[odb-users] reuse inheritance with templated base class

Marcel Nehring mne at qosmotec.com
Tue Jul 29 10:05:45 EDT 2014


I am trying to run the ODB compiler on my code but I keep getting "no data member designated as an object id" and "optimistic class without a version member" errors. To me it looks like that this happens when the base class is a template class.

The following example does not compile, producing the two error messages above. However, if one changes Base to a none template class, it compiles just fine.

Do I have to specify something else to make this work? Is this a bug or expected behavior?


#include <odb/core.hxx>

#pragma db object optimistic
template <class T>
class Base
    Base() : m_id(0), m_version(0) {};
    virtual ~Base() {};

    virtual void foo() = 0;

    friend class odb::access;

    #pragma db id auto
    long long m_id;

    #pragma db version
    const unsigned long long m_version;

#pragma db object
class Derived : public Base<Derived>
    Derived() {};
    ~Derived() {};

    void foo() {};

    friend class odb::access;

More information about the odb-users mailing list