[odb-users] reuse inheritance with templated base class

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


Hi,

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?

Regards,
Marcel

#include <odb/core.hxx>

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

    virtual void foo() = 0;

protected:
    friend class odb::access;

private:
    #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>
{
public:
    Derived() {};
    ~Derived() {};

    void foo() {};

protected:
    friend class odb::access;
};


More information about the odb-users mailing list