AW: [odb-users] reuse inheritance with templated base class

Marcel Nehring mne at qosmotec.com
Tue Aug 5 12:32:05 EDT 2014


Hi Boris,

I tried the new version you build for me - thanks for that.

However, either I did not fully understand how to use it, or it does not work properly.
I modified your example a bit by removing the class called "derived". In case I specify the id pragma only once I get a "no data member designated as an object id" error. The error is issued for the line with the typedef. For the version pragma it suffices to specify it only once in the "base_data" class. Am I missing something?

The code looks like the one below.

Regards,
Marcel

#pragma db object abstract optimistic
struct base_data
{
#pragma db id auto
    unsigned long id;

#pragma db version
    unsigned long version;
};

template <typename T>
struct base : public base_data
{
    T x;
};

typedef base<std::string> base_derived;
#pragma db object(base_derived)
//#pragma db member(base_derived::id) id auto //uncomment to resolve error
//#pragma db member(base_derived::version) version //this is not needed



More information about the odb-users mailing list