Boost logo

Boost Users :

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


Joseph Turian wrote:
> Robert,
>
>> 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.
>
> How can I ensure, in the example I give, that the primitive static
> members will be stored/loaded only once?

use BOOST_STRONGTYPE to wrap them in a typesafe wrapper
and make sure the new wrapper uses the default tracking behavior.

> I see how to control the tracking behavior of classes.
> http://www.boost.org/libs/serialization/doc/traits.html#tracking
> How can I change the tracking of particular objects?

You can't. You can only control it by the type of object. It would
be possible to augment the library to assign tracking an other traits
on a per object basis, but it doesn't seem that there has any been
any real demand for it. The same effect can easily be obtained for
specifice cases by usiing the BOOST_STRONGTYPE approach above.
In practice the assigment of serialization traits to the type as opposed
to the object seems to almost always work well.

> Thank you for explaining that tracking means that two objects with the
> same address are never serialized twice.

Unless tracking is turned off by setting the corresponding serialization
trait.

>I didn't understand that from
> the documentation, but it's very useful.

> Is the performance overhead too high for me just to turn on tracking
> for all objects?

I would expect so. and I think it would seem to be overkill to most of us.

Robert Ramey

>
> Joseph


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