
a) I don't see any "virtual" in the "general form". For this to work, the base class has to have at least one virtual function. We can't verify this from the code displayed so far. b) My currently recommended practice is that BOOST_CLASS_EXPORT not be in the header but rather in the *.cpp file. Check the updated documents in the trunk. Robert Ramey Jerry wrote:
Sohail,
Might be a long shot, but are you sure you've done this throughout your code:
http://www.boost.org/libs/serialization/doc/special.html#export
Yes, all done. The failing code is _after_ the check for unregistered classes. No exception is thrown, but the assert() is triggered.
BTW here's the general form as I outlined a few weeks back: Can you see any problems.
//---------header file-----------
// example derived serializable class class derived : public base { std::string m_name; friend class boost::serialization::access; template<class Archive> void serialize(Archive &ar, const unsigned int /*version*/) { // serialize base class ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(base); // handle any members in derived ar & BOOST_SERIALIZATION_NVP(m_name); } public: derived() {} };
// ensure correct ID generation when saving via base* // if this is omitted you'll get an unregistered exception unless // you register each class directly with the archive BOOST_CLASS_EXPORT_GUID(derived,"derived")
//--------------/header file---------------