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