cereal
A C++11 library for serialization
|
Casts a derived class to its virtual base class in a way that allows cereal to track inheritance. More...
#include </home/shane/workspace/cereal/include/cereal/types/base_class.hpp>
Public Member Functions | |
template<class Derived > | |
virtual_base_class (Derived const *derived) | |
Public Attributes | |
Base * | base_ptr |
Casts a derived class to its virtual base class in a way that allows cereal to track inheritance.
This should be used in cases when a derived type features virtual inheritance from some base type. This allows cereal to track the inheritance and to avoid making duplicate copies during serialization.
It is safe to use virtual_base_class in all circumstances for serializing base classes, even in cases where virtual inheritance does not take place, though it may be slightly faster to utilize cereal::base_class<> if you do not need to worry about virtual inheritance.
This also automatically registers polymorphic relation between the base and derived class, assuming they are indeed polymorphic. Note this is not the same as polymorphic type registration. For more information see the documentation on polymorphism. If using a polymorphic class, be sure to include support for polymorphism (cereal/types/polymorphic.hpp).