Nick
Nick

Reputation: 509

Boost serialization base class

When using Boost's serialization library, you can invoke the serialization of the base class with

ar & boost::serialization::base_object<> (*this);

according to the documentation. I am wondering, though, if it is safe to do without this (I mean can you choose not to serialize the data from the base class?)

Upvotes: 2

Views: 259

Answers (1)

mirams
mirams

Reputation: 766

You can choose not to serialize the data from a base class, but then any member variables that are serialized in the base class will not get recorded and restored.

This may be OK if you only want to serialize the particular concrete class you are working with, and you manually archive all the variables you need to reconstruct your class instance.

But why would you want to? It generally suggests something is wrong with the inheritance structure...

Upvotes: 1

Related Questions