rttr_enable.h File Reference
#include <type_traits>
#include "rttr/type.h"
#include "rttr/type_list.h"

Go to the source code of this file.

Macros

#define RTTR_ENABLE(...)
 This macro is necessary in order to retrieve type information about the inheritance graph of a class. More...
 

Macro Definition Documentation

#define RTTR_ENABLE (   ...)

This macro is necessary in order to retrieve type information about the inheritance graph of a class.

When there is no inheritance graph, the macro is not needed, e.g. for POD types.

Put the macro inside every class, where you need the complete inheritance information about the class type.

struct Base
{
};

Place the macro RTTR_ENABLE() somewhere in the class, it doesn't matter if its under the public, protected or private class accessor section. The macro will close itself with a private visibility. So when you not specify anything afterwords, everything will be private.

Into the derived class you put the same macro, but now as argument the name of the parent class. Which is in this case Base.

struct Derived : Base
{
};

When you use multiple inheritance you simply separate every class with a comma.

struct MultipleDerived : Base, Other
{
RTTR_ENABLE(Base, Other)
};
Remarks
Without this macro, it will not be possible to use rttr_cast or meta information in the type class, like: get_base_classes() or get_derived_classes().