Hi! A question on serializing pointers to derived classes:
When I serialize naked polymorphic pointers through base pointers, things
work as expected, ie the derived classes are serailized and deserialized.
However, when I replace the naked pointers with corresponding
boost::shared_ptr's, I get an archive_exception, to the tune of
"unregistered class".
I'm using BOOST_CLASS_EXPORT, and not the register_type<> functions.
Is this supposed to happen, or do I need some additional type registration
beyond what was necessary for serializing naked pointers?
Thanks!
Jarl.
The code:
//B and C derive from A
std::ostringstream os;
boost::archive::text_oarchive oa(os);
//A *pb0 = new B(15,16);
//A *pc0 = new C(17, 18, 19);
boost::shared_ptr<A> pb0( new B(15,16) );
boost::shared_ptr<A> pc0( new C(17, 18, 19) );
oa << pb0;
oa << pc0;
std::string data = os.str();
{
std::istringstream is(data);
boost::archive::text_iarchive ia(is);
//A *pa1 = NULL;
//A *pa2 = NULL;
boost::shared_ptr<A> pa1;
boost::shared_ptr<A> pa2;
ia >> pa1;
ia >> pa2;
B* pb = dynamic_cast(pa1.get());
C* pc = dynamic_cast