]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/unordered/test/helpers/helpers.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / unordered / test / helpers / helpers.hpp
1
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 #if !defined(BOOST_UNORDERED_TEST_HELPERS_HEADER)
7 #define BOOST_UNORDERED_TEST_HELPERS_HEADER
8
9 namespace test
10 {
11 template <class Container>
12 struct get_key_impl
13 {
14 typedef BOOST_DEDUCED_TYPENAME Container::key_type key_type;
15
16 static key_type const& get_key(key_type const& x)
17 {
18 return x;
19 }
20
21 template <class T>
22 static key_type const& get_key(
23 std::pair<key_type, T> const& x, char = 0)
24 {
25 return x.first;
26 }
27
28 template <class T>
29 static key_type const& get_key(std::pair<key_type const, T> const& x,
30 unsigned char = 0)
31 {
32 return x.first;
33 }
34 };
35
36 template <class Container, class T>
37 inline BOOST_DEDUCED_TYPENAME Container::key_type const& get_key(T const& x)
38 {
39 return get_key_impl<Container>::get_key(x);
40 }
41
42 // test::next
43 //
44 // Increments an iterator by 1 or a given value.
45 // Like boost::next, but simpler and slower.
46
47 template <typename Iterator>
48 Iterator next(Iterator it)
49 {
50 return ++it;
51 }
52
53 template <typename Iterator, typename IntType>
54 Iterator next(Iterator it, IntType x)
55 {
56 for(; x > 0; --x) {
57 ++it;
58 }
59 return it;
60 }
61 }
62
63 #endif