cereal
cereal copied to clipboard
UNREGISTERED_POLYMORPHIC_CAST_EXCEPTION thrown on save for polymorphic types using split save/load member functions
Are split save/load member functions supported for polymorphic types?
To demonsrate, I modified the polymorphic unittest so that PolyDerived looks like the following:
struct PolyDerived : PolyBase
{
PolyDerived() {}
PolyDerived( int xx, float yy, bool aa, double bb ) :
PolyBase( xx, yy ), a(aa), b(bb) {}
virtual ~PolyDerived() {}
bool a;
double b;
// template <class Archive>
// void serialize( Archive & ar )
// {
// ar( cereal::base_class<PolyBase>( this ),
// a, b );
// }
template<class Archive>
void save( Archive & ar ) const
{
ar( cereal::base_class<PolyBase>( this ),
a, b );
}
template<class Archive>
void load( Archive & ar )
{
ar( cereal::base_class( this ),
a, b );
}
bool operator==( PolyDerived const & other ) const
{
return PolyBase::operator==( other ) && a == other.a && std::abs(b - other.b)