File indexing completed on 2025-01-30 09:46:48
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef BOOST_MOVE_MOVE_HELPERS_HPP
0013 #define BOOST_MOVE_MOVE_HELPERS_HPP
0014
0015 #ifndef BOOST_CONFIG_HPP
0016 # include <boost/config.hpp>
0017 #endif
0018 #
0019 #if defined(BOOST_HAS_PRAGMA_ONCE)
0020 # pragma once
0021 #endif
0022
0023 #include <boost/move/core.hpp>
0024 #include <boost/move/utility_core.hpp>
0025 #include <boost/move/detail/type_traits.hpp>
0026
0027 #if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
0028
0029 #define BOOST_MOVE_CATCH_CONST(U) \
0030 typename ::boost::move_detail::if_< ::boost::move_detail::is_class<U>, BOOST_CATCH_CONST_RLVALUE(U), const U &>::type
0031 #define BOOST_MOVE_CATCH_RVALUE(U)\
0032 typename ::boost::move_detail::if_< ::boost::move_detail::is_class<U>, BOOST_RV_REF(U), ::boost::move_detail::nat>::type
0033 #define BOOST_MOVE_CATCH_FWD(U) BOOST_FWD_REF(U)
0034 #else
0035 #define BOOST_MOVE_CATCH_CONST(U) const U &
0036 #define BOOST_MOVE_CATCH_RVALUE(U) U &&
0037 #define BOOST_MOVE_CATCH_FWD(U) U &&
0038 #endif
0039
0040
0041
0042
0043
0044
0045
0046 #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
0047
0048 template<class RETURN_VALUE, class BOOST_MOVE_TEMPL_PARAM, class TYPE>
0049 struct boost_move_conversion_aware_catch_1
0050 : public ::boost::move_detail::enable_if_and
0051 < RETURN_VALUE
0052 , ::boost::move_detail::is_same<TYPE, BOOST_MOVE_TEMPL_PARAM>
0053 , ::boost::move_detail::is_class<TYPE>
0054 , ::boost::has_move_emulation_disabled<BOOST_MOVE_TEMPL_PARAM>
0055 >
0056 {};
0057
0058 template<class RETURN_VALUE, class BOOST_MOVE_TEMPL_PARAM, class TYPE>
0059 struct boost_move_conversion_aware_catch_2
0060 : public ::boost::move_detail::disable_if_or
0061 < RETURN_VALUE
0062 , ::boost::move_detail::is_same<TYPE, BOOST_MOVE_TEMPL_PARAM>
0063 , ::boost::move_detail::is_rv_impl<BOOST_MOVE_TEMPL_PARAM>
0064 , ::boost::move_detail::and_
0065 < ::boost::move_detail::is_rv_impl<BOOST_MOVE_TEMPL_PARAM>
0066 , ::boost::move_detail::is_class<BOOST_MOVE_TEMPL_PARAM>
0067 >
0068 >
0069 {};
0070
0071 #define BOOST_MOVE_CONVERSION_AWARE_CATCH_COMMON(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION)\
0072 BOOST_MOVE_FORCEINLINE RETURN_VALUE PUB_FUNCTION(BOOST_MOVE_CATCH_CONST(TYPE) x)\
0073 { return FWD_FUNCTION(static_cast<const TYPE&>(x)); }\
0074 \
0075 BOOST_MOVE_FORCEINLINE RETURN_VALUE PUB_FUNCTION(BOOST_MOVE_CATCH_RVALUE(TYPE) x) \
0076 { return FWD_FUNCTION(::boost::move(x)); }\
0077 \
0078 BOOST_MOVE_FORCEINLINE RETURN_VALUE PUB_FUNCTION(TYPE &x)\
0079 { return FWD_FUNCTION(const_cast<const TYPE &>(x)); }\
0080
0081 #if defined(BOOST_MOVE_HELPERS_RETURN_SFINAE_BROKEN)
0082 #define BOOST_MOVE_CONVERSION_AWARE_CATCH(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION)\
0083 BOOST_MOVE_CONVERSION_AWARE_CATCH_COMMON(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION)\
0084 \
0085 template<class BOOST_MOVE_TEMPL_PARAM>\
0086 BOOST_MOVE_FORCEINLINE RETURN_VALUE PUB_FUNCTION(const BOOST_MOVE_TEMPL_PARAM &u,\
0087 typename boost_move_conversion_aware_catch_1< ::boost::move_detail::nat, BOOST_MOVE_TEMPL_PARAM, TYPE>::type* = 0)\
0088 { return FWD_FUNCTION(u); }\
0089 \
0090 template<class BOOST_MOVE_TEMPL_PARAM>\
0091 BOOST_MOVE_FORCEINLINE RETURN_VALUE PUB_FUNCTION(const BOOST_MOVE_TEMPL_PARAM &u,\
0092 typename boost_move_conversion_aware_catch_2< ::boost::move_detail::nat, BOOST_MOVE_TEMPL_PARAM, TYPE>::type* = 0)\
0093 {\
0094 TYPE t((u));\
0095 return FWD_FUNCTION(::boost::move(t));\
0096 }\
0097
0098 #else
0099 #define BOOST_MOVE_CONVERSION_AWARE_CATCH(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION)\
0100 BOOST_MOVE_CONVERSION_AWARE_CATCH_COMMON(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION)\
0101 \
0102 template<class BOOST_MOVE_TEMPL_PARAM>\
0103 BOOST_MOVE_FORCEINLINE typename boost_move_conversion_aware_catch_1<RETURN_VALUE, BOOST_MOVE_TEMPL_PARAM, TYPE>::type\
0104 PUB_FUNCTION(const BOOST_MOVE_TEMPL_PARAM &u)\
0105 { return FWD_FUNCTION(u); }\
0106 \
0107 template<class BOOST_MOVE_TEMPL_PARAM>\
0108 BOOST_MOVE_FORCEINLINE typename boost_move_conversion_aware_catch_2<RETURN_VALUE, BOOST_MOVE_TEMPL_PARAM, TYPE>::type\
0109 PUB_FUNCTION(const BOOST_MOVE_TEMPL_PARAM &u)\
0110 {\
0111 TYPE t((u));\
0112 return FWD_FUNCTION(::boost::move(t));\
0113 }\
0114
0115 #endif
0116 #elif (defined(_MSC_VER) && (_MSC_VER == 1600))
0117
0118 #define BOOST_MOVE_CONVERSION_AWARE_CATCH(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION)\
0119 BOOST_MOVE_FORCEINLINE RETURN_VALUE PUB_FUNCTION(BOOST_MOVE_CATCH_CONST(TYPE) x)\
0120 { return FWD_FUNCTION(static_cast<const TYPE&>(x)); }\
0121 \
0122 BOOST_MOVE_FORCEINLINE RETURN_VALUE PUB_FUNCTION(BOOST_MOVE_CATCH_RVALUE(TYPE) x) \
0123 { return FWD_FUNCTION(::boost::move(x)); }\
0124 \
0125 template<class BOOST_MOVE_TEMPL_PARAM>\
0126 BOOST_MOVE_FORCEINLINE typename ::boost::move_detail::enable_if_c\
0127 < !::boost::move_detail::is_same<TYPE, BOOST_MOVE_TEMPL_PARAM>::value\
0128 , RETURN_VALUE >::type\
0129 PUB_FUNCTION(const BOOST_MOVE_TEMPL_PARAM &u)\
0130 {\
0131 TYPE t((u));\
0132 return FWD_FUNCTION(::boost::move(t));\
0133 }\
0134
0135
0136 #else
0137
0138 #define BOOST_MOVE_CONVERSION_AWARE_CATCH(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION)\
0139 BOOST_MOVE_FORCEINLINE RETURN_VALUE PUB_FUNCTION(BOOST_MOVE_CATCH_CONST(TYPE) x)\
0140 { return FWD_FUNCTION(x); }\
0141 \
0142 BOOST_MOVE_FORCEINLINE RETURN_VALUE PUB_FUNCTION(BOOST_MOVE_CATCH_RVALUE(TYPE) x) \
0143 { return FWD_FUNCTION(::boost::move(x)); }\
0144
0145
0146 #endif
0147
0148
0149
0150
0151
0152
0153
0154 #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
0155
0156 template<class RETURN_VALUE, class BOOST_MOVE_TEMPL_PARAM, class UNLESS_CONVERTIBLE_TO, class TYPE>
0157 struct boost_move_conversion_aware_catch_1arg_1
0158 : public ::boost::move_detail::enable_if_and
0159 < RETURN_VALUE
0160 , ::boost::move_detail::not_< ::boost::move_detail::is_same_or_convertible<BOOST_MOVE_TEMPL_PARAM, UNLESS_CONVERTIBLE_TO> >
0161 , ::boost::move_detail::is_same<TYPE, BOOST_MOVE_TEMPL_PARAM>
0162 , ::boost::has_move_emulation_disabled<BOOST_MOVE_TEMPL_PARAM>
0163 >
0164 {};
0165
0166 template<class RETURN_VALUE, class BOOST_MOVE_TEMPL_PARAM, class UNLESS_CONVERTIBLE_TO, class TYPE>
0167 struct boost_move_conversion_aware_catch_1arg_2
0168 : public ::boost::move_detail::disable_if_or
0169 < RETURN_VALUE
0170 , ::boost::move_detail::is_same_or_convertible< BOOST_MOVE_TEMPL_PARAM, UNLESS_CONVERTIBLE_TO>
0171 , ::boost::move_detail::is_rv_impl<BOOST_MOVE_TEMPL_PARAM>
0172 , ::boost::move_detail::is_same<TYPE, BOOST_MOVE_TEMPL_PARAM>
0173 >
0174 {};
0175
0176 #define BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG_COMMON(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION, ARG1, UNLESS_CONVERTIBLE_TO)\
0177 BOOST_MOVE_FORCEINLINE RETURN_VALUE PUB_FUNCTION(ARG1 arg1, BOOST_MOVE_CATCH_CONST(TYPE) x)\
0178 { return FWD_FUNCTION(arg1, static_cast<const TYPE&>(x)); }\
0179 \
0180 BOOST_MOVE_FORCEINLINE RETURN_VALUE PUB_FUNCTION(ARG1 arg1, BOOST_MOVE_CATCH_RVALUE(TYPE) x) \
0181 { return FWD_FUNCTION(arg1, ::boost::move(x)); }\
0182 \
0183 BOOST_MOVE_FORCEINLINE RETURN_VALUE PUB_FUNCTION(ARG1 arg1, TYPE &x)\
0184 { return FWD_FUNCTION(arg1, const_cast<const TYPE &>(x)); }\
0185
0186 #if defined(BOOST_MOVE_HELPERS_RETURN_SFINAE_BROKEN)
0187 #define BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION, ARG1, UNLESS_CONVERTIBLE_TO)\
0188 BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG_COMMON(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION, ARG1, UNLESS_CONVERTIBLE_TO)\
0189 \
0190 template<class BOOST_MOVE_TEMPL_PARAM>\
0191 BOOST_MOVE_FORCEINLINE RETURN_VALUE PUB_FUNCTION(ARG1 arg1, const BOOST_MOVE_TEMPL_PARAM &u,\
0192 typename boost_move_conversion_aware_catch_1arg_1<void, BOOST_MOVE_TEMPL_PARAM, UNLESS_CONVERTIBLE_TO, TYPE>::type* = 0)\
0193 { return FWD_FUNCTION(arg1, u); }\
0194 \
0195 template<class BOOST_MOVE_TEMPL_PARAM>\
0196 BOOST_MOVE_FORCEINLINE RETURN_VALUE PUB_FUNCTION(ARG1 arg1, const BOOST_MOVE_TEMPL_PARAM &u,\
0197 typename boost_move_conversion_aware_catch_1arg_2<void, BOOST_MOVE_TEMPL_PARAM, UNLESS_CONVERTIBLE_TO, TYPE>::type* = 0)\
0198 {\
0199 TYPE t((u));\
0200 return FWD_FUNCTION(arg1, ::boost::move(t));\
0201 }\
0202
0203 #else
0204 #define BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION, ARG1, UNLESS_CONVERTIBLE_TO)\
0205 BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG_COMMON(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION, ARG1, UNLESS_CONVERTIBLE_TO)\
0206 \
0207 template<class BOOST_MOVE_TEMPL_PARAM>\
0208 BOOST_MOVE_FORCEINLINE typename boost_move_conversion_aware_catch_1arg_1<RETURN_VALUE, BOOST_MOVE_TEMPL_PARAM, UNLESS_CONVERTIBLE_TO, TYPE>::type\
0209 PUB_FUNCTION(ARG1 arg1, const BOOST_MOVE_TEMPL_PARAM &u)\
0210 { return FWD_FUNCTION(arg1, u); }\
0211 \
0212 template<class BOOST_MOVE_TEMPL_PARAM>\
0213 BOOST_MOVE_FORCEINLINE typename boost_move_conversion_aware_catch_1arg_2<RETURN_VALUE, BOOST_MOVE_TEMPL_PARAM, UNLESS_CONVERTIBLE_TO, TYPE>::type\
0214 PUB_FUNCTION(ARG1 arg1, const BOOST_MOVE_TEMPL_PARAM &u)\
0215 {\
0216 TYPE t((u));\
0217 return FWD_FUNCTION(arg1, ::boost::move(t));\
0218 }\
0219
0220 #endif
0221
0222 #elif (defined(_MSC_VER) && (_MSC_VER == 1600))
0223
0224 #define BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION, ARG1, UNLESS_CONVERTIBLE_TO)\
0225 BOOST_MOVE_FORCEINLINE RETURN_VALUE PUB_FUNCTION(ARG1 arg1, BOOST_MOVE_CATCH_CONST(TYPE) x)\
0226 { return FWD_FUNCTION(arg1, static_cast<const TYPE&>(x)); }\
0227 \
0228 BOOST_MOVE_FORCEINLINE RETURN_VALUE PUB_FUNCTION(ARG1 arg1, BOOST_MOVE_CATCH_RVALUE(TYPE) x) \
0229 { return FWD_FUNCTION(arg1, ::boost::move(x)); }\
0230 \
0231 template<class BOOST_MOVE_TEMPL_PARAM>\
0232 BOOST_MOVE_FORCEINLINE typename ::boost::move_detail::disable_if_or\
0233 < RETURN_VALUE \
0234 , ::boost::move_detail::is_same<TYPE, BOOST_MOVE_TEMPL_PARAM> \
0235 , ::boost::move_detail::is_same_or_convertible<BOOST_MOVE_TEMPL_PARAM, UNLESS_CONVERTIBLE_TO> \
0236 >::type\
0237 PUB_FUNCTION(ARG1 arg1, const BOOST_MOVE_TEMPL_PARAM &u)\
0238 {\
0239 TYPE t((u));\
0240 return FWD_FUNCTION(arg1, ::boost::move(t));\
0241 }\
0242
0243
0244 #else
0245
0246 #define BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION, ARG1, UNLESS_CONVERTIBLE_TO)\
0247 BOOST_MOVE_FORCEINLINE RETURN_VALUE PUB_FUNCTION(ARG1 arg1, BOOST_MOVE_CATCH_CONST(TYPE) x)\
0248 { return FWD_FUNCTION(arg1, static_cast<const TYPE&>(x)); }\
0249 \
0250 BOOST_MOVE_FORCEINLINE RETURN_VALUE PUB_FUNCTION(ARG1 arg1, BOOST_MOVE_CATCH_RVALUE(TYPE) x) \
0251 { return FWD_FUNCTION(arg1, ::boost::move(x)); }\
0252
0253
0254 #endif
0255
0256 #endif