]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_shared_ptr.pass.cpp
Vendor import of libc++ trunk r300422:
[FreeBSD/FreeBSD.git] / test / std / utilities / memory / util.smartptr / util.smartptr.hash / hash_shared_ptr.pass.cpp
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 // <memory>
11
12 // template <class T>
13 // struct hash<shared_ptr<T>>
14 // {
15 //     typedef shared_ptr<T>    argument_type;
16 //     typedef size_t           result_type;
17 //     size_t operator()(const shared_ptr<T>& p) const;
18 // };
19
20 #include <memory>
21 #include <cassert>
22
23 #if TEST_STD_VER >= 11
24 #include "poisoned_hash_helper.hpp"
25
26 struct A {};
27 #endif
28
29 int main()
30 {
31   {
32     int* ptr = new int;
33     std::shared_ptr<int> p(ptr);
34     std::hash<std::shared_ptr<int> > f;
35     std::size_t h = f(p);
36     assert(h == std::hash<int*>()(ptr));
37   }
38 #if TEST_STD_VER >= 11
39   {
40     test_hash_enabled_for_type<std::shared_ptr<int>>();
41     test_hash_enabled_for_type<std::shared_ptr<A>>();
42   }
43 #endif
44 }