[odb-users] std::atomic<double> cause me trouble.

Xavier Monset xavier.monset at gmail.com
Tue Aug 11 07:24:34 EDT 2020


Hi !

I'm trying to use ODB, but I'm stuck with an error about std::atomic.
I've read this :
https://odb-users.codesynthesis.narkive.com/yfbzUHDa/wrapping-existing-members-with-std-atomic
So I tried to to define the odb::wrapper_traits specialization for
std::atomic in file wrapper-traits.hxx.
I did it this by adding :

// Specialization for odb::atomic.
> //
> template <typename T>
> class wrapper_traits< std::atomic<T> >
> {
> public:
> // T can be const.
> //
> typedef T wrapped_type;
> typedef nullable<T> wrapper_type;
>
> // T can be const.
> //
> typedef
> typename odb::details::meta::remove_const<T>::result
> unrestricted_wrapped_type;
>
> static const bool null_handler = true;
> static const bool null_default = true;
>
> static bool
> get_null (const wrapper_type& n)
> {
> return n.null ();
> }
>
> static void
> set_null (wrapper_type& n)
> {
> n.reset ();
> }
>
> static const wrapped_type&
> get_ref (const wrapper_type& n)
> {
> return *n;
> }
>
> static unrestricted_wrapped_type&
> set_ref (wrapper_type& n)
> {
> if (n.null ())
> n = unrestricted_wrapped_type ();
>
> return const_cast<unrestricted_wrapped_type&> (*n);
> }
>


> };
>

 But, now, I'm getting error. I have this complain : "
/usr/local/include/odb/wrapper-traits.hxx:277:30*: error: ‘atomic’ is not a
member of ‘std*’"

May someone help me with this ?
Thanks.
Xavier.


More information about the odb-users mailing list