File indexing completed on 2026-04-06 08:05:21
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef BOOST_MOVE_CORE_HPP
0017 #define BOOST_MOVE_CORE_HPP
0018
0019 #ifndef BOOST_CONFIG_HPP
0020 # include <boost/config.hpp>
0021 #endif
0022 0023 ">#
0024 #if defined(BOOST_HAS_PRAGMA_ONCE)
0025 # pragma once
0026 #endif
0027
0028 #include <boost/move/detail/config_begin.hpp>
0029 #include <boost/move/detail/workaround.hpp>
0030
0031
0032
0033
0034
0035 #if defined(BOOST_NO_CXX11_DELETED_FUNCTIONS) || defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
0036 #define BOOST_MOVE_IMPL_NO_COPY_CTOR_OR_ASSIGN(TYPE) \
0037 private:\
0038 TYPE(TYPE &);\
0039 TYPE& operator=(TYPE &);\
0040 public:\
0041 typedef int boost_move_no_copy_constructor_or_assign; \
0042 private:\
0043
0044 #else
0045 #define BOOST_MOVE_IMPL_NO_COPY_CTOR_OR_ASSIGN(TYPE) \
0046 public:\
0047 TYPE(TYPE const &) = delete;\
0048 TYPE& operator=(TYPE const &) = delete;\
0049 public:\
0050 typedef int boost_move_no_copy_constructor_or_assign; \
0051 private:\
0052
0053 #endif
0054
0055
0056
0057 #if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_MOVE_DOXYGEN_INVOKED)
0058
0059 #include <boost/move/detail/type_traits.hpp>
0060
0061 #define BOOST_MOVE_TO_RV_CAST(RV_TYPE, ARG) reinterpret_cast<RV_TYPE>(ARG)
0062 #define BOOST_MOVE_TO_LV_CAST(LV_TYPE, ARG) static_cast<LV_TYPE>(ARG)
0063
0064
0065 #if defined(BOOST_GCC) && (BOOST_GCC >= 40400) && (BOOST_GCC < 40500)
0066 #define BOOST_RV_ATTRIBUTE_MAY_ALIAS BOOST_MAY_ALIAS
0067 #else
0068 #define BOOST_RV_ATTRIBUTE_MAY_ALIAS
0069 #endif
0070
0071 namespace boost {
0072
0073
0074
0075
0076
0077
0078 template <class T>
0079 class BOOST_RV_ATTRIBUTE_MAY_ALIAS rv
0080 : public ::boost::move_detail::if_c
0081 < ::boost::move_detail::is_class<T>::value
0082 , T
0083 , ::boost::move_detail::nat
0084 >::type
0085 {
0086 rv();
0087 ~rv() throw();
0088 rv(rv const&);
0089 void operator=(rv const&);
0090 };
0091
0092
0093
0094
0095
0096
0097
0098
0099 namespace move_detail {
0100
0101 template <class T>
0102 struct is_rv
0103
0104
0105 : integral_constant<bool, ::boost::move_detail::is_rv_impl<T>::value >
0106 {};
0107
0108 template <class T>
0109 struct is_not_rv
0110 {
0111 static const bool value = !is_rv<T>::value;
0112 };
0113
0114 }
0115
0116
0117
0118
0119
0120
0121 template<class T>
0122 struct has_move_emulation_enabled
0123 : ::boost::move_detail::has_move_emulation_enabled_impl<T>
0124 {};
0125
0126 template<class T>
0127 struct has_move_emulation_disabled
0128 {
0129 static const bool value = !::boost::move_detail::has_move_emulation_enabled_impl<T>::value;
0130 };
0131
0132 }
0133
0134 #define BOOST_RV_REF(TYPE)\
0135 ::boost::rv< TYPE >& \
0136
0137
0138 #define BOOST_RV_REF_2_TEMPL_ARGS(TYPE, ARG1, ARG2)\
0139 ::boost::rv< TYPE<ARG1, ARG2> >& \
0140
0141
0142 #define BOOST_RV_REF_3_TEMPL_ARGS(TYPE, ARG1, ARG2, ARG3)\
0143 ::boost::rv< TYPE<ARG1, ARG2, ARG3> >& \
0144
0145
0146 #define BOOST_RV_REF_BEG\
0147 ::boost::rv< \
0148
0149
0150 #define BOOST_RV_REF_END\
0151 >& \
0152
0153
0154 #define BOOST_RV_REF_BEG_IF_CXX11 \
0155 \
0156
0157
0158 #define BOOST_RV_REF_END_IF_CXX11 \
0159 \
0160
0161
0162 #define BOOST_FWD_REF(TYPE)\
0163 const TYPE & \
0164
0165
0166 #define BOOST_COPY_ASSIGN_REF(TYPE)\
0167 const ::boost::rv< TYPE >& \
0168
0169
0170 #define BOOST_COPY_ASSIGN_REF_BEG \
0171 const ::boost::rv< \
0172
0173
0174 #define BOOST_COPY_ASSIGN_REF_END \
0175 >& \
0176
0177
0178 #define BOOST_COPY_ASSIGN_REF_2_TEMPL_ARGS(TYPE, ARG1, ARG2)\
0179 const ::boost::rv< TYPE<ARG1, ARG2> >& \
0180
0181
0182 #define BOOST_COPY_ASSIGN_REF_3_TEMPL_ARGS(TYPE, ARG1, ARG2, ARG3)\
0183 const ::boost::rv< TYPE<ARG1, ARG2, ARG3> >& \
0184
0185
0186 #define BOOST_CATCH_CONST_RLVALUE(TYPE)\
0187 const ::boost::rv< TYPE >& \
0188
0189
0190 namespace boost {
0191 namespace move_detail {
0192
0193 template <class Ret, class T>
0194 BOOST_MOVE_FORCEINLINE typename ::boost::move_detail::enable_if_c
0195 < ::boost::move_detail::is_lvalue_reference<Ret>::value ||
0196 !::boost::has_move_emulation_enabled<T>::value
0197 , T&>::type
0198 move_return(T& x) BOOST_NOEXCEPT
0199 {
0200 return x;
0201 }
0202
0203 template <class Ret, class T>
0204 BOOST_MOVE_FORCEINLINE typename ::boost::move_detail::enable_if_c
0205 < !::boost::move_detail::is_lvalue_reference<Ret>::value &&
0206 ::boost::has_move_emulation_enabled<T>::value
0207 , ::boost::rv<T>&>::type
0208 move_return(T& x) BOOST_NOEXCEPT
0209 {
0210 return *BOOST_MOVE_TO_RV_CAST(::boost::rv<T>*, ::boost::move_detail::addressof(x));
0211 }
0212
0213 template <class Ret, class T>
0214 BOOST_MOVE_FORCEINLINE typename ::boost::move_detail::enable_if_c
0215 < !::boost::move_detail::is_lvalue_reference<Ret>::value &&
0216 ::boost::has_move_emulation_enabled<T>::value
0217 , ::boost::rv<T>&>::type
0218 move_return(::boost::rv<T>& x) BOOST_NOEXCEPT
0219 {
0220 return x;
0221 }
0222
0223 template <class T>
0224 BOOST_MOVE_FORCEINLINE T& unrv(::boost::rv<T> &rv) BOOST_NOEXCEPT
0225 { return BOOST_MOVE_TO_LV_CAST(T&, rv); }
0226
0227 }
0228 }
0229
0230 #define BOOST_MOVE_RET(RET_TYPE, REF)\
0231 boost::move_detail::move_return< RET_TYPE >(REF)
0232
0233
0234 #define BOOST_MOVE_BASE(BASE_TYPE, ARG) \
0235 ::boost::move((BASE_TYPE&)(ARG))
0236
0237
0238 #define BOOST_MOVE_TO_LV(ARG) \
0239 ::boost::move_detail::unrv(ARG)
0240
0241
0242
0243
0244
0245
0246
0247
0248 #define BOOST_MOVABLE_BUT_NOT_COPYABLE(TYPE)\
0249 BOOST_MOVE_IMPL_NO_COPY_CTOR_OR_ASSIGN(TYPE)\
0250 public:\
0251 BOOST_MOVE_FORCEINLINE operator ::boost::rv<TYPE>&() \
0252 { return *BOOST_MOVE_TO_RV_CAST(::boost::rv<TYPE>*, this); }\
0253 BOOST_MOVE_FORCEINLINE operator const ::boost::rv<TYPE>&() const \
0254 { return *BOOST_MOVE_TO_RV_CAST(const ::boost::rv<TYPE>*, this); }\
0255 private:\
0256
0257
0258
0259
0260
0261
0262
0263
0264 #define BOOST_COPYABLE_AND_MOVABLE(TYPE)\
0265 public:\
0266 BOOST_MOVE_FORCEINLINE TYPE& operator=(TYPE &t)\
0267 { this->operator=(const_cast<const TYPE&>(t)); return *this;}\
0268 public:\
0269 BOOST_MOVE_FORCEINLINE operator ::boost::rv<TYPE>&() \
0270 { return *BOOST_MOVE_TO_RV_CAST(::boost::rv<TYPE>*, this); }\
0271 BOOST_MOVE_FORCEINLINE operator const ::boost::rv<TYPE>&() const \
0272 { return *BOOST_MOVE_TO_RV_CAST(const ::boost::rv<TYPE>*, this); }\
0273 private:\
0274
0275
0276 #define BOOST_COPYABLE_AND_MOVABLE_ALT(TYPE)\
0277 public:\
0278 BOOST_MOVE_FORCEINLINE operator ::boost::rv<TYPE>&() \
0279 { return *BOOST_MOVE_TO_RV_CAST(::boost::rv<TYPE>*, this); }\
0280 BOOST_MOVE_FORCEINLINE operator const ::boost::rv<TYPE>&() const \
0281 { return *BOOST_MOVE_TO_RV_CAST(const ::boost::rv<TYPE>*, this); }\
0282 private:\
0283
0284
0285 namespace boost{
0286 namespace move_detail{
0287
0288 template< class T>
0289 struct forward_type
0290 { typedef const T &type; };
0291
0292 template< class T>
0293 struct forward_type< boost::rv<T> >
0294 { typedef T type; };
0295
0296 }}
0297
0298 #else
0299
0300
0301
0302
0303 #define BOOST_MOVABLE_BUT_NOT_COPYABLE(TYPE)\
0304 BOOST_MOVE_IMPL_NO_COPY_CTOR_OR_ASSIGN(TYPE)\
0305 public:\
0306 typedef int boost_move_emulation_t;\
0307 private:\
0308
0309
0310
0311
0312
0313 #define BOOST_COPYABLE_AND_MOVABLE(TYPE)\
0314
0315
0316 #if !defined(BOOST_MOVE_DOXYGEN_INVOKED)
0317 #define BOOST_COPYABLE_AND_MOVABLE_ALT(TYPE)\
0318
0319 #endif
0320
0321 namespace boost {
0322
0323
0324
0325
0326 template<class T>
0327 struct has_move_emulation_enabled
0328 {
0329 static const bool value = false;
0330 };
0331
0332 template<class T>
0333 struct has_move_emulation_disabled
0334 {
0335 static const bool value = true;
0336 };
0337
0338 }
0339
0340
0341
0342
0343 #define BOOST_RV_REF(TYPE)\
0344 TYPE && \
0345
0346
0347
0348
0349
0350
0351
0352
0353 #define BOOST_RV_REF_BEG\
0354 \
0355
0356
0357
0358
0359
0360
0361
0362
0363 #define BOOST_RV_REF_END\
0364 && \
0365
0366
0367
0368
0369 #define BOOST_RV_REF_BEG_IF_CXX11 \
0370 BOOST_RV_REF_BEG \
0371
0372
0373
0374
0375 #define BOOST_RV_REF_END_IF_CXX11 \
0376 BOOST_RV_REF_END \
0377
0378
0379
0380
0381 #define BOOST_COPY_ASSIGN_REF(TYPE)\
0382 const TYPE & \
0383
0384
0385
0386
0387 #define BOOST_FWD_REF(TYPE)\
0388 TYPE && \
0389
0390
0391 #if !defined(BOOST_MOVE_DOXYGEN_INVOKED)
0392
0393 #define BOOST_RV_REF_2_TEMPL_ARGS(TYPE, ARG1, ARG2)\
0394 TYPE<ARG1, ARG2> && \
0395
0396
0397 #define BOOST_RV_REF_3_TEMPL_ARGS(TYPE, ARG1, ARG2, ARG3)\
0398 TYPE<ARG1, ARG2, ARG3> && \
0399
0400
0401 #define BOOST_COPY_ASSIGN_REF_BEG \
0402 const \
0403
0404
0405 #define BOOST_COPY_ASSIGN_REF_END \
0406 & \
0407
0408
0409 #define BOOST_COPY_ASSIGN_REF_2_TEMPL_ARGS(TYPE, ARG1, ARG2)\
0410 const TYPE<ARG1, ARG2> & \
0411
0412
0413 #define BOOST_COPY_ASSIGN_REF_3_TEMPL_ARGS(TYPE, ARG1, ARG2, ARG3)\
0414 const TYPE<ARG1, ARG2, ARG3>& \
0415
0416
0417 #define BOOST_CATCH_CONST_RLVALUE(TYPE)\
0418 const TYPE & \
0419
0420
0421 #endif
0422
0423 #if !defined(BOOST_MOVE_MSVC_AUTO_MOVE_RETURN_BUG) || defined(BOOST_MOVE_DOXYGEN_INVOKED)
0424
0425
0426
0427
0428
0429
0430
0431
0432
0433
0434
0435
0436
0437
0438
0439
0440
0441
0442
0443
0444
0445 #define BOOST_MOVE_RET(RET_TYPE, REF)\
0446 REF
0447
0448
0449 #else
0450
0451 #include <boost/move/detail/meta_utils_core.hpp>
0452
0453 namespace boost {
0454 namespace move_detail {
0455
0456 template <class Ret, class T>
0457 BOOST_MOVE_FORCEINLINE typename ::boost::move_detail::enable_if_c
0458 < ::boost::move_detail::is_lvalue_reference<Ret>::value
0459 , T&>::type
0460 move_return(T& x) BOOST_NOEXCEPT
0461 {
0462 return x;
0463 }
0464
0465 template <class Ret, class T>
0466 BOOST_MOVE_FORCEINLINE typename ::boost::move_detail::enable_if_c
0467 < !::boost::move_detail::is_lvalue_reference<Ret>::value
0468 , Ret && >::type
0469 move_return(T&& t) BOOST_NOEXCEPT
0470 {
0471 return static_cast< Ret&& >(t);
0472 }
0473
0474 }
0475 }
0476
0477 #define BOOST_MOVE_RET(RET_TYPE, REF)\
0478 boost::move_detail::move_return< RET_TYPE >(REF)
0479
0480
0481 #endif
0482
0483
0484
0485
0486
0487
0488
0489
0490 #define BOOST_MOVE_BASE(BASE_TYPE, ARG) \
0491 ::boost::move((BASE_TYPE&)(ARG))
0492
0493
0494
0495
0496
0497
0498
0499
0500
0501
0502 #define BOOST_MOVE_TO_LV(ARG) ARG
0503
0504
0505 namespace boost {
0506 namespace move_detail {
0507
0508 template< class T> struct forward_type { typedef T type; };
0509
0510 }}
0511
0512 #endif
0513
0514 #include <boost/move/detail/config_end.hpp>
0515
0516 #endif