• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 // <functional>
11 
12 // template <class T>
13 // struct hash
14 //     : public unary_function<T, size_t>
15 // {
16 //     size_t operator()(T val) const;
17 // };
18 
19 // Not very portable
20 
21 #include <functional>
22 #include <cassert>
23 #include <type_traits>
24 #include <limits>
25 
26 template <class T>
27 void
test()28 test()
29 {
30     typedef std::hash<T> H;
31     static_assert((std::is_same<typename H::argument_type, T>::value), "" );
32     static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" );
33     H h;
34 
35     typedef typename std::remove_pointer<T>::type type;
36     type i;
37     type j;
38     assert(h(&i) != h(&j));
39 }
40 
main()41 int main()
42 {
43     test<int*>();
44 }
45