1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9// <typeindex>
10
11// class type_index
12
13// template <>
14// struct hash<type_index>
15// {
16// size_t operator()(type_index index) const;
17// };
18
19// UNSUPPORTED: no-rtti
20
21#include <typeindex>
22#include <type_traits>
23#include <cassert>
24
25#include "test_macros.h"
26
27int main(int, char**)
28{
29#if TEST_STD_VER <= 14
30 typedef std::hash<std::type_index> H;
31 static_assert((std::is_same<typename H::argument_type, std::type_index>::value), "" );
32 static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" );
33#endif
34
35 std::type_index t1 = typeid(int);
36 assert(std::hash<std::type_index>()(t1) == t1.hash_code());
37
38 return 0;
39}
40

source code of libcxx/test/std/utilities/type.index/type.index.hash/hash.pass.cpp