
Hello,
I took your code and fixed it up to that below and it compile and tests fine.
Note the usage of BOOST_SERIALIZATION_BASE_OBJECT_NVP below which is key. This is explained in the documentation.
thanks a lot for the answer. Now it works correctly, I still "dare" to
give a suggestion and ask help again:
1) In the documentation I think that the relevant information about how to
serialize properly a derived polymorphic class should stay also in
"Pointers to Objects of Derived Classes -> Registration". In that section
is not mentioned boost::serialization::base_object nor
BOOST_SERIALIZATION_BASE_OBJECT_NVP, and I think it would be helpful to
add an explanation in there: in fact the provided example (class base ...
class derived_one ... derived_two) does not work out of the box.
I think that to the above mentioned section should be added a reference
(or directly the content) of the section
Serializable Concept->Pointers->Pointers of Derived Objects->Runtime
Casting, which explicitly says to call
boost::serialization::base_object<base>(*this), so that the relationship
between a "base/derived pair is added to the table", and make things
working :)
2) Since I do not like to serialize the base object, I do not want to call
boost::serialization::base_object in the derived serializing method, but
instead I wish to just explicitly register base/derived relationship with:
boost::serialization::void_cast_register