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