File indexing completed on 2025-01-18 09:38:36
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef BOOST_INTRUSIVE_DETAIL_EBO_HOLDER_HPP
0015 #define BOOST_INTRUSIVE_DETAIL_EBO_HOLDER_HPP
0016
0017 #ifndef BOOST_CONFIG_HPP
0018 # include <boost/config.hpp>
0019 #endif
0020
0021 #if defined(BOOST_HAS_PRAGMA_ONCE)
0022 # pragma once
0023 #endif
0024
0025 #include <boost/intrusive/detail/workaround.hpp>
0026 #include <boost/move/utility_core.hpp>
0027
0028 namespace boost {
0029 namespace intrusive {
0030 namespace detail {
0031
0032 #if defined(BOOST_MSVC) || defined(__BORLANDC_)
0033 #define BOOST_INTRUSIVE_TT_DECL __cdecl
0034 #else
0035 #define BOOST_INTRUSIVE_TT_DECL
0036 #endif
0037
0038 #if defined(_MSC_EXTENSIONS) && !defined(__BORLAND__) && !defined(_WIN64) && !defined(_M_ARM) && !defined(_M_ARM64) && !defined(UNDER_CE)
0039 #define BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS
0040 #endif
0041
0042 template <typename T>
0043 struct is_unary_or_binary_function_impl
0044 { static const bool value = false; };
0045
0046
0047
0048 #ifndef BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS
0049
0050 template <typename R>
0051 struct is_unary_or_binary_function_impl<R (*)()>
0052 { static const bool value = true; };
0053
0054 template <typename R>
0055 struct is_unary_or_binary_function_impl<R (*)(...)>
0056 { static const bool value = true; };
0057
0058 #else
0059
0060 template <typename R>
0061 struct is_unary_or_binary_function_impl<R (__stdcall*)()>
0062 { static const bool value = true; };
0063
0064 #ifndef _MANAGED
0065
0066 template <typename R>
0067 struct is_unary_or_binary_function_impl<R (__fastcall*)()>
0068 { static const bool value = true; };
0069
0070 #endif
0071
0072 template <typename R>
0073 struct is_unary_or_binary_function_impl<R (__cdecl*)()>
0074 { static const bool value = true; };
0075
0076 template <typename R>
0077 struct is_unary_or_binary_function_impl<R (__cdecl*)(...)>
0078 { static const bool value = true; };
0079
0080 #endif
0081
0082
0083
0084 #ifndef BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS
0085
0086 template <typename R, class T0>
0087 struct is_unary_or_binary_function_impl<R (*)(T0)>
0088 { static const bool value = true; };
0089
0090 template <typename R, class T0>
0091 struct is_unary_or_binary_function_impl<R (*)(T0...)>
0092 { static const bool value = true; };
0093
0094 #else
0095
0096 template <typename R, class T0>
0097 struct is_unary_or_binary_function_impl<R (__stdcall*)(T0)>
0098 { static const bool value = true; };
0099
0100 #ifndef _MANAGED
0101
0102 template <typename R, class T0>
0103 struct is_unary_or_binary_function_impl<R (__fastcall*)(T0)>
0104 { static const bool value = true; };
0105
0106 #endif
0107
0108 template <typename R, class T0>
0109 struct is_unary_or_binary_function_impl<R (__cdecl*)(T0)>
0110 { static const bool value = true; };
0111
0112 template <typename R, class T0>
0113 struct is_unary_or_binary_function_impl<R (__cdecl*)(T0...)>
0114 { static const bool value = true; };
0115
0116 #endif
0117
0118
0119
0120 #ifndef BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS
0121
0122 template <typename R, class T0, class T1>
0123 struct is_unary_or_binary_function_impl<R (*)(T0, T1)>
0124 { static const bool value = true; };
0125
0126 template <typename R, class T0, class T1>
0127 struct is_unary_or_binary_function_impl<R (*)(T0, T1...)>
0128 { static const bool value = true; };
0129
0130 #else
0131
0132 template <typename R, class T0, class T1>
0133 struct is_unary_or_binary_function_impl<R (__stdcall*)(T0, T1)>
0134 { static const bool value = true; };
0135
0136 #ifndef _MANAGED
0137
0138 template <typename R, class T0, class T1>
0139 struct is_unary_or_binary_function_impl<R (__fastcall*)(T0, T1)>
0140 { static const bool value = true; };
0141
0142 #endif
0143
0144 template <typename R, class T0, class T1>
0145 struct is_unary_or_binary_function_impl<R (__cdecl*)(T0, T1)>
0146 { static const bool value = true; };
0147
0148 template <typename R, class T0, class T1>
0149 struct is_unary_or_binary_function_impl<R (__cdecl*)(T0, T1...)>
0150 { static const bool value = true; };
0151 #endif
0152
0153 template <typename T>
0154 struct is_unary_or_binary_function_impl<T&>
0155 { static const bool value = false; };
0156
0157 template<typename T>
0158 struct is_unary_or_binary_function : is_unary_or_binary_function_impl<T>
0159 {};
0160
0161 template<typename T, typename Tag = void, bool = is_unary_or_binary_function<T>::value>
0162 class ebo_functor_holder
0163 {
0164 BOOST_COPYABLE_AND_MOVABLE(ebo_functor_holder)
0165
0166 public:
0167 typedef T functor_type;
0168
0169 BOOST_INTRUSIVE_FORCEINLINE ebo_functor_holder()
0170 : t_()
0171 {}
0172
0173 BOOST_INTRUSIVE_FORCEINLINE explicit ebo_functor_holder(const T &t)
0174 : t_(t)
0175 {}
0176
0177 BOOST_INTRUSIVE_FORCEINLINE explicit ebo_functor_holder(BOOST_RV_REF(T) t)
0178 : t_(::boost::move(t))
0179 {}
0180
0181 template<class Arg1, class Arg2>
0182 BOOST_INTRUSIVE_FORCEINLINE ebo_functor_holder(BOOST_FWD_REF(Arg1) arg1, BOOST_FWD_REF(Arg2) arg2)
0183 : t_(::boost::forward<Arg1>(arg1), ::boost::forward<Arg2>(arg2))
0184 {}
0185
0186 BOOST_INTRUSIVE_FORCEINLINE ebo_functor_holder(const ebo_functor_holder &x)
0187 : t_(x.t_)
0188 {}
0189
0190 BOOST_INTRUSIVE_FORCEINLINE ebo_functor_holder(BOOST_RV_REF(ebo_functor_holder) x)
0191 : t_(x.t_)
0192 {}
0193
0194 BOOST_INTRUSIVE_FORCEINLINE ebo_functor_holder& operator=(BOOST_COPY_ASSIGN_REF(ebo_functor_holder) x)
0195 {
0196 this->get() = x.get();
0197 return *this;
0198 }
0199
0200 BOOST_INTRUSIVE_FORCEINLINE ebo_functor_holder& operator=(BOOST_RV_REF(ebo_functor_holder) x)
0201 {
0202 this->get() = ::boost::move(x.get());
0203 return *this;
0204 }
0205
0206 BOOST_INTRUSIVE_FORCEINLINE ebo_functor_holder& operator=(const T &x)
0207 {
0208 this->get() = x;
0209 return *this;
0210 }
0211
0212 BOOST_INTRUSIVE_FORCEINLINE ebo_functor_holder& operator=(BOOST_RV_REF(T) x)
0213 {
0214 this->get() = ::boost::move(x);
0215 return *this;
0216 }
0217
0218 BOOST_INTRUSIVE_FORCEINLINE T& get(){return t_;}
0219 BOOST_INTRUSIVE_FORCEINLINE const T& get()const{return t_;}
0220
0221 private:
0222 T t_;
0223 };
0224
0225 template<typename T, typename Tag>
0226 class ebo_functor_holder<T, Tag, false>
0227 : public T
0228 {
0229 BOOST_COPYABLE_AND_MOVABLE(ebo_functor_holder)
0230
0231 public:
0232 typedef T functor_type;
0233
0234 BOOST_INTRUSIVE_FORCEINLINE ebo_functor_holder()
0235 : T()
0236 {}
0237
0238 BOOST_INTRUSIVE_FORCEINLINE explicit ebo_functor_holder(const T &t)
0239 : T(t)
0240 {}
0241
0242 BOOST_INTRUSIVE_FORCEINLINE explicit ebo_functor_holder(BOOST_RV_REF(T) t)
0243 : T(::boost::move(t))
0244 {}
0245
0246 template<class Arg1, class Arg2>
0247 BOOST_INTRUSIVE_FORCEINLINE ebo_functor_holder(BOOST_FWD_REF(Arg1) arg1, BOOST_FWD_REF(Arg2) arg2)
0248 : T(::boost::forward<Arg1>(arg1), ::boost::forward<Arg2>(arg2))
0249 {}
0250
0251 BOOST_INTRUSIVE_FORCEINLINE ebo_functor_holder(const ebo_functor_holder &x)
0252 : T(static_cast<const T&>(x))
0253 {}
0254
0255 BOOST_INTRUSIVE_FORCEINLINE ebo_functor_holder(BOOST_RV_REF(ebo_functor_holder) x)
0256 : T(BOOST_MOVE_BASE(T, x))
0257 {}
0258
0259 BOOST_INTRUSIVE_FORCEINLINE ebo_functor_holder& operator=(BOOST_COPY_ASSIGN_REF(ebo_functor_holder) x)
0260 {
0261 const ebo_functor_holder&r = x;
0262 this->get() = r;
0263 return *this;
0264 }
0265
0266 BOOST_INTRUSIVE_FORCEINLINE ebo_functor_holder& operator=(BOOST_RV_REF(ebo_functor_holder) x)
0267 {
0268 this->get() = ::boost::move(x.get());
0269 return *this;
0270 }
0271
0272 BOOST_INTRUSIVE_FORCEINLINE ebo_functor_holder& operator=(const T &x)
0273 {
0274 this->get() = x;
0275 return *this;
0276 }
0277
0278 BOOST_INTRUSIVE_FORCEINLINE ebo_functor_holder& operator=(BOOST_RV_REF(T) x)
0279 {
0280 this->get() = ::boost::move(x);
0281 return *this;
0282 }
0283
0284 BOOST_INTRUSIVE_FORCEINLINE T& get(){return *this;}
0285 BOOST_INTRUSIVE_FORCEINLINE const T& get()const{return *this;}
0286 };
0287
0288 }
0289 }
0290 }
0291
0292 #endif