hash_shared_ptr.pass.cpp revision c52f43e72dfcea03037729649da84c23b3beb04a
1//===----------------------------------------------------------------------===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. 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
23int main()
24{
25    int* ptr = new int;
26    std::shared_ptr<int> p(ptr);
27    std::hash<std::shared_ptr<int> > f;
28    std::size_t h = f(p);
29    assert(h == std::hash<int*>()(ptr));
30}
31