Boost logo

Boost :

From: Mikhail Kubzin (mikhail.kubzin_at_[hidden])
Date: 2005-12-08 10:21:14


I use boost serialisation in my project and I need to serialise a
vector of pointers (boost::shared_ptr) to a base class. The base class
is declared in one dll in the following way:

A.h:

namespace boost {
  namespace serialization {
      class access;
  }
}
class A
{...
};

A.cpp
#include <... boost serialization headers .. >
BOOST_CLASS_VERSION(A, 1)

....

In another dll I declare class B derived from A declared and
implemented in the same manner ( .h files do not include boost
serialization headers). The problem is that inside the sirialisation
(save/load) function of the derived class I get correct file_version
value while in the serialisation function of the base class
file_version is 0.

I call serialization function of the base class as advised in the
documentation:
ar & boost::serialization::base_object<A>(*this);

However, if I insert BOOST_CLASS_VERSION(A, 1) into B.cpp then
file_version in A's serialisation function is initialised properly.

It is a pain to update the version of the base class in all derived
classes from one side, it is also impractical to include all boost
headers and class version information into .h files since the
compilation time grows dramatically and the size of the executables
increases several times.

Any thoughts and suggestions are welcome!
Thank you in advance,

Mikhail


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk