标准库标头 <typeindex> (C++11)

来自cppreference.com
< cpp‎ | header


 
 
标准库头
通用工具
<any> (C++17)
<bitset>
<bit> (C++20)
<charconv> (C++17)
<expected> (C++23)
<format> (C++20)
<functional>
<optional> (C++17)
<stdbit.h> (C++26)
<tuple> (C++11)
<typeindex> (C++11)
<utility>
<variant> (C++17)
容器
<array> (C++11)
<deque>
<flat_map> (C++23)
<flat_set> (C++23)
<forward_list> (C++11)
<hive> (C++26)
<inplace_vector> (C++26)   
<list>
<map>
<mdspan> (C++23)
<queue>
<set>
<span> (C++20)
<stack>
<unordered_map> (C++11)
<unordered_set> (C++11)
<vector>
迭代器
<iterator>
范围
<generator> (C++23)
<ranges> (C++20)
 

此头文件是类型支持库的一部分。

目录

包含

(C++20)
三路比较运算符支持[编辑]

type_info 对象的包装,用作关联容器和无序关联容器的索引
(类) [编辑]
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; // 仅用于阐释
    // 注意,此处使用了指针而非引用,
    // 表示预置的复制/移动构造函数及赋值运算符均有所提供并按预期工作。
  };
}