File indexing completed on 2025-12-15 10:09:24
0001
0002
0003
0004
0005
0006
0007 #ifndef BOOST_THREAD_MOVE_HPP
0008 #define BOOST_THREAD_MOVE_HPP
0009
0010 #include <boost/thread/detail/config.hpp>
0011 #ifndef BOOST_NO_SFINAE
0012 #include <boost/core/enable_if.hpp>
0013 #include <boost/type_traits/is_convertible.hpp>
0014 #include <boost/type_traits/remove_reference.hpp>
0015 #include <boost/type_traits/remove_cv.hpp>
0016 #include <boost/type_traits/decay.hpp>
0017 #include <boost/type_traits/conditional.hpp>
0018 #include <boost/type_traits/remove_extent.hpp>
0019 #include <boost/type_traits/is_array.hpp>
0020 #include <boost/type_traits/is_function.hpp>
0021 #include <boost/type_traits/add_pointer.hpp>
0022 #endif
0023
0024 #include <boost/thread/detail/delete.hpp>
0025 #include <boost/move/utility.hpp>
0026 #include <boost/move/traits.hpp>
0027 #include <boost/config/abi_prefix.hpp>
0028 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
0029 #include <type_traits>
0030 #endif
0031 namespace boost
0032 {
0033
0034 namespace detail
0035 {
0036 template <typename T>
0037 struct enable_move_utility_emulation_dummy_specialization;
0038 template<typename T>
0039 struct thread_move_t
0040 {
0041 T& t;
0042 explicit thread_move_t(T& t_):
0043 t(t_)
0044 {}
0045
0046 T& operator*() const
0047 {
0048 return t;
0049 }
0050
0051 T* operator->() const
0052 {
0053 return &t;
0054 }
0055 private:
0056 void operator=(thread_move_t&);
0057 };
0058 }
0059
0060 #if !defined BOOST_THREAD_USES_MOVE
0061
0062 #ifndef BOOST_NO_SFINAE
0063 template<typename T>
0064 typename enable_if<boost::is_convertible<T&,boost::detail::thread_move_t<T> >, boost::detail::thread_move_t<T> >::type move(T& t)
0065 {
0066 return boost::detail::thread_move_t<T>(t);
0067 }
0068 #endif
0069
0070 template<typename T>
0071 boost::detail::thread_move_t<T> move(boost::detail::thread_move_t<T> t)
0072 {
0073 return t;
0074 }
0075
0076 #endif
0077 }
0078
0079 #if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES
0080
0081 #define BOOST_THREAD_COPY_ASSIGN_REF(TYPE) BOOST_COPY_ASSIGN_REF(TYPE)
0082 #define BOOST_THREAD_RV_REF(TYPE) BOOST_RV_REF(TYPE)
0083 #define BOOST_THREAD_RV_REF_2_TEMPL_ARGS(TYPE) BOOST_RV_REF_2_TEMPL_ARGS(TYPE)
0084 #define BOOST_THREAD_RV_REF_BEG BOOST_RV_REF_BEG
0085 #define BOOST_THREAD_RV_REF_END BOOST_RV_REF_END
0086 #define BOOST_THREAD_RV(V) V
0087 #define BOOST_THREAD_MAKE_RV_REF(RVALUE) RVALUE
0088 #define BOOST_THREAD_FWD_REF(TYPE) BOOST_FWD_REF(TYPE)
0089 #define BOOST_THREAD_DCL_MOVABLE(TYPE)
0090 #define BOOST_THREAD_DCL_MOVABLE_BEG(T) \
0091 namespace detail { \
0092 template <typename T> \
0093 struct enable_move_utility_emulation_dummy_specialization<
0094
0095 #define BOOST_THREAD_DCL_MOVABLE_BEG2(T1, T2) \
0096 namespace detail { \
0097 template <typename T1, typename T2> \
0098 struct enable_move_utility_emulation_dummy_specialization<
0099
0100 #define BOOST_THREAD_DCL_MOVABLE_END > \
0101 : integral_constant<bool, false> \
0102 {}; \
0103 }
0104
0105 #elif ! defined BOOST_NO_CXX11_RVALUE_REFERENCES && defined BOOST_MSVC
0106
0107 #define BOOST_THREAD_COPY_ASSIGN_REF(TYPE) BOOST_COPY_ASSIGN_REF(TYPE)
0108 #define BOOST_THREAD_RV_REF(TYPE) BOOST_RV_REF(TYPE)
0109 #define BOOST_THREAD_RV_REF_2_TEMPL_ARGS(TYPE) BOOST_RV_REF_2_TEMPL_ARGS(TYPE)
0110 #define BOOST_THREAD_RV_REF_BEG BOOST_RV_REF_BEG
0111 #define BOOST_THREAD_RV_REF_END BOOST_RV_REF_END
0112 #define BOOST_THREAD_RV(V) V
0113 #define BOOST_THREAD_MAKE_RV_REF(RVALUE) RVALUE
0114 #define BOOST_THREAD_FWD_REF(TYPE) BOOST_FWD_REF(TYPE)
0115 #define BOOST_THREAD_DCL_MOVABLE(TYPE)
0116 #define BOOST_THREAD_DCL_MOVABLE_BEG(T) \
0117 namespace detail { \
0118 template <typename T> \
0119 struct enable_move_utility_emulation_dummy_specialization<
0120
0121 #define BOOST_THREAD_DCL_MOVABLE_BEG2(T1, T2) \
0122 namespace detail { \
0123 template <typename T1, typename T2> \
0124 struct enable_move_utility_emulation_dummy_specialization<
0125
0126 #define BOOST_THREAD_DCL_MOVABLE_END > \
0127 : integral_constant<bool, false> \
0128 {}; \
0129 }
0130
0131 #else
0132
0133 #if defined BOOST_THREAD_USES_MOVE
0134 #define BOOST_THREAD_COPY_ASSIGN_REF(TYPE) BOOST_COPY_ASSIGN_REF(TYPE)
0135 #define BOOST_THREAD_RV_REF(TYPE) BOOST_RV_REF(TYPE)
0136 #define BOOST_THREAD_RV_REF_2_TEMPL_ARGS(TYPE) BOOST_RV_REF_2_TEMPL_ARGS(TYPE)
0137 #define BOOST_THREAD_RV_REF_BEG BOOST_RV_REF_BEG
0138 #define BOOST_THREAD_RV_REF_END BOOST_RV_REF_END
0139 #define BOOST_THREAD_RV(V) V
0140 #define BOOST_THREAD_FWD_REF(TYPE) BOOST_FWD_REF(TYPE)
0141 #define BOOST_THREAD_DCL_MOVABLE(TYPE)
0142 #define BOOST_THREAD_DCL_MOVABLE_BEG(T) \
0143 namespace detail { \
0144 template <typename T> \
0145 struct enable_move_utility_emulation_dummy_specialization<
0146
0147 #define BOOST_THREAD_DCL_MOVABLE_BEG2(T1, T2) \
0148 namespace detail { \
0149 template <typename T1, typename T2> \
0150 struct enable_move_utility_emulation_dummy_specialization<
0151
0152 #define BOOST_THREAD_DCL_MOVABLE_END > \
0153 : integral_constant<bool, false> \
0154 {}; \
0155 }
0156
0157 #else
0158
0159 #define BOOST_THREAD_COPY_ASSIGN_REF(TYPE) const TYPE&
0160 #define BOOST_THREAD_RV_REF(TYPE) boost::detail::thread_move_t< TYPE >
0161 #define BOOST_THREAD_RV_REF_BEG boost::detail::thread_move_t<
0162 #define BOOST_THREAD_RV_REF_END >
0163 #define BOOST_THREAD_RV(V) (*V)
0164 #define BOOST_THREAD_FWD_REF(TYPE) BOOST_FWD_REF(TYPE)
0165
0166 #define BOOST_THREAD_DCL_MOVABLE(TYPE) \
0167 template <> \
0168 struct enable_move_utility_emulation< TYPE > \
0169 { \
0170 static const bool value = false; \
0171 };
0172
0173 #define BOOST_THREAD_DCL_MOVABLE_BEG(T) \
0174 template <typename T> \
0175 struct enable_move_utility_emulation<
0176
0177 #define BOOST_THREAD_DCL_MOVABLE_BEG2(T1, T2) \
0178 template <typename T1, typename T2> \
0179 struct enable_move_utility_emulation<
0180
0181 #define BOOST_THREAD_DCL_MOVABLE_END > \
0182 { \
0183 static const bool value = false; \
0184 };
0185
0186 #endif
0187
0188 namespace boost
0189 {
0190 namespace detail
0191 {
0192 template <typename T>
0193 BOOST_THREAD_RV_REF(typename ::boost::remove_cv<typename ::boost::remove_reference<T>::type>::type)
0194 make_rv_ref(T v) BOOST_NOEXCEPT
0195 {
0196 return (BOOST_THREAD_RV_REF(typename ::boost::remove_cv<typename ::boost::remove_reference<T>::type>::type))(v);
0197 }
0198
0199
0200
0201
0202
0203
0204
0205
0206
0207
0208
0209
0210 }
0211 }
0212
0213 #define BOOST_THREAD_MAKE_RV_REF(RVALUE) RVALUE.move()
0214
0215 #endif
0216
0217
0218 #if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES
0219
0220 #define BOOST_THREAD_MOVABLE(TYPE)
0221
0222 #define BOOST_THREAD_COPYABLE(TYPE)
0223
0224 #else
0225
0226 #if defined BOOST_THREAD_USES_MOVE
0227
0228 #define BOOST_THREAD_MOVABLE(TYPE) \
0229 ::boost::rv<TYPE>& move() BOOST_NOEXCEPT \
0230 { \
0231 return *static_cast< ::boost::rv<TYPE>* >(this); \
0232 } \
0233 const ::boost::rv<TYPE>& move() const BOOST_NOEXCEPT \
0234 { \
0235 return *static_cast<const ::boost::rv<TYPE>* >(this); \
0236 } \
0237 operator ::boost::rv<TYPE>&() \
0238 { \
0239 return *static_cast< ::boost::rv<TYPE>* >(this); \
0240 } \
0241 operator const ::boost::rv<TYPE>&() const \
0242 { \
0243 return *static_cast<const ::boost::rv<TYPE>* >(this); \
0244 }\
0245
0246 #define BOOST_THREAD_COPYABLE(TYPE) \
0247 TYPE& operator=(TYPE &t)\
0248 { this->operator=(static_cast<const ::boost::rv<TYPE> &>(const_cast<const TYPE &>(t))); return *this;}
0249
0250
0251 #else
0252
0253 #define BOOST_THREAD_MOVABLE(TYPE) \
0254 operator ::boost::detail::thread_move_t<TYPE>() BOOST_NOEXCEPT \
0255 { \
0256 return move(); \
0257 } \
0258 ::boost::detail::thread_move_t<TYPE> move() BOOST_NOEXCEPT \
0259 { \
0260 ::boost::detail::thread_move_t<TYPE> x(*this); \
0261 return x; \
0262 } \
0263
0264 #define BOOST_THREAD_COPYABLE(TYPE)
0265
0266 #endif
0267 #endif
0268
0269 #define BOOST_THREAD_MOVABLE_ONLY(TYPE) \
0270 BOOST_THREAD_NO_COPYABLE(TYPE) \
0271 BOOST_THREAD_MOVABLE(TYPE) \
0272 typedef int boost_move_no_copy_constructor_or_assign; \
0273
0274
0275 #define BOOST_THREAD_COPYABLE_AND_MOVABLE(TYPE) \
0276 BOOST_THREAD_COPYABLE(TYPE) \
0277 BOOST_THREAD_MOVABLE(TYPE) \
0278
0279
0280
0281 namespace boost
0282 {
0283 namespace thread_detail
0284 {
0285
0286 #if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES
0287 #elif defined BOOST_THREAD_USES_MOVE
0288 template <class T>
0289 struct is_rv
0290 : ::boost::move_detail::is_rv<T>
0291 {};
0292
0293 #else
0294 template <class T>
0295 struct is_rv
0296 : ::boost::integral_constant<bool, false>
0297 {};
0298
0299 template <class T>
0300 struct is_rv< ::boost::detail::thread_move_t<T> >
0301 : ::boost::integral_constant<bool, true>
0302 {};
0303
0304 template <class T>
0305 struct is_rv< const ::boost::detail::thread_move_t<T> >
0306 : ::boost::integral_constant<bool, true>
0307 {};
0308 #endif
0309
0310 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
0311 template <class Tp>
0312 struct remove_reference : boost::remove_reference<Tp> {};
0313 template <class Tp>
0314 struct decay : boost::decay<Tp> {};
0315 #else
0316 template <class Tp>
0317 struct remove_reference
0318 {
0319 typedef Tp type;
0320 };
0321 template <class Tp>
0322 struct remove_reference<Tp&>
0323 {
0324 typedef Tp type;
0325 };
0326 template <class Tp>
0327 struct remove_reference< rv<Tp> > {
0328 typedef Tp type;
0329 };
0330
0331 template <class Tp>
0332 struct decay
0333 {
0334 private:
0335 typedef typename boost::move_detail::remove_rvalue_reference<Tp>::type Up0;
0336 typedef typename boost::remove_reference<Up0>::type Up;
0337 public:
0338 typedef typename conditional
0339 <
0340 is_array<Up>::value,
0341 typename remove_extent<Up>::type*,
0342 typename conditional
0343 <
0344 is_function<Up>::value,
0345 typename add_pointer<Up>::type,
0346 typename remove_cv<Up>::type
0347 >::type
0348 >::type type;
0349 };
0350 #endif
0351
0352 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
0353 template <class T>
0354 typename decay<T>::type
0355 decay_copy(T&& t)
0356 {
0357 return boost::forward<T>(t);
0358 }
0359 typedef void (*void_fct_ptr)();
0360
0361
0362
0363
0364
0365
0366 #else
0367 template <class T>
0368 typename decay<T>::type
0369 decay_copy(BOOST_THREAD_FWD_REF(T) t)
0370 {
0371 return boost::forward<T>(t);
0372 }
0373 #endif
0374 }
0375 }
0376
0377 #include <boost/config/abi_suffix.hpp>
0378
0379 #endif