[#AsBase-0af]
= AsBase
:mrdocs:

Convert any argument to a reference to X, maintaining constness&period;

== Synopsis

Declared in `&lt;serialize&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class Out,
    class In&gt;
Out&
AsBase(In& x);
----

== Description

This can be used in serialization code to invoke a base class&apos;s serialization routines&period;

Example use&colon; class Base &lcub; &period;&period;&period; &rcub;&semi; class Child &colon; public Base &lcub; int m&lowbar;data&semi; public&colon; SERIALIZE&lowbar;METHODS(Child, obj) &lcub; READWRITE(AsBase&lt;Base&gt;(obj), obj&period;m&lowbar;data)&semi; &rcub; &rcub;&semi;

static&lowbar;cast cannot easily be used here, as the type of Obj will be const Child&amp; during serialization and Child&amp; during deserialization&period; AsBase will convert to const Base&amp; and Base&amp; appropriately&period;

== Return Value

A reference to x typed as the base class Out&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *x*
| The derived object to view as its base class&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
