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 | // <memory> |
10 | |
11 | // template <class T> |
12 | // struct hash<shared_ptr<T>> |
13 | // { |
14 | // typedef shared_ptr<T> argument_type; |
15 | // typedef size_t result_type; |
16 | // size_t operator()(const shared_ptr<T>& p) const; |
17 | // }; |
18 | |
19 | #include <memory> |
20 | |
21 | #include <cassert> |
22 | #include <functional> |
23 | |
24 | #include "test_macros.h" |
25 | |
26 | #if TEST_STD_VER >= 11 |
27 | #include "poisoned_hash_helper.h" |
28 | |
29 | struct A {}; |
30 | #endif |
31 | |
32 | int main(int, char**) |
33 | { |
34 | { |
35 | int* ptr = new int; |
36 | std::shared_ptr<int> p(ptr); |
37 | std::hash<std::shared_ptr<int> > f; |
38 | std::size_t h = f(p); |
39 | assert(h == std::hash<int*>()(ptr)); |
40 | } |
41 | #if TEST_STD_VER >= 11 |
42 | { |
43 | test_hash_enabled_for_type<std::shared_ptr<int>>(); |
44 | test_hash_enabled_for_type<std::shared_ptr<A>>(); |
45 | } |
46 | #endif |
47 | |
48 | return 0; |
49 | } |
50 | |