42 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8//9// UNSUPPORTED: no-threads10 11// <thread>12 13// template <class T>14// struct hash15// {16// size_t operator()(T val) const;17// };18 19// Not very portable20 21#include <cassert>22#include <functional>23#include <thread>24 25#include "test_macros.h"26 27int 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#if TEST_STD_VER <= 1433 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#endif36 ASSERT_NOEXCEPT(H()(id2));37 H h;38 assert(h(id1) != h(id2));39 40 return 0;41}42