Boost Users :
From: Jarl Lindrud (jlindrud_at_[hidden])
Date: 2005-01-11 11:05:07
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
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?
//B and C derive from A
//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();
//A *pa1 = NULL;
//A *pa2 = NULL;
ia >> pa1;
ia >> pa2;
B* pb = dynamic_cast<B *>(pa1.get());
C* pc = dynamic_cast<C *>(pa2.get());
Express yourself instantly with MSN Messenger! Download today it's FREE!
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