Boost logo

Boost Users :

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


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.

I've used the BOOST_CLASS_EXPORT_KEY and BOOST_CLASS_EXPORT_IMPLEMENT
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.

However, if I don't register the shared_ptr<T> for each derived class T
in the shared library, but instead use BOOST_EXPORT_CLASS(shared_ptr<T>)
in main(), everything works fine.

Is there a workaround so that I don't need
BOOST_EXPORT_CLASS(shared_ptr<T>) in main() for every possible derived
class?

Thanks. I can provide a trivial example that illustrates this issue if
that would help.


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