标准库标头 <typeindex> (C++11)
来自cppreference.com
此头文件是类型支持库的一部分。
包含 | ||
(C++20) |
三路比较运算符支持 | |
类 | ||
(C++11) |
对 type_info 对象的包装,用作关联容器和无序关联容器的索引 (类) | |
(C++11) |
std::type_index 的散列支持 (类模板特化) | |
前置声明 | ||
在标头
<functional> 定义 | ||
(C++11) |
散列函数对象 (类模板) |
[编辑] 概要
#include <compare> namespace std { class type_index; template<class T> struct hash; template<> struct hash<type_index>; }
[编辑] 类 std::type_index
class type_index { public: type_index(const type_info& rhs) noexcept; bool operator==(const type_index& rhs) const noexcept; bool operator< (const type_index& rhs) const noexcept; bool operator> (const type_index& rhs) const noexcept; bool operator<=(const type_index& rhs) const noexcept; bool operator>=(const type_index& rhs) const noexcept; strong_ordering operator<=>(const type_index& rhs) const noexcept; size_t hash_code() const noexcept; const char* name() const noexcept; private: const type_info* target; // 仅用于阐释 // 注意,此处使用了指针而非引用, // 表示预置的复制/移动构造函数及赋值运算符均有所提供并按预期工作。 }; }