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

履歴 編集

class template
<memory>

std::indirect::hash(C++26)

namespace std {
  template <class T, class Allocator>
  struct hash<indirect<T, Allocator>>;
}

概要

std::hashクラスの、std::indirectに対する特殊化。

この特殊化は、hash<T>が有効である場合にのみ有効となる。

効果

indirect<T, Allocator>型のオブジェクトiに対して、hash<indirect<T, Allocator>>()(i)は、iが無効値状態でなければhash<T>()(*i)と同じ値を返し、無効値状態であれば処理系定義の値を返す。

備考

メンバ関数がnoexceptである保証はない。

#include <cassert>
#include <functional>
#include <memory>

int main()
{
  std::indirect<int> a{42};
  // 所有する値のハッシュ値と一致する
  assert((std::hash<std::indirect<int>>{}(a) == std::hash<int>{}(42)));
}

出力

バージョン

言語

  • C++26

処理系

関連項目

参照