Ciao folks,
I'm quiet desperate not to find the source of the problem. I'm using Boost:serialization (version 1.46.1) and everything was working fine with binary_oarchive
. I have a hierarchy of classes and, thus, I use the register_type()
.
However, where I came to use binary_iarchive
to unserialize my objects, I got
error: cannot allocate an object of abstract type
which comes from the call of register_type()
on the input archive.
After googling I found out that the macro BOOST_SERIALIZATION_ASSUME_ABSTRACT(T)
must be used for the abstract classes. The problem is that it simply doesn't work :).
Can anyone help me out ?
More about my code :
virtual void AbstractClass::initBinarySerialization(binary_iarchive& ia)
{
ia.register_type<AbstractClass>();
}
virtual void SubClass::initBinarySerialization(binary_iarchive& ia)
{
AbstractClass::initBinarySerialization(ia);
ia.register_type<SubClass>();
}
I call initBinarySerialization
before reading in the archive.