type_index 类

type_index 类将指针包装到 type_info 类,以便通过这些对象辅助编写索引。

class type_index { public: type_index(const type_info& tinfo); const char *name() const; size_t hash_code() const; bool operator==(const type_info& right) const; bool operator!=(const type_info& right) const; bool operator<(const type_info& right) const; bool operator<=(const type_info& right) const; bool operator>(const type_info& right) const; bool operator>=(const type_info& right) const; };

构造函数将 ptr 初始化为 &tinfo

name 返回的是 ptr->name()

hash_code 返回 ptr->hash_code()

operator== 返回 *ptr == right.ptr

operator!= 返回 !(*this == right)

operator< 返回 *ptr->before(*right.ptr)

operator<= 返回 !(right < *this)

operator> 返回 right < *this

operator>= 返回 !(*this < right)

另请参阅

运行时类型信息
<typeindex>