File indexing completed on 2025-01-18 09:38:37
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_INTRUSIVE_DETAIL_TREE_VALUE_COMPARE_HPP
0011 #define BOOST_INTRUSIVE_DETAIL_TREE_VALUE_COMPARE_HPP
0012
0013 #ifndef BOOST_CONFIG_HPP
0014 # include <boost/config.hpp>
0015 #endif
0016
0017 #if defined(BOOST_HAS_PRAGMA_ONCE)
0018 # pragma once
0019 #endif
0020
0021 #include <boost/intrusive/detail/workaround.hpp>
0022 #include <boost/intrusive/detail/mpl.hpp>
0023 #include <boost/intrusive/detail/ebo_functor_holder.hpp>
0024 #include <boost/intrusive/pointer_traits.hpp>
0025
0026 namespace boost{
0027 namespace intrusive{
0028
0029
0030 template <class From, class ValuePtr>
0031 struct disable_if_smartref_to
0032 : detail::disable_if_c
0033 < detail::is_same
0034 <From, typename pointer_traits
0035 <ValuePtr>
0036 ::reference>::value
0037 || detail::is_same
0038 <From, typename pointer_traits
0039 < typename pointer_rebind
0040 < ValuePtr
0041 , const typename boost::movelib::pointer_element<ValuePtr>::type>::type>
0042 ::reference>::value
0043 >
0044 {};
0045
0046
0047
0048 template< class ValuePtr, class KeyCompare, class KeyOfValue, class Ret = bool
0049 , bool = boost::intrusive::detail::is_same
0050 <typename boost::movelib::pointer_element<ValuePtr>::type, typename KeyOfValue::type>::value >
0051 struct tree_value_compare
0052 : public boost::intrusive::detail::ebo_functor_holder<KeyCompare>
0053 {
0054 typedef typename
0055 boost::movelib::pointer_element<ValuePtr>::type value_type;
0056 typedef KeyCompare key_compare;
0057 typedef KeyOfValue key_of_value;
0058 typedef typename KeyOfValue::type key_type;
0059
0060 typedef boost::intrusive::detail::ebo_functor_holder<KeyCompare> base_t;
0061
0062 BOOST_INTRUSIVE_FORCEINLINE tree_value_compare()
0063 : base_t()
0064 {}
0065
0066 BOOST_INTRUSIVE_FORCEINLINE explicit tree_value_compare(const key_compare &kcomp)
0067 : base_t(kcomp)
0068 {}
0069
0070 BOOST_INTRUSIVE_FORCEINLINE tree_value_compare (const tree_value_compare &x)
0071 : base_t(x.base_t::get())
0072 {}
0073
0074 BOOST_INTRUSIVE_FORCEINLINE tree_value_compare &operator=(const tree_value_compare &x)
0075 { this->base_t::get() = x.base_t::get(); return *this; }
0076
0077 BOOST_INTRUSIVE_FORCEINLINE tree_value_compare &operator=(const key_compare &x)
0078 { this->base_t::get() = x; return *this; }
0079
0080 BOOST_INTRUSIVE_FORCEINLINE const key_compare &key_comp() const
0081 { return static_cast<const key_compare &>(*this); }
0082
0083 BOOST_INTRUSIVE_FORCEINLINE Ret operator()(const key_type &key) const
0084 { return this->key_comp()(key); }
0085
0086 BOOST_INTRUSIVE_FORCEINLINE Ret operator()(const value_type &value) const
0087 { return this->key_comp()(KeyOfValue()(value)); }
0088
0089 template<class U>
0090 BOOST_INTRUSIVE_FORCEINLINE Ret operator()( const U &nonkey
0091 , typename disable_if_smartref_to<U, ValuePtr>::type* = 0) const
0092 { return this->key_comp()(nonkey); }
0093
0094 BOOST_INTRUSIVE_FORCEINLINE Ret operator()(const key_type &key1, const key_type &key2) const
0095 { return this->key_comp()(key1, key2); }
0096
0097 BOOST_INTRUSIVE_FORCEINLINE Ret operator()(const value_type &value1, const value_type &value2) const
0098 { return this->key_comp()(KeyOfValue()(value1), KeyOfValue()(value2)); }
0099
0100 BOOST_INTRUSIVE_FORCEINLINE Ret operator()(const key_type &key1, const value_type &value2) const
0101 { return this->key_comp()(key1, KeyOfValue()(value2)); }
0102
0103 BOOST_INTRUSIVE_FORCEINLINE Ret operator()(const value_type &value1, const key_type &key2) const
0104 { return this->key_comp()(KeyOfValue()(value1), key2); }
0105
0106 template<class U>
0107 BOOST_INTRUSIVE_FORCEINLINE Ret operator()( const key_type &key1, const U &nonkey2
0108 , typename disable_if_smartref_to<U, ValuePtr>::type* = 0) const
0109 { return this->key_comp()(key1, nonkey2); }
0110
0111 template<class U>
0112 BOOST_INTRUSIVE_FORCEINLINE Ret operator()( const U &nonkey1, const key_type &key2
0113 , typename disable_if_smartref_to<U, ValuePtr>::type* = 0) const
0114 { return this->key_comp()(nonkey1, key2); }
0115
0116 template<class U>
0117 BOOST_INTRUSIVE_FORCEINLINE Ret operator()( const value_type &value1, const U &nonvalue2
0118 , typename disable_if_smartref_to<U, ValuePtr>::type* = 0) const
0119 { return this->key_comp()(KeyOfValue()(value1), nonvalue2); }
0120
0121 template<class U>
0122 BOOST_INTRUSIVE_FORCEINLINE Ret operator()( const U &nonvalue1, const value_type &value2
0123 , typename disable_if_smartref_to<U, ValuePtr>::type* = 0) const
0124 { return this->key_comp()(nonvalue1, KeyOfValue()(value2)); }
0125 };
0126
0127 template<class ValuePtr, class KeyCompare, class KeyOfValue, class Ret>
0128 struct tree_value_compare<ValuePtr, KeyCompare, KeyOfValue, Ret, true>
0129 : public boost::intrusive::detail::ebo_functor_holder<KeyCompare>
0130 {
0131 typedef typename
0132 boost::movelib::pointer_element<ValuePtr>::type value_type;
0133 typedef KeyCompare key_compare;
0134 typedef KeyOfValue key_of_value;
0135 typedef typename KeyOfValue::type key_type;
0136
0137 typedef boost::intrusive::detail::ebo_functor_holder<KeyCompare> base_t;
0138
0139
0140 BOOST_INTRUSIVE_FORCEINLINE tree_value_compare()
0141 : base_t()
0142 {}
0143
0144 BOOST_INTRUSIVE_FORCEINLINE explicit tree_value_compare(const key_compare &kcomp)
0145 : base_t(kcomp)
0146 {}
0147
0148 BOOST_INTRUSIVE_FORCEINLINE tree_value_compare (const tree_value_compare &x)
0149 : base_t(x.base_t::get())
0150 {}
0151
0152 BOOST_INTRUSIVE_FORCEINLINE tree_value_compare &operator=(const tree_value_compare &x)
0153 { this->base_t::get() = x.base_t::get(); return *this; }
0154
0155 BOOST_INTRUSIVE_FORCEINLINE tree_value_compare &operator=(const key_compare &x)
0156 { this->base_t::get() = x; return *this; }
0157
0158 BOOST_INTRUSIVE_FORCEINLINE const key_compare &key_comp() const
0159 { return static_cast<const key_compare &>(*this); }
0160
0161 BOOST_INTRUSIVE_FORCEINLINE Ret operator()(const key_type &key) const
0162 { return this->key_comp()(key); }
0163
0164 template<class U>
0165 BOOST_INTRUSIVE_FORCEINLINE Ret operator()( const U &nonkey
0166 , typename disable_if_smartref_to<U, ValuePtr>::type* = 0) const
0167 { return this->key_comp()(nonkey); }
0168
0169 BOOST_INTRUSIVE_FORCEINLINE Ret operator()(const key_type &key1, const key_type &key2) const
0170 { return this->key_comp()(key1, key2); }
0171
0172 template<class U>
0173 BOOST_INTRUSIVE_FORCEINLINE Ret operator()( const key_type &key1, const U &nonkey2
0174 , typename disable_if_smartref_to<U, ValuePtr>::type* = 0) const
0175 { return this->key_comp()(key1, nonkey2); }
0176
0177 template<class U>
0178 BOOST_INTRUSIVE_FORCEINLINE Ret operator()(const U &nonkey1, const key_type &key2
0179 , typename disable_if_smartref_to<U, ValuePtr>::type* = 0) const
0180 { return this->key_comp()(nonkey1, key2); }
0181 };
0182
0183 }
0184 }
0185
0186 #endif