0

I'm trying to use ODB, but I'm stuck with an error about std::atomic. I've read this : the same problem on odb mailing list 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 I still have an error when I try to get my shema (using :odb -d -v mysql --generate-query --generate-schema *.h ) :

/usr/local/include/odb/wrapper-traits.hxx:277:30: error: atomic’ is not a member of ‘std

May someone help me with this ? Xavier.

Xavier
  • 41
  • 7

1 Answers1

0

Finally, I'm using other way : I'm using virtual data member

    #pragma db transient
    std::atomic<double> valAtom;
#pragma db member(valAtom_) virtual(double) \
    get(this.valAtom.load (std::memory_order_relaxed)) \
    set(this.valAtom.store ((?), std::memory_order_relaxed))

And (thanks jignatius ) I had --std c++11 to my odb command. And that's fine !

Xavier
  • 41
  • 7