Boost logo

Boost Users :

Subject: Re: [Boost-users] [1.41][serialization] deserialization of weak_ptrfails
From: Robert Ramey (ramey_at_[hidden])
Date: 2009-12-14 13:47:55


Normally, one would expect so serialize a base class using
the base object as below:

However, serialization for enable_shared_from_this has not
been written, so this won't work until that happens. A few
minutes spent looking into this reveals that implementing
serialization for this class is not a trivial task. So, for now,
this cannot be done.

Robert Ramey

Alexander Gutenev wrote:
> The example below works in 1.40 and fails in 1.41
>
> struct X
> : boost::enable_shared_from_this<X>
> {
> X(){}
> virtual ~X() {}
> explicit X(int i) : i(i) {}
>
> template<class Archive>
> void serialize(Archive & ar, const unsigned int version)
> {
    ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(
        boost::enable_shared_from_this<X>
    );
> ar & boost::serialization::make_nvp("i", i);
> }
>
> int i;
> };


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