Convert any argument to a reference to X, maintaining constness.
Synopsis
Declared in <serialize.h>
template<
class Out,
class In>
Out&
AsBase(In& x);
Description
This can be used in serialization code to invoke a base class's serialization routines.
Example use: class Base { ... }; class Child : public Base { int m_data; public: SERIALIZE_METHODS(Child, obj) { READWRITE(AsBase<Base>(obj), obj.m_data); } };
static_cast cannot easily be used here, as the type of Obj will be const Child& during serialization and Child& during deserialization. AsBase will convert to const Base& and Base& appropriately.
Return Value
A reference to x typed as the base class Out.
Parameters
Name |
Description |
x |
The derived object to view as its base class. |
Created with MrDocs