• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // UNSUPPORTED: libcpp-has-no-threads
11 
12 // <thread>
13 
14 // template <class T>
15 // struct hash
16 //     : public unary_function<T, size_t>
17 // {
18 //     size_t operator()(T val) const;
19 // };
20 
21 // Not very portable
22 
23 #include <thread>
24 #include <cassert>
25 
26 #include "test_macros.h"
27 
main()28 int main()
29 {
30     std::thread::id id1;
31     std::thread::id id2 = std::this_thread::get_id();
32     typedef std::hash<std::thread::id> H;
33     static_assert((std::is_same<typename H::argument_type, std::thread::id>::value), "" );
34     static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" );
35     ASSERT_NOEXCEPT(H()(id2));
36     H h;
37     assert(h(id1) != h(id2));
38 }
39