Boost logo

Boost :

From: martin.ecker_at_[hidden]
Date: 2004-11-09 02:27:25

Peter Dimov wrote:
> Correct deserialization of shared_ptr/weak_ptr requires keeping a
> of shared_ptr<void> that holds the objects alive during the
> process.


> The problem I've not been able to solve so far is where to keep it
> without making shared_ptr special WRT the archives. :-)

At work, we're using a modified version of boost::serialization where
we've added a shared_ptr registry (the container to keep the pointed-
to objects alive) as a kind of user data to the archives. So this
could be a way, which would, however, require users to explicitly
associate the shared_ptr registry with archives that have to
deserialize shared_ptrs/weak_ptrs. We haven't found this to be much of
a problem, though.

In general, I propose adding some sort of user data mechanism to
archives. Our system is quite complex and we use boost::serialization
exclusively to serialize all the classes. Sometimes it is necessary to
store certain state during serialization/deserialization that is
associated with archives and that can be accessed from within
serialization code. This is especially true for objects that depend on
each other and have more complex relationships, such as shared_ptr and

Best Regards,

TAB Austria
Haiderstraße 40
4052 Ansfelden
Phone: +43 7229 78040-218
Fax: +43 7229 78040-209
E-mail: martin.ecker_at_[hidden]

Boost list run by bdawes at, gregod at, cpdaniel at, john at