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