Boost logo

Boost Users :

From: Robert Ramey (ramey_at_[hidden])
Date: 2006-01-16 17:48:58

Objects that are tracked are tracked by address regardless of whether they
are static variables or not. So the answer to your question is Yes - static
pointers will be serialized only once - providing they point to tracked

However, in your example, the static object isn't a pointer - its a static
integer. Given that default behavior for primitive types (including
integers) is not tracked, multiple copies of j will be stored/loaded.

Robert Ramey

Joseph Turian wrote:
> Hi,
> If see from the serialization documentation that if I serialize a
> pointer more than once, only one instance will appear in the archive.
> However, what about static member variables?
> Will they only be serialized once, even if I serialize multiple
> objects of the class type?
> e.g.
> class foo {
> private:
> int i;
> static int j;
> friend class boost::serialization::access;
> template<class Archive> void serialize(Archive& ar, const unsigned
> int version) {
> ar & i;
> ar & j; // Will j be serialized multiple times, i.e. once per
> foo instance?
> }
> };
> Thanks,
> Joseph

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at