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: c++03 |
10 | |
11 | // <functional> |
12 | |
13 | // Hashing a struct w/o a defined hash should *not* fail, but it should |
14 | // create a type that is not constructible and not callable. |
15 | // See also: https://cplusplus.github.io/LWG/lwg-defects.html#2543 |
16 | |
17 | #include <functional> |
18 | #include <cassert> |
19 | #include <type_traits> |
20 | |
21 | #include "test_macros.h" |
22 | |
23 | struct X {}; |
24 | |
25 | int main(int, char**) |
26 | { |
27 | using H = std::hash<X>; |
28 | static_assert(!std::is_default_constructible<H>::value, "" ); |
29 | static_assert(!std::is_copy_constructible<H>::value, "" ); |
30 | static_assert(!std::is_move_constructible<H>::value, "" ); |
31 | static_assert(!std::is_copy_assignable<H>::value, "" ); |
32 | static_assert(!std::is_move_assignable<H>::value, "" ); |
33 | #if TEST_STD_VER > 14 |
34 | static_assert(!std::is_invocable<H, X&>::value, "" ); |
35 | static_assert(!std::is_invocable<H, X const&>::value, "" ); |
36 | #endif |
37 | |
38 | return 0; |
39 | } |
40 | |