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 // UNSUPPORTED: libcpp-has-no-threads
10 
11 // <thread>
12 
13 // template <class T>
14 // struct hash
15 //     : public unary_function<T, size_t>
16 // {
17 //     size_t operator()(T val) const;
18 // };
19 
20 // Not very portable
21 
22 #include <thread>
23 #include <cassert>
24 
25 #include "test_macros.h"
26 
main(int,char **)27 int main(int, char**)
28 {
29     std::thread::id id1;
30     std::thread::id id2 = std::this_thread::get_id();
31     typedef std::hash<std::thread::id> H;
32     static_assert((std::is_same<typename H::argument_type, std::thread::id>::value), "" );
33     static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" );
34     ASSERT_NOEXCEPT(H()(id2));
35     H h;
36     assert(h(id1) != h(id2));
37 
38   return 0;
39 }
40