标准库标头 <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; // 仅用于阐释
    // 注意,此处使用了指针而非引用,
    // 表示预置的复制/移动构造函数及赋值运算符均有所提供并按预期工作。
  };
}