[#AsBase-0af] = AsBase :mrdocs: Convert any argument to a reference to X, maintaining constness. == Synopsis Declared in `<serialize.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- 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 [cols="1,4"] |=== | Name| Description | *x* | The derived object to view as its base class. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#