blob: e64017cd6e286f3c5e944aafc522ecfeae94db1c [file] [log] [blame]
Jeff Thompsona28eed82013-08-22 16:21:10 -07001
2// Copyright 2006-2009 Daniel James.
3// Distributed under the Boost Software License, Version 1.0. (See accompanying
4// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6#include "./config.hpp"
7
8#if defined(BOOST_HASH_TEST_EXTENSIONS) && !defined(BOOST_HASH_TEST_STD_INCLUDES)
9#include <boost/functional/hash_fwd.hpp>
10
11#include <boost/config.hpp>
12#include <cstddef>
13#include <vector>
14
15namespace test {
16
17 template <class T>
18 struct test_type1
19 {
20 T value;
21 test_type1(T const& x) : value(x) {}
22 };
23
24#if !defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
25 template <class T>
26 std::size_t hash_value(test_type1<T> const& x)
27 {
28 BOOST_HASH_TEST_NAMESPACE::hash<T> hasher;
29 return hasher(x.value);
30 }
31#endif
32
33 template <class T>
34 struct test_type2
35 {
36 T value1, value2;
37 test_type2(T const& x, T const& y) : value1(x), value2(y) {}
38 };
39
40#if !defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
41 template <class T>
42 std::size_t hash_value(test_type2<T> const& x)
43 {
44 std::size_t seed = 0;
45 BOOST_HASH_TEST_NAMESPACE::hash_combine(seed, x.value1);
46 BOOST_HASH_TEST_NAMESPACE::hash_combine(seed, x.value2);
47 return seed;
48 }
49#endif
50
51 template <class T>
52 struct test_type3
53 {
54 std::vector<T> values;
55 test_type3(typename std::vector<T>::iterator x,
56 typename std::vector<T>::iterator y) : values(x, y) {}
57 };
58
59#if !defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
60 template <class T>
61 std::size_t hash_value(test_type3<T> const& x)
62 {
63 std::size_t seed =
64 BOOST_HASH_TEST_NAMESPACE::hash_range(x.values.begin(), x.values.end());
65 BOOST_HASH_TEST_NAMESPACE::hash_range(seed, x.values.begin(), x.values.end());
66 return seed;
67 }
68#endif
69
70}
71
72#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
73
74namespace ndnboost
75{
76 template <class T>
77 std::size_t hash_value(test::test_type1<T> const& x)
78 {
79 BOOST_HASH_TEST_NAMESPACE::hash<T> hasher;
80 return hasher(x.value);
81 }
82
83 template <class T>
84 std::size_t hash_value(test::test_type2<T> const& x)
85 {
86 std::size_t seed = 0;
87 BOOST_HASH_TEST_NAMESPACE::hash_combine(seed, x.value1);
88 BOOST_HASH_TEST_NAMESPACE::hash_combine(seed, x.value2);
89 return seed;
90 }
91
92 template <class T>
93 std::size_t hash_value(test::test_type3<T> const& x)
94 {
95 std::size_t seed =
96 BOOST_HASH_TEST_NAMESPACE::hash_range(x.values.begin(), x.values.end());
97 BOOST_HASH_TEST_NAMESPACE::hash_range(seed, x.values.begin(), x.values.end());
98 return seed;
99 }
100}
101
102#endif
103
104#endif