...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::stl_type_index
// In header: <boost/type_index/stl_type_index.hpp> class stl_type_index : public boost::typeindex::type_index_facade< stl_type_index, std::type_info > { public: // types typedef std::type_info type_info_t; // construct/copy/destruct stl_type_index() noexcept; stl_type_index(const type_info_t &) noexcept; // public member functions const type_info_t & type_info() const noexcept; const char * raw_name() const noexcept; const char * name() const noexcept; std::string pretty_name() const; std::size_t hash_code() const noexcept; bool equal(const stl_type_index &) const noexcept; bool before(const stl_type_index &) const noexcept; // public static functions template<typename T> static stl_type_index type_id() noexcept; template<typename T> static stl_type_index type_id_with_cvr() noexcept; template<typename T> static stl_type_index type_id_runtime(const T &) noexcept; };
This class is a wrapper around std::type_info, that workarounds issues and provides much more rich interface. For description of functions see type_index_facade.
This class requires typeid() to work. For cases when RTTI is disabled see ctti_type_index.
stl_type_index
public member functionsconst type_info_t & type_info() const noexcept;
const char * raw_name() const noexcept;
const char * name() const noexcept;
std::string pretty_name() const;
std::size_t hash_code() const noexcept;
bool equal(const stl_type_index & rhs) const noexcept;
bool before(const stl_type_index & rhs) const noexcept;
stl_type_index
public static functionstemplate<typename T> static stl_type_index type_id() noexcept;
template<typename T> static stl_type_index type_id_with_cvr() noexcept;
template<typename T> static stl_type_index type_id_runtime(const T & value) noexcept;