]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/intrusive/detail/tree_value_compare.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / intrusive / detail / tree_value_compare.hpp
CommitLineData
7c673cae
FG
1//////////////////////////////////////////////////////////////////////////////
2//
3// (C) Copyright Ion Gaztanaga 2015-2015. Distributed under the Boost
4// Software License, Version 1.0. (See accompanying file
5// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6//
7// See http://www.boost.org/libs/container for documentation.
8//
9//////////////////////////////////////////////////////////////////////////////
10#ifndef BOOST_INTRUSIVE_DETAIL_TREE_VALUE_COMPARE_HPP
11#define BOOST_INTRUSIVE_DETAIL_TREE_VALUE_COMPARE_HPP
12
13#ifndef BOOST_CONFIG_HPP
14# include <boost/config.hpp>
15#endif
16
17#if defined(BOOST_HAS_PRAGMA_ONCE)
18# pragma once
19#endif
20
21#include <boost/intrusive/detail/workaround.hpp>
22#include <boost/intrusive/detail/mpl.hpp>
23#include <boost/intrusive/detail/ebo_functor_holder.hpp>
24#include <boost/intrusive/pointer_traits.hpp>
25
26namespace boost{
27namespace intrusive{
28
29//Needed to support smart references to value types
30template <class From, class ValuePtr>
31struct disable_if_smartref_to
32 : detail::disable_if_c
33 < detail::is_same
34 <From, typename pointer_traits
35 <ValuePtr>
36 ::reference>::value
37 || detail::is_same
38 <From, typename pointer_traits
39 < typename pointer_rebind
b32b8144
FG
40 < ValuePtr
41 , const typename boost::movelib::pointer_element<ValuePtr>::type>::type>
7c673cae
FG
42 ::reference>::value
43 >
44{};
45
46//This function object takes a KeyCompare function object
47//and compares values that contains keys using KeyOfValue
92f5a8d4 48template< class ValuePtr, class KeyCompare, class KeyOfValue, class Ret = bool
b32b8144
FG
49 , bool = boost::intrusive::detail::is_same
50 <typename boost::movelib::pointer_element<ValuePtr>::type, typename KeyOfValue::type>::value >
7c673cae
FG
51struct tree_value_compare
52 : public boost::intrusive::detail::ebo_functor_holder<KeyCompare>
53{
b32b8144
FG
54 typedef typename
55 boost::movelib::pointer_element<ValuePtr>::type value_type;
7c673cae
FG
56 typedef KeyCompare key_compare;
57 typedef KeyOfValue key_of_value;
58 typedef typename KeyOfValue::type key_type;
59
60 typedef boost::intrusive::detail::ebo_functor_holder<KeyCompare> base_t;
61
62 BOOST_INTRUSIVE_FORCEINLINE tree_value_compare()
63 : base_t()
64 {}
65
66 BOOST_INTRUSIVE_FORCEINLINE explicit tree_value_compare(const key_compare &kcomp)
67 : base_t(kcomp)
68 {}
69
70 BOOST_INTRUSIVE_FORCEINLINE tree_value_compare (const tree_value_compare &x)
71 : base_t(x.base_t::get())
72 {}
73
74 BOOST_INTRUSIVE_FORCEINLINE tree_value_compare &operator=(const tree_value_compare &x)
75 { this->base_t::get() = x.base_t::get(); return *this; }
76
77 BOOST_INTRUSIVE_FORCEINLINE tree_value_compare &operator=(const key_compare &x)
78 { this->base_t::get() = x; return *this; }
79
80 BOOST_INTRUSIVE_FORCEINLINE const key_compare &key_comp() const
81 { return static_cast<const key_compare &>(*this); }
82
92f5a8d4
TL
83 BOOST_INTRUSIVE_FORCEINLINE Ret operator()(const key_type &key) const
84 { return this->key_comp()(key); }
85
86 BOOST_INTRUSIVE_FORCEINLINE Ret operator()(const value_type &value) const
87 { return this->key_comp()(KeyOfValue()(value)); }
88
89 template<class U>
90 BOOST_INTRUSIVE_FORCEINLINE Ret operator()( const U &nonkey
91 , typename disable_if_smartref_to<U, ValuePtr>::type* = 0) const
92 { return this->key_comp()(nonkey); }
93
94 BOOST_INTRUSIVE_FORCEINLINE Ret operator()(const key_type &key1, const key_type &key2) const
7c673cae
FG
95 { return this->key_comp()(key1, key2); }
96
92f5a8d4 97 BOOST_INTRUSIVE_FORCEINLINE Ret operator()(const value_type &value1, const value_type &value2) const
7c673cae
FG
98 { return this->key_comp()(KeyOfValue()(value1), KeyOfValue()(value2)); }
99
92f5a8d4 100 BOOST_INTRUSIVE_FORCEINLINE Ret operator()(const key_type &key1, const value_type &value2) const
7c673cae
FG
101 { return this->key_comp()(key1, KeyOfValue()(value2)); }
102
92f5a8d4 103 BOOST_INTRUSIVE_FORCEINLINE Ret operator()(const value_type &value1, const key_type &key2) const
7c673cae
FG
104 { return this->key_comp()(KeyOfValue()(value1), key2); }
105
106 template<class U>
92f5a8d4 107 BOOST_INTRUSIVE_FORCEINLINE Ret operator()( const key_type &key1, const U &nonkey2
7c673cae
FG
108 , typename disable_if_smartref_to<U, ValuePtr>::type* = 0) const
109 { return this->key_comp()(key1, nonkey2); }
110
111 template<class U>
92f5a8d4 112 BOOST_INTRUSIVE_FORCEINLINE Ret operator()( const U &nonkey1, const key_type &key2
7c673cae
FG
113 , typename disable_if_smartref_to<U, ValuePtr>::type* = 0) const
114 { return this->key_comp()(nonkey1, key2); }
115
116 template<class U>
92f5a8d4 117 BOOST_INTRUSIVE_FORCEINLINE Ret operator()( const value_type &value1, const U &nonvalue2
7c673cae
FG
118 , typename disable_if_smartref_to<U, ValuePtr>::type* = 0) const
119 { return this->key_comp()(KeyOfValue()(value1), nonvalue2); }
120
121 template<class U>
92f5a8d4 122 BOOST_INTRUSIVE_FORCEINLINE Ret operator()( const U &nonvalue1, const value_type &value2
7c673cae
FG
123 , typename disable_if_smartref_to<U, ValuePtr>::type* = 0) const
124 { return this->key_comp()(nonvalue1, KeyOfValue()(value2)); }
125};
126
92f5a8d4
TL
127template<class ValuePtr, class KeyCompare, class KeyOfValue, class Ret>
128struct tree_value_compare<ValuePtr, KeyCompare, KeyOfValue, Ret, true>
7c673cae
FG
129 : public boost::intrusive::detail::ebo_functor_holder<KeyCompare>
130{
b32b8144
FG
131 typedef typename
132 boost::movelib::pointer_element<ValuePtr>::type value_type;
7c673cae
FG
133 typedef KeyCompare key_compare;
134 typedef KeyOfValue key_of_value;
135 typedef typename KeyOfValue::type key_type;
136
137 typedef boost::intrusive::detail::ebo_functor_holder<KeyCompare> base_t;
138
139
140 BOOST_INTRUSIVE_FORCEINLINE tree_value_compare()
141 : base_t()
142 {}
143
144 BOOST_INTRUSIVE_FORCEINLINE explicit tree_value_compare(const key_compare &kcomp)
145 : base_t(kcomp)
146 {}
147
148 BOOST_INTRUSIVE_FORCEINLINE tree_value_compare (const tree_value_compare &x)
149 : base_t(x.base_t::get())
150 {}
151
152 BOOST_INTRUSIVE_FORCEINLINE tree_value_compare &operator=(const tree_value_compare &x)
153 { this->base_t::get() = x.base_t::get(); return *this; }
154
155 BOOST_INTRUSIVE_FORCEINLINE tree_value_compare &operator=(const key_compare &x)
156 { this->base_t::get() = x; return *this; }
157
158 BOOST_INTRUSIVE_FORCEINLINE const key_compare &key_comp() const
159 { return static_cast<const key_compare &>(*this); }
160
92f5a8d4
TL
161 BOOST_INTRUSIVE_FORCEINLINE Ret operator()(const key_type &key) const
162 { return this->key_comp()(key); }
163
164 template<class U>
165 BOOST_INTRUSIVE_FORCEINLINE Ret operator()( const U &nonkey
166 , typename disable_if_smartref_to<U, ValuePtr>::type* = 0) const
167 { return this->key_comp()(nonkey); }
168
169 BOOST_INTRUSIVE_FORCEINLINE Ret operator()(const key_type &key1, const key_type &key2) const
7c673cae
FG
170 { return this->key_comp()(key1, key2); }
171
172 template<class U>
92f5a8d4 173 BOOST_INTRUSIVE_FORCEINLINE Ret operator()( const key_type &key1, const U &nonkey2
7c673cae
FG
174 , typename disable_if_smartref_to<U, ValuePtr>::type* = 0) const
175 { return this->key_comp()(key1, nonkey2); }
176
177 template<class U>
92f5a8d4 178 BOOST_INTRUSIVE_FORCEINLINE Ret operator()(const U &nonkey1, const key_type &key2
7c673cae
FG
179 , typename disable_if_smartref_to<U, ValuePtr>::type* = 0) const
180 { return this->key_comp()(nonkey1, key2); }
181};
182
183} //namespace intrusive{
184} //namespace boost{
185
186#endif //#ifdef BOOST_INTRUSIVE_DETAIL_TREE_VALUE_COMPARE_HPP