...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::typeindex::ctti_type_index
// In header: <boost/type_index/ctti_type_index.hpp> class ctti_type_index { public: // types typedef unspecified type_info_t; // construct/copy/destruct ctti_type_index() noexcept; ctti_type_index(const type_info_t &) noexcept; // private member functions std::size_t get_raw_name_length() const noexcept; // public member functions const type_info_t & type_info() const noexcept; const char * raw_name() const noexcept; std::string pretty_name() const; std::size_t hash_code() const noexcept; // public static functions template<typename T> static ctti_type_index type_id() noexcept; template<typename T> static ctti_type_index type_id_with_cvr() noexcept; template<typename T> static ctti_type_index type_id_runtime(const T &) noexcept; };
This class is a wrapper that pretends to work exactly like stl_type_index, but does not require RTTI support. For description of functions see type_index_facade.
This class produces slightly longer type names, so consider using stl_type_index in situations when typeid() is working.
ctti_type_index
public
construct/copy/destructctti_type_index() noexcept;
ctti_type_index(const type_info_t & data) noexcept;
ctti_type_index
public member functionsconst type_info_t & type_info() const noexcept;
Override: This function may be redefined in Derived class. Overrides must not throw.
Returns: |
Const reference to underlying low level type_info_t. |
const char * raw_name() const noexcept;
Override: This function must be redefined in Derived class. Overrides must not throw.
Returns: |
Pointer to unredable/raw type name. |
std::string pretty_name() const;
Override: This function may be redefined in Derived class. Overrides may throw.
Returns: |
Human readable type name. By default returns Derived::name(). |
std::size_t hash_code() const noexcept;
Override: This function may be redefined in Derived class. Overrides must not throw.
Note | |
---|---|
<boost/functional/hash.hpp> has to be included if this function is used. |
Returns: |
Hash code of a type. By default hashes types by raw_name(). |
ctti_type_index
public static functionstemplate<typename T> static ctti_type_index type_id() noexcept;
This is a factory method that is used to create instances of Derived classes. boost::typeindex::type_id() will call this method, if Derived has same type as boost::typeindex::type_index.
Override: This function may be redefined and made public in Derived class. Overrides must not throw. Overrides must remove const, volatile && and & modifiers from T.
Template Parameters: |
|
||
Returns: |
type_index for type T. |
template<typename T> static ctti_type_index type_id_with_cvr() noexcept;
This is a factory method that is used to create instances of Derived classes. boost::typeindex::type_id_with_cvr() will call this method, if Derived has same type as boost::typeindex::type_index.
Override: This function may be redefined and made public in Derived class. Overrides must not throw. Overrides must not remove const, volatile && and & modifiers from T.
Template Parameters: |
|
||
Returns: |
type_index for type T. |
template<typename T> static ctti_type_index type_id_runtime(const T & variable) noexcept;
This is a factory method that is used to create instances of Derived classes. boost::typeindex::type_id_runtime(const T&) will call this method, if Derived has same type as boost::typeindex::type_index.
Override: This function may be redefined and made public in Derived class.
Parameters: |
|
||
Returns: |
type_index with runtime type of variable. |