Boost logo

Boost Users :

Subject: Re: [Boost-users] [serialization] Registering/exporting shared_ptr<T> in a library
From: Martin Weinberg (martin.weinberg_at_[hidden])
Date: 2013-12-28 19:02:18

On 12/28/2013 06:34 PM, Robert Ramey wrote:
> On Saturday, December 28, 2013 2:15:44 PM UTC-8, Martin Weinberg wrote:
> I have a shared library for derived and base classes. My code passes
> instances of derived classes T using boost::shared_ptr<B> to the base
> class. This all works as expected.
> macros to register both the classes Tand shared_ptr<T> typedefs to
> all
> the classes.
> If I attempt to serialize a base class pointer,
> boost::serialization can
> not find the serialize member for the shared_ptr to the derived
> class.
> a) double check the documentation boost/serialization/case
> studies/shared_ptr<T> revisited
> b) Make sure you'r doing the following
> class A {...};
> class B : public A {...}
> ...
> A * = new B; // note we create a B and cast the address to an A* !!!
> ... should be no problem from here on out.
> Robert Ramey

Thanks. What I'm doing is:

shared_ptr<A> t(new B);

and then:

ar & A;

It's ok if I put:


in the caller but not if I put them in the library. Trying to
understand if there's a way to put registration in the library rather
than the main source.

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