yomm2

yorel::yomm2::policy::std_rtti
defined in <yorel/yomm2/policy.hpp>, also provided by <yorel/yomm2/core.hpp>, <yorel/yomm2/keywords.hpp>

struct std_rtti;

Implement rtti using the RTTI facilities provided by standard C++.

Static member functions

Name Description
type_id static_type<T> return a type_id for T
type_id dynamic_type<T> return a type_id for an object’s dynamic type
void type_name<Stream> write a description of type_id to a stream
unspecified type_index return a unique key for a type_id
D dynamic_cast_ref<D, B> cast from base class to derived class

static_type

template<class Class>
static type_id static_type();

Return &typeid(Class), cast to a type_id.

Template parameters

dynamic_type

template<class Class>
static type_id dynamic_type(const Class& obj);

Return &typeid(obj), cast to a type_id.

Template parameters

type_name

template<typename Stream>
static void type_name(type_id type, Stream& stream);

Execute stream << reinterpret_cast<const std::type_info*>(type)[name](None)().

Template parameters

Function parameters

type_index

static /*unspecified*/ type_index(type_id type);

Return std::type_index(*reinterpret_cast<const std::type_info*>(type)).

The function is required because C++ does not guarantee that there is a single instance of std::type_info for each specific type. update builds a map associating the std::type_indexs to a set of type_ids, thus ensuring proper operation, even in the (unlikely) case that some types have multiple type_info objects, and thus static_type and dynamic_type do not return the same value for the same class.

Function parameters

dynamic_cast_ref

template<typename Derived, typename Base>
static Derived dynamic_cast_ref(Base&& obj);

Cast obj using the dynamic_cast operator. Note that YOMM2 will use a static_cast whenever possible.

Template parameters

Function parameters