AW: [odb-users] reuse inheritance with templated base class
Marcel Nehring
mne at qosmotec.com
Wed Jul 30 04:31:01 EDT 2014
Hi Boris,
uhm, that is quite a limitation. I did not expect that.
The example I provided was only a short, self-contained, compilable example to demonstrate the error I am getting. In fact my code *does* contain persistent classes where the persistent data depends on the template argument.
Regards,
Marcel
-----Ursprüngliche Nachricht-----
Von: Boris Kolpackov [mailto:boris at codesynthesis.com]
Gesendet: Dienstag, 29. Juli 2014 20:15
An: Marcel Nehring
Cc: odb-users at codesynthesis.com
Betreff: Re: [odb-users] reuse inheritance with templated base class
Hi Marcel,
Marcel Nehring <mne at qosmotec.com> writes:
> #pragma db object optimistic
> template <class T>
> class Base
ODB does not support persistent class templates. The persistent data (m_id and m_version in your case) rarely depends on the template argument (it doesn't in your case) so what you can do is split your base into two classes:
#pragma db object optimistic
class BaseData
{
#pragma db id auto
long long m_id;
#pragma db version
const unsigned long long m_version;
};
// Note: not persistent object
template <class T>
class Base
{
...
};
#pragma db object
class Derived : public Base<Derived>, public BaseData {
...
};
Boris
More information about the odb-users
mailing list