Boost logo

Boost :

From: FATH Francois (francois.fath-renexter_at_[hidden])
Date: 2004-05-07 12:33:47


Robert Ramey wrote:

...
> If objects are to be serialized through a base class
> pointer, they must either:
>
> a) Be previously serialized directly

If I understand what you mean by "serialized directly", that is what I
am trying to do.

> or through the derived class pointer.

This way it works.
This is the meaning of "ar & BOOST_SERIALIZATION_NVP(this)" in the code
at the end. It is semantically meaningless, but it generates a reference
to the object with the pointer of the right type. Hopefully it does not
do anything bad when deserializing.

>>template<class Archive>
>>void serialize(Archive & ar, const unsigned int version)
>> {
>> ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
>> // What is the intended purpose for the following?
>> // I can't see why one would want to do this.
>> /* uncomment to avoid the exception
>> * ar & BOOST_SERIALIZATION_NVP(this);
>> */
>> }
>>};

François Fath


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