[odb-users] reuse inheritance with templated base class

Boris Kolpackov boris at codesynthesis.com
Fri Aug 1 06:14:20 EDT 2014


Hi Marcel,

Marcel Nehring <mne at qosmotec.com> writes:

> So I would have to split all my persistent template classes into two?
> A template part and a none template part? Actually I would like to 
> avoid that since it would mean a blow up in my number of classes.
> However, if I understand you correctly this would only be a possible
> optimization to reduce code size and to avoid the need to respecify
> pragmas for every instantiation?

Yes, that's correct. For example, if your id member is in the template,
then you will have to specify:

#pragma db member(some_base:::m_id) id auto

for every instantiation. However, if the type of m_id does not depend
on the template argument, then you can put it into a non-template base
class and specify the id pragma only once.

You also don't have to have a separate non-template base for every
template base. I would imagine in a typical situation you would have
the same types for the id and version members for all (or most) of
your classes. So you could place them into a single non-template base
and use it for all of your templates.


> However, yes, it would be great if you could build a pre-release binary. 

Here is the 2.4.0.a3 pre-release:

http://codesynthesis.com/~boris/tmp/odb/pre-release/

The NEWS file entry:

 * Support for defining persistent objects as instantiations of C++ class
   templates, similar to composite value types. For details, refer to
   Section 15.2, "Persistent Class Template Instantiations" in the ODB
   manual.

Let me know if there are any problems.

Boris



More information about the odb-users mailing list