最終更新日時(UTC):
が更新

履歴 編集

function
<typeinfo>

std::type_info::hash_code(C++11)

size_t hash_code() const noexcept;

概要

型のハッシュコードを取得する

戻り値

未規定の値を返す。一度のプログラム実行中において、同じ型に対しては同じ値が返される。

例外

投げない

備考

この関数の実装は、異なる型に対しては異なる値を返すことが推奨される。

#include <iostream>
#include <typeinfo>

int main()
{
  std::cout << typeid(int).hash_code() << std::endl;
  std::cout << typeid(char).hash_code() << std::endl;
}

出力例

15265900242347711334
9981675175275146982

バージョン

言語

  • C++11

処理系

参照