Namespaces
Variants

Standard library header <typeindex> (C++11)

From cppreference.net
Standard library headers

このヘッダは type support ライブラリの一部です。

目次

インクルード

(C++20)
三方比較演算子 サポート

クラス

(C++11)
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

namespace std {
  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; // 説明専用
    // ここで参照ではなくポインタを使用していることは、
    // デフォルトのコピー/ムーブコンストラクタと代入演算子が
    // 提供され、期待通りに動作することを意味します。
  };
}