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++.
| 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 |
template<class Class>
static type_id static_type();
Return &typeid(Class), cast to a type_id.
Template parameters
template<class Class>
static type_id dynamic_type(const Class& obj);
Return &typeid(obj), cast to a type_id.
Template parameters
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
Stream: a model of RestrictedOutputStream.Function parameters
type: the type id of the class to describe.stream: the stream to write the description to.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
type: the type id of a classtemplate<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
Base: a registered class. Base&& is guaranteed to evaluate to a
referenceDerived: a registered class, derived from Base.Function parameters
obj: the object to cast.
to a Base object.