diff -ur boost_1_48_0/boost/move/move.hpp boost_1_48_0_patched/boost/move/move.hpp --- boost_1_48_0/boost/move/move.hpp 2011-10-17 03:47:28.000000000 +1100 +++ boost_1_48_0_patched/boost/move/move.hpp 2012-01-08 20:30:54.000000000 +1100 @@ -375,6 +375,10 @@ { return *static_cast< ::boost::rv* >(this); }\ operator const ::boost::rv&() const \ { return *static_cast* >(this); }\ + ::boost::rv& move()\ + { return static_cast< ::boost::rv& >(*this); }\ + ::boost::rv const& copy() const\ + { return static_cast< ::boost::rv const& >(*this); }\ private:\ // @@ -393,6 +397,10 @@ { return *static_cast< ::boost::rv* >(this); }\ operator const ::boost::rv&() const \ { return *static_cast* >(this); }\ + ::boost::rv& move()\ + { return static_cast< ::boost::rv& >(*this); }\ + ::boost::rv const& copy() const\ + { return static_cast< ::boost::rv const& >(*this); }\ private:\ // @@ -402,6 +410,10 @@ { return *static_cast< ::boost::rv* >(this); }\ operator const ::boost::rv&() const \ { return *static_cast* >(this); }\ + ::boost::rv& move()\ + { return static_cast< ::boost::rv& >(*this); }\ + ::boost::rv const& copy() const\ + { return static_cast< ::boost::rv const& >(*this); }\ private:\ // @@ -518,6 +530,10 @@ #define BOOST_MOVABLE_BUT_NOT_COPYABLE(TYPE)\ public:\ typedef int boost_move_emulation_t;\ + TYPE&& move()\ + { return static_cast< TYPE&& >(*this); }\ + TYPE const& copy() const\ + { return static_cast< TYPE const& >(*this); }\ private:\ TYPE(const TYPE &);\ TYPE& operator=(const TYPE &);\ @@ -527,9 +543,21 @@ //! The user will need to write a move constructor/assignment and a copy assignment //! as explained in the documentation to fully write a copyable and movable class. #define BOOST_COPYABLE_AND_MOVABLE(TYPE)\ + public:\ + TYPE&& move()\ + { return static_cast< TYPE&& >(*this); }\ + TYPE const& copy() const\ + { return static_cast< TYPE const& >(*this); }\ + private:\ // #define BOOST_COPYABLE_AND_MOVABLE_ALT(TYPE)\ + public:\ + TYPE&& move()\ + { return static_cast< TYPE&& >(*this); }\ + TYPE const& copy() const\ + { return static_cast< TYPE const& >(*this); }\ + private:\ // //!This macro is used to achieve portable syntax in move Only in boost_1_48_0/boost/thread/detail: move.hpp diff -ur boost_1_48_0/boost/thread/detail/thread.hpp boost_1_48_0_patched/boost/thread/detail/thread.hpp --- boost_1_48_0/boost/thread/detail/thread.hpp 2010-08-26 02:41:08.000000000 +1000 +++ boost_1_48_0_patched/boost/thread/detail/thread.hpp 2012-01-08 21:51:39.000000000 +1100 @@ -9,7 +9,7 @@ #ifndef BOOST_NO_IOSTREAM #include #endif -#include +#include #include #include #include @@ -23,7 +23,10 @@ #include #include #include +#include #include +#include +#include #include @@ -41,27 +44,37 @@ public detail::thread_data_base { public: -#ifndef BOOST_NO_RVALUE_REFERENCES - thread_data(F&& f_): - f(static_cast(f_)) - {} - thread_data(F& f_): - f(f_) + thread_data(BOOST_RV_REF(F) f_): + f(boost::move(f_)) {} -#else - thread_data(F f_): + thread_data(F const& f_): f(f_) {} - thread_data(detail::thread_move_t f_): + void run() + { + f(); + } + private: + F f; + + void operator=(thread_data&); + thread_data(thread_data&); + }; + + template + class thread_data: + public detail::thread_data_base + { + public: + thread_data(R f_()): f(f_) {} -#endif void run() { f(); } private: - F f; + R (*f)(); void operator=(thread_data&); thread_data(thread_data&); @@ -110,9 +123,7 @@ class BOOST_THREAD_DECL thread { private: - thread(thread&); - thread& operator=(thread&); - + BOOST_MOVABLE_BUT_NOT_COPYABLE(thread) void release_handle(); detail::thread_data_ptr thread_info; @@ -123,29 +134,17 @@ detail::thread_data_ptr get_thread_info BOOST_PREVENT_MACRO_SUBSTITUTION () const; -#ifndef BOOST_NO_RVALUE_REFERENCES template - static inline detail::thread_data_ptr make_thread_info(F&& f) + static inline detail::thread_data_ptr make_thread_info(BOOST_RV_REF(F) f) { - return detail::thread_data_ptr(detail::heap_new::type> >(static_cast(f))); + return detail::thread_data_ptr(detail::heap_new::type> >(boost::move(f))); } - static inline detail::thread_data_ptr make_thread_info(void (*f)()) - { - return detail::thread_data_ptr(detail::heap_new >(static_cast(f))); - } -#else template - static inline detail::thread_data_ptr make_thread_info(F f) - { - return detail::thread_data_ptr(detail::heap_new >(f)); - } - template - static inline detail::thread_data_ptr make_thread_info(boost::detail::thread_move_t f) + static inline detail::thread_data_ptr make_thread_info(F const& f) { return detail::thread_data_ptr(detail::heap_new >(f)); } -#endif struct dummy; public: #if BOOST_WORKAROUND(__SUNPRO_CC, < 0x5100) @@ -155,96 +154,67 @@ ~thread(); #ifndef BOOST_NO_RVALUE_REFERENCES -#ifdef BOOST_MSVC - template - explicit thread(F f,typename disable_if >, dummy* >::type=0): - thread_info(make_thread_info(static_cast(f))) - { - start_thread(); - } -#else - template - thread(F&& f): - thread_info(make_thread_info(static_cast(f))) - { - start_thread(); - } -#endif - - thread(thread&& other) - { - thread_info.swap(other.thread_info); - } - thread& operator=(thread&& other) { thread_info=other.thread_info; other.thread_info.reset(); return *this; } - - thread&& move() - { - return static_cast(*this); - } - -#else -#ifdef BOOST_NO_SFINAE template - explicit thread(F f): - thread_info(make_thread_info(f)) + explicit thread(F&& f): + thread_info(make_thread_info(static_cast, typename boost::remove_reference::type const&, F&&>::type>(f))) { start_thread(); } #else template - explicit thread(F f,typename disable_if >, dummy* >::type=0): - thread_info(make_thread_info(f)) - { - start_thread(); - } -#endif - - template - explicit thread(detail::thread_move_t f): + explicit thread(F const& f,typename disable_if&>, dummy* >::type=0): thread_info(make_thread_info(f)) { start_thread(); } - thread(detail::thread_move_t x) - { - thread_info=x->thread_info; - x->thread_info.reset(); - } - #if BOOST_WORKAROUND(__SUNPRO_CC, < 0x5100) - thread& operator=(thread x) + thread& operator=(thread other) { - swap(x); + swap(other); return *this; } #else - thread& operator=(detail::thread_move_t x) + thread& operator=(BOOST_RV_REF(thread) other) { - thread new_thread(x); + thread new_thread(boost::move(other)); swap(new_thread); return *this; } -#endif - operator detail::thread_move_t() +#endif + template + explicit thread(BOOST_RV_REF(F) f): + thread_info(make_thread_info(boost::move(f))) { - return move(); + start_thread(); } - detail::thread_move_t move() + template + explicit thread(F& f): + thread_info(make_thread_info(f)) { - detail::thread_move_t x(*this); - return x; + start_thread(); } - #endif + template + explicit thread(BOOST_CATCH_CONST_RLVALUE(F) f): + thread_info(make_thread_info(f)) + { + start_thread(); + } + + thread(BOOST_RV_REF(thread) other) + { + thread_info.swap(other.thread_info); + } + template thread(F f,A1 a1): thread_info(make_thread_info(boost::bind(boost::type(),f,a1))) @@ -355,22 +325,6 @@ { return lhs.swap(rhs); } - -#ifndef BOOST_NO_RVALUE_REFERENCES - inline thread&& move(thread& t) - { - return static_cast(t); - } - inline thread&& move(thread&& t) - { - return static_cast(t); - } -#else - inline detail::thread_move_t move(detail::thread_move_t t) - { - return t; - } -#endif namespace this_thread { diff -ur boost_1_48_0/boost/thread/future.hpp boost_1_48_0_patched/boost/thread/future.hpp --- boost_1_48_0/boost/thread/future.hpp 2010-10-30 10:27:00.000000000 +1100 +++ boost_1_48_0_patched/boost/thread/future.hpp 2012-01-09 18:12:00.000000000 +1100 @@ -7,7 +7,7 @@ #ifndef BOOST_THREAD_FUTURE_HPP #define BOOST_THREAD_FUTURE_HPP #include -#include +#include #include #include #include @@ -16,6 +16,8 @@ #include #include #include +#include +#include #include #include #include @@ -229,9 +231,10 @@ typedef typename boost::mpl::if_,dummy&,T&&>::type rvalue_source_type; typedef typename boost::mpl::if_,T,T&&>::type move_dest_type; #else - typedef T& source_reference_type; - typedef typename boost::mpl::if_ >,boost::detail::thread_move_t,T const&>::type rvalue_source_type; - typedef typename boost::mpl::if_ >,boost::detail::thread_move_t,T>::type move_dest_type; + typedef boost::is_convertible& > T_supports_move_emulation; + typedef typename boost::mpl::if_ const&,T&>::type source_reference_type; + typedef typename boost::mpl::if_&,T const&>::type rvalue_source_type; + typedef typename boost::mpl::if_&,T>::type move_dest_type; #endif static void init(storage_type& storage,source_reference_type t) @@ -322,13 +325,13 @@ void mark_finished_with_result(rvalue_source_type result_) { boost::lock_guard lock(mutex); - mark_finished_with_result_internal(result_); + mark_finished_with_result_internal(static_cast(result_)); } - move_dest_type get() + T& get() { wait(); - return static_cast(*result); + return *result; } future_state::state get_state() @@ -616,8 +619,7 @@ template class unique_future { - unique_future(unique_future & rhs);// = delete; - unique_future& operator=(unique_future& rhs);// = delete; + BOOST_MOVABLE_BUT_NOT_COPYABLE(unique_future) typedef boost::shared_ptr > future_ptr; @@ -643,36 +645,16 @@ ~unique_future() {} -#ifndef BOOST_NO_RVALUE_REFERENCES - unique_future(unique_future && other) + unique_future(BOOST_RV_REF(unique_future) other) { future.swap(other.future); } - unique_future& operator=(unique_future && other) + unique_future& operator=(BOOST_RV_REF(unique_future) other) { future=other.future; other.future.reset(); return *this; } -#else - unique_future(boost::detail::thread_move_t other): - future(other->future) - { - other->future.reset(); - } - - unique_future& operator=(boost::detail::thread_move_t other) - { - future=other->future; - other->future.reset(); - return *this; - } - - operator boost::detail::thread_move_t() - { - return boost::detail::thread_move_t(*this); - } -#endif void swap(unique_future& other) { @@ -687,7 +669,7 @@ boost::throw_exception(future_uninitialized()); } - return future->get(); + return static_cast(future->get()); } // functions to check state, and wait for ready @@ -752,6 +734,8 @@ // shared_future(const unique_future& other); // shared_future& operator=(const unique_future& other); + BOOST_COPYABLE_AND_MOVABLE(shared_future) + friend class detail::future_waiter; friend class promise; friend class packaged_task; @@ -773,63 +757,32 @@ ~shared_future() {} - shared_future& operator=(shared_future const& other) + shared_future& operator=(BOOST_COPY_ASSIGN_REF(shared_future) other) { future=other.future; return *this; } -#ifndef BOOST_NO_RVALUE_REFERENCES - shared_future(shared_future && other) + + shared_future(BOOST_RV_REF(shared_future) other) { future.swap(other.future); } - shared_future(unique_future && other) + shared_future(BOOST_RV_REF(unique_future) other) { future.swap(other.future); } - shared_future& operator=(shared_future && other) + shared_future& operator=(BOOST_RV_REF(shared_future) other) { future.swap(other.future); other.future.reset(); return *this; } - shared_future& operator=(unique_future && other) + shared_future& operator=(BOOST_RV_REF(unique_future) other) { future.swap(other.future); other.future.reset(); return *this; } -#else - shared_future(boost::detail::thread_move_t other): - future(other->future) - { - other->future.reset(); - } -// shared_future(const unique_future &) = delete; - shared_future(boost::detail::thread_move_t > other): - future(other->future) - { - other->future.reset(); - } - shared_future& operator=(boost::detail::thread_move_t other) - { - future.swap(other->future); - other->future.reset(); - return *this; - } - shared_future& operator=(boost::detail::thread_move_t > other) - { - future.swap(other->future); - other->future.reset(); - return *this; - } - - operator boost::detail::thread_move_t() - { - return boost::detail::thread_move_t(*this); - } - -#endif void swap(shared_future& other) { @@ -837,7 +790,7 @@ } // retrieving the value - R get() + R const& get() { if(!future) { @@ -907,8 +860,7 @@ future_ptr future; bool future_obtained; - promise(promise & rhs);// = delete; - promise & operator=(promise & rhs);// = delete; + BOOST_MOVABLE_BUT_NOT_COPYABLE(promise) void lazy_init() { @@ -940,14 +892,13 @@ } // Assignment -#ifndef BOOST_NO_RVALUE_REFERENCES - promise(promise && rhs): + promise(BOOST_RV_REF(promise) rhs): future_obtained(rhs.future_obtained) { future.swap(rhs.future); rhs.future_obtained=false; } - promise & operator=(promise&& rhs) + promise & operator=(BOOST_RV_REF(promise) rhs) { future.swap(rhs.future); future_obtained=rhs.future_obtained; @@ -955,27 +906,6 @@ rhs.future_obtained=false; return *this; } -#else - promise(boost::detail::thread_move_t rhs): - future(rhs->future),future_obtained(rhs->future_obtained) - { - rhs->future.reset(); - rhs->future_obtained=false; - } - promise & operator=(boost::detail::thread_move_t rhs) - { - future=rhs->future; - future_obtained=rhs->future_obtained; - rhs->future.reset(); - rhs->future_obtained=false; - return *this; - } - - operator boost::detail::thread_move_t() - { - return boost::detail::thread_move_t(*this); - } -#endif void swap(promise& other) { @@ -1046,8 +976,7 @@ future_ptr future; bool future_obtained; - promise(promise & rhs);// = delete; - promise & operator=(promise & rhs);// = delete; + BOOST_MOVABLE_BUT_NOT_COPYABLE(promise) void lazy_init() { @@ -1078,14 +1007,13 @@ } // Assignment -#ifndef BOOST_NO_RVALUE_REFERENCES - promise(promise && rhs): + promise(BOOST_RV_REF(promise) rhs): future_obtained(rhs.future_obtained) { future.swap(rhs.future); rhs.future_obtained=false; } - promise & operator=(promise&& rhs) + promise & operator=(BOOST_RV_REF(promise) rhs) { future.swap(rhs.future); future_obtained=rhs.future_obtained; @@ -1093,27 +1021,6 @@ rhs.future_obtained=false; return *this; } -#else - promise(boost::detail::thread_move_t rhs): - future(rhs->future),future_obtained(rhs->future_obtained) - { - rhs->future.reset(); - rhs->future_obtained=false; - } - promise & operator=(boost::detail::thread_move_t rhs) - { - future=rhs->future; - future_obtained=rhs->future_obtained; - rhs->future.reset(); - rhs->future_obtained=false; - return *this; - } - - operator boost::detail::thread_move_t() - { - return boost::detail::thread_move_t(*this); - } -#endif void swap(promise& other) { @@ -1209,12 +1116,15 @@ struct task_object: task_base { + struct dummy; F f; + task_object(F const& f_): f(f_) {} - task_object(boost::detail::thread_move_t f_): - f(f_) + + task_object(BOOST_RV_REF(F) f_): + f(::boost::move(f_)) {} void do_run() @@ -1234,11 +1144,39 @@ struct task_object: task_base { + struct dummy; F f; + task_object(F const& f_): f(f_) {} - task_object(boost::detail::thread_move_t f_): + + task_object(BOOST_RV_REF(F) f_): + f(::boost::move(f_)) + {} + + void do_run() + { + try + { + f(); + this->mark_finished_with_result(); + } + catch(...) + { + this->mark_exceptional_finish(); + } + } + }; + + template + struct task_object: + task_base + { + struct dummy; + R (*f)(); + + task_object(R f_()): f(f_) {} @@ -1246,6 +1184,30 @@ { try { + this->mark_finished_with_result(f()); + } + catch(...) + { + this->mark_exceptional_finish(); + } + } + }; + + template<> + struct task_object: + task_base + { + struct dummy; + void (*f)(); + + task_object(void f_()): + f(f_) + {} + + void do_run() + { + try + { f(); this->mark_finished_with_result(); } @@ -1265,28 +1227,50 @@ boost::shared_ptr > task; bool future_obtained; - packaged_task(packaged_task&);// = delete; - packaged_task& operator=(packaged_task&);// = delete; - + BOOST_MOVABLE_BUT_NOT_COPYABLE(packaged_task) + struct dummy; public: packaged_task(): future_obtained(false) {} // construction and destruction +#ifdef BOOST_NO_RVALUE_REFERENCES template - explicit packaged_task(F const& f): + explicit packaged_task(F const& f, typename ::boost::disable_if< ::boost::is_convertible&>,dummy*>::type=0): task(new detail::task_object(f)),future_obtained(false) {} - explicit packaged_task(R(*f)()): - task(new detail::task_object(f)),future_obtained(false) + + template + explicit packaged_task(F& f): + task(new detail::task_object(f)),future_obtained(false) {} template - explicit packaged_task(boost::detail::thread_move_t f): + explicit packaged_task(BOOST_RV_REF(F) f): + task(new detail::task_object(boost::move(f))),future_obtained(false) + {} + + template + explicit packaged_task(BOOST_CATCH_CONST_RLVALUE(F) f): task(new detail::task_object(f)),future_obtained(false) {} +#else + template + explicit packaged_task(F&& f): + task(new detail::task_object::type>( + static_cast, + typename boost::remove_reference::type const&, F&&>::type>(f))), + future_obtained(false) + {} +#endif + explicit packaged_task(R(*f)()): + task(new detail::task_object(f)),future_obtained(false) + {} + + + // template // explicit packaged_task(F const& f, Allocator a); // template @@ -1302,37 +1286,18 @@ } // assignment -#ifndef BOOST_NO_RVALUE_REFERENCES - packaged_task(packaged_task&& other): + packaged_task(BOOST_RV_REF(packaged_task) other): future_obtained(other.future_obtained) { task.swap(other.task); other.future_obtained=false; } - packaged_task& operator=(packaged_task&& other) - { - packaged_task temp(static_cast(other)); - swap(temp); - return *this; - } -#else - packaged_task(boost::detail::thread_move_t other): - future_obtained(other->future_obtained) - { - task.swap(other->task); - other->future_obtained=false; - } - packaged_task& operator=(boost::detail::thread_move_t other) + packaged_task& operator=(BOOST_RV_REF(packaged_task) other) { - packaged_task temp(other); + packaged_task temp(boost::move(other)); swap(temp); return *this; } - operator boost::detail::thread_move_t() - { - return boost::detail::thread_move_t(*this); - } -#endif void swap(packaged_task& other) { diff -ur boost_1_48_0/boost/thread/locks.hpp boost_1_48_0_patched/boost/thread/locks.hpp --- boost_1_48_0/boost/thread/locks.hpp 2010-07-10 05:13:09.000000000 +1000 +++ boost_1_48_0_patched/boost/thread/locks.hpp 2012-01-08 20:38:42.000000000 +1100 @@ -6,7 +6,7 @@ #define BOOST_THREAD_LOCKS_HPP #include #include -#include +#include #include #include #include @@ -272,10 +272,8 @@ private: Mutex* m; bool is_locked; - unique_lock(unique_lock&); explicit unique_lock(upgrade_lock&); - unique_lock& operator=(unique_lock&); - unique_lock& operator=(upgrade_lock& other); + BOOST_MOVABLE_BUT_NOT_COPYABLE(unique_lock); public: #if BOOST_WORKAROUND(__SUNPRO_CC, < 0x5100) unique_lock(const volatile unique_lock&); @@ -311,85 +309,34 @@ { timed_lock(target_time); } -#ifndef BOOST_NO_RVALUE_REFERENCES - unique_lock(unique_lock&& other): + + unique_lock(BOOST_RV_REF(unique_lock) other): m(other.m),is_locked(other.is_locked) { other.is_locked=false; other.m=0; } - explicit unique_lock(upgrade_lock&& other); - - unique_lock&& move() - { - return static_cast&&>(*this); - } - + explicit unique_lock(BOOST_RV_REF(upgrade_lock) other); - unique_lock& operator=(unique_lock&& other) + unique_lock& operator=(BOOST_RV_REF(unique_lock) other) { unique_lock temp(other.move()); swap(temp); return *this; } - unique_lock& operator=(upgrade_lock&& other) + unique_lock& operator=(BOOST_RV_REF(upgrade_lock) other) { unique_lock temp(other.move()); swap(temp); return *this; } - void swap(unique_lock&& other) + void swap(BOOST_RV_REF(unique_lock) other) { std::swap(m,other.m); std::swap(is_locked,other.is_locked); } -#else - unique_lock(detail::thread_move_t > other): - m(other->m),is_locked(other->is_locked) - { - other->is_locked=false; - other->m=0; - } - unique_lock(detail::thread_move_t > other); - - operator detail::thread_move_t >() - { - return move(); - } - - detail::thread_move_t > move() - { - return detail::thread_move_t >(*this); - } -#if BOOST_WORKAROUND(__SUNPRO_CC, < 0x5100) - unique_lock& operator=(unique_lock other) - { - swap(other); - return *this; - } -#else - unique_lock& operator=(detail::thread_move_t > other) - { - unique_lock temp(other); - swap(temp); - return *this; - } -#endif - - unique_lock& operator=(detail::thread_move_t > other) - { - unique_lock temp(other); - swap(temp); - return *this; - } - void swap(detail::thread_move_t > other) - { - std::swap(m,other->m); - std::swap(is_locked,other->is_locked); - } -#endif void swap(unique_lock& other) { std::swap(m,other.m); @@ -479,45 +426,19 @@ friend class upgrade_lock; }; -#ifndef BOOST_NO_RVALUE_REFERENCES - template - void swap(unique_lock&& lhs,unique_lock&& rhs) - { - lhs.swap(rhs); - } template - inline upgrade_lock&& move(upgrade_lock&& ul) + void swap(BOOST_RV_REF(unique_lock) lhs, BOOST_RV_REF(unique_lock) rhs) { - return static_cast&&>(ul); + lhs.swap(rhs); } template - inline upgrade_lock&& move(upgrade_lock& ul) - { - return static_cast&&>(ul); - } -#endif - template void swap(unique_lock& lhs,unique_lock& rhs) { lhs.swap(rhs); } -#ifndef BOOST_NO_RVALUE_REFERENCES - template - inline unique_lock&& move(unique_lock&& ul) - { - return static_cast&&>(ul); - } - - template - inline unique_lock&& move(unique_lock& ul) - { - return static_cast&&>(ul); - } -#endif - template class shared_lock { @@ -525,8 +446,7 @@ Mutex* m; bool is_locked; private: - explicit shared_lock(shared_lock&); - shared_lock& operator=(shared_lock&); + BOOST_MOVABLE_BUT_NOT_COPYABLE(shared_lock) public: shared_lock(): m(0),is_locked(false) @@ -554,14 +474,14 @@ timed_lock(target_time); } - shared_lock(detail::thread_move_t > other): + shared_lock(BOOST_RV_REF(shared_lock) other): m(other->m),is_locked(other->is_locked) { other->is_locked=false; other->m=0; } - shared_lock(detail::thread_move_t > other): + shared_lock(BOOST_RV_REF(unique_lock) other): m(other->m),is_locked(other->is_locked) { if(is_locked) @@ -572,7 +492,7 @@ other->m=0; } - shared_lock(detail::thread_move_t > other): + shared_lock(BOOST_RV_REF(upgrade_lock) other): m(other->m),is_locked(other->is_locked) { if(is_locked) @@ -583,51 +503,33 @@ other->m=0; } - operator detail::thread_move_t >() - { - return move(); - } - - detail::thread_move_t > move() - { - return detail::thread_move_t >(*this); - } - - - shared_lock& operator=(detail::thread_move_t > other) + shared_lock& operator=(BOOST_RV_REF(shared_lock) other) { shared_lock temp(other); swap(temp); return *this; } - shared_lock& operator=(detail::thread_move_t > other) + shared_lock& operator=(BOOST_RV_REF(unique_lock) other) { shared_lock temp(other); swap(temp); return *this; } - shared_lock& operator=(detail::thread_move_t > other) + shared_lock& operator=(BOOST_RV_REF(upgrade_lock) other) { shared_lock temp(other); swap(temp); return *this; } -#ifndef BOOST_NO_RVALUE_REFERENCES - void swap(shared_lock&& other) + void swap(BOOST_RV_REF(shared_lock) other) { std::swap(m,other.m); std::swap(is_locked,other.is_locked); } -#else - void swap(boost::detail::thread_move_t > other) - { - std::swap(m,other->m); - std::swap(is_locked,other->is_locked); - } -#endif + void swap(shared_lock& other) { std::swap(m,other.m); @@ -709,19 +611,11 @@ }; -#ifndef BOOST_NO_RVALUE_REFERENCES - template - void swap(shared_lock&& lhs,shared_lock&& rhs) - { - lhs.swap(rhs); - } -#else template - void swap(shared_lock& lhs,shared_lock& rhs) + void swap(BOOST_RV_REF(shared_lock) lhs,BOOST_RV_REF(shared_lock) rhs) { lhs.swap(rhs); } -#endif template class upgrade_lock @@ -730,8 +624,7 @@ Mutex* m; bool is_locked; private: - explicit upgrade_lock(upgrade_lock&); - upgrade_lock& operator=(upgrade_lock&); + BOOST_MOVABLE_BUT_NOT_COPYABLE(upgrade_lock) public: upgrade_lock(): m(0),is_locked(false) @@ -753,15 +646,15 @@ { try_lock(); } -#ifdef BOOST_HAS_RVALUE_REFS - upgrade_lock(upgrade_lock&& other): + + upgrade_lock(BOOST_RV_REF(upgrade_lock) other): m(other.m),is_locked(other.is_locked) { other.is_locked=false; other.m=0; } - upgrade_lock(unique_lock&& other): + upgrade_lock(BOOST_RV_REF(unique_lock) other): m(other.m),is_locked(other.is_locked) { if(is_locked) @@ -772,63 +665,19 @@ other.m=0; } - upgrade_lock& operator=(upgrade_lock&& other) + upgrade_lock& operator=(BOOST_RV_REF(upgrade_lock) other) { - upgrade_lock temp(static_cast&&>(other)); + upgrade_lock temp(boost::move(other)); swap(temp); return *this; } - upgrade_lock& operator=(unique_lock&& other) + upgrade_lock& operator=(BOOST_RV_REF(unique_lock) other) { - upgrade_lock temp(static_cast&&>(other)); + upgrade_lock temp(boost::move(other)); swap(temp); return *this; } -#else - upgrade_lock(detail::thread_move_t > other): - m(other->m),is_locked(other->is_locked) - { - other->is_locked=false; - other->m=0; - } - - upgrade_lock(detail::thread_move_t > other): - m(other->m),is_locked(other->is_locked) - { - if(is_locked) - { - m->unlock_and_lock_upgrade(); - } - other->is_locked=false; - other->m=0; - } - - operator detail::thread_move_t >() - { - return move(); - } - - detail::thread_move_t > move() - { - return detail::thread_move_t >(*this); - } - - - upgrade_lock& operator=(detail::thread_move_t > other) - { - upgrade_lock temp(other); - swap(temp); - return *this; - } - - upgrade_lock& operator=(detail::thread_move_t > other) - { - upgrade_lock temp(other); - swap(temp); - return *this; - } -#endif void swap(upgrade_lock& other) { @@ -888,10 +737,8 @@ friend class unique_lock; }; - -#ifndef BOOST_NO_RVALUE_REFERENCES template - unique_lock::unique_lock(upgrade_lock&& other): + unique_lock::unique_lock(BOOST_RV_REF(upgrade_lock) other): m(other.m),is_locked(other.is_locked) { other.is_locked=false; @@ -900,18 +747,7 @@ m->unlock_upgrade_and_lock(); } } -#else - template - unique_lock::unique_lock(detail::thread_move_t > other): - m(other->m),is_locked(other->is_locked) - { - other->is_locked=false; - if(is_locked) - { - m->unlock_upgrade_and_lock(); - } - } -#endif + template class upgrade_to_unique_lock { @@ -919,47 +755,32 @@ upgrade_lock* source; unique_lock exclusive; - explicit upgrade_to_unique_lock(upgrade_to_unique_lock&); - upgrade_to_unique_lock& operator=(upgrade_to_unique_lock&); + BOOST_MOVABLE_BUT_NOT_COPYABLE(upgrade_to_unique_lock) public: explicit upgrade_to_unique_lock(upgrade_lock& m_): - source(&m_),exclusive(move(*source)) + source(&m_),exclusive(boost::move(*source)) {} ~upgrade_to_unique_lock() { if(source) { - *source=move(exclusive); + *source=boost::move(exclusive); } } -#ifdef BOOST_HAS_RVALUE_REFS - upgrade_to_unique_lock(upgrade_to_unique_lock&& other): - source(other.source),exclusive(move(other.exclusive)) + upgrade_to_unique_lock(BOOST_RV_REF(upgrade_to_unique_lock) other): + source(other.source),exclusive(boost::move(other.exclusive)) { other.source=0; } - upgrade_to_unique_lock& operator=(upgrade_to_unique_lock&& other) - { - upgrade_to_unique_lock temp(other); - swap(temp); - return *this; - } -#else - upgrade_to_unique_lock(detail::thread_move_t > other): - source(other->source),exclusive(move(other->exclusive)) - { - other->source=0; - } - - upgrade_to_unique_lock& operator=(detail::thread_move_t > other) + upgrade_to_unique_lock& operator=(BOOST_RV_REF(upgrade_to_unique_lock) other) { upgrade_to_unique_lock temp(other); swap(temp); return *this; } -#endif + void swap(upgrade_to_unique_lock& other) { std::swap(source,other.source); @@ -986,6 +807,7 @@ class try_lock_wrapper: private unique_lock { + BOOST_MOVABLE_BUT_NOT_COPYABLE(try_lock_wrapper) typedef unique_lock base; public: try_lock_wrapper() @@ -1004,54 +826,23 @@ try_lock_wrapper(Mutex& m_,try_to_lock_t): base(m_,try_to_lock) {} -#ifndef BOOST_NO_RVALUE_REFERENCES - try_lock_wrapper(try_lock_wrapper&& other): - base(other.move()) - {} - try_lock_wrapper&& move() - { - return static_cast(*this); - } - - try_lock_wrapper& operator=(try_lock_wrapper&& other) + try_lock_wrapper(BOOST_RV_REF(try_lock_wrapper) other): + base(boost::move(static_cast(other))) + {} + + try_lock_wrapper& operator=(BOOST_RV_REF(try_lock_wrapper) other) { try_lock_wrapper temp(other.move()); swap(temp); return *this; } - void swap(try_lock_wrapper&& other) + void swap(BOOST_RV_REF(try_lock_wrapper) other) { base::swap(other); } -#else - try_lock_wrapper(detail::thread_move_t > other): - base(detail::thread_move_t(*other)) - {} - - operator detail::thread_move_t >() - { - return move(); - } - - detail::thread_move_t > move() - { - return detail::thread_move_t >(*this); - } - - try_lock_wrapper& operator=(detail::thread_move_t > other) - { - try_lock_wrapper temp(other); - swap(temp); - return *this; - } - void swap(detail::thread_move_t > other) - { - base::swap(*other); - } -#endif void swap(try_lock_wrapper& other) { base::swap(other); @@ -1092,19 +883,11 @@ } }; -#ifndef BOOST_NO_RVALUE_REFERENCES template - void swap(try_lock_wrapper&& lhs,try_lock_wrapper&& rhs) + void swap(BOOST_RV_REF(try_lock_wrapper) lhs,BOOST_RV_REF(try_lock_wrapper) rhs) { lhs.swap(rhs); } -#else - template - void swap(try_lock_wrapper& lhs,try_lock_wrapper& rhs) - { - lhs.swap(rhs); - } -#endif template unsigned try_lock_internal(MutexType1& m1,MutexType2& m2)