Boost logo

Boost Users :

Subject: Re: [Boost-users] Serialization of a class which contains a pointer
From: Robert Ramey (ramey_at_[hidden])
Date: 2010-05-19 12:25:49


Nguyen Kim Son wrote:
> Hello,
>
> I've tried a simple example with the serialization of a class that
> contains an int and a pointer to int (named "nothing" in the code)
> but after having tried both ar & (*b) and ar & b (b is the second
> variable), I have not been succeeded to send the class via the call
> "send" (in boost::mpi).
> My code is found at:
> http://www.copypastecode.com/29170/
> Does anyone has an idea of why it doesn't work?
> Thank you in advance!
>
> Son.

This would be a pointer to a primitive. Correct serialization of a pointer
requires that all pointers to a type be tracked. No one would want to
do this for all integers in the program. If you really want to serialize
a pointer to a primitive type - like an int - use BOOST_SERIALIZATION_STRONGTYPEDEF
to make a distinct type equivalent to an int which is not in fact an int.

Review the manual regarding serialization of pointers which has
some subtle aspects.

Robert Ramey



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net