Ticket #6174: detail_thread.hpp.diff
File detail_thread.hpp.diff, 3.3 KB (added by , 11 years ago) |
---|
-
detail/thread.hpp
25 25 #include <boost/utility/enable_if.hpp> 26 26 #include <boost/type_traits/remove_reference.hpp> 27 27 #include <boost/io/ios_state.hpp> 28 #include <boost/type_traits/is_same.hpp> 29 #include <boost/type_traits/decay.hpp> 28 30 29 31 #include <boost/config/abi_prefix.hpp> 30 32 … … 37 39 { 38 40 namespace detail 39 41 { 42 43 #ifndef BOOST_NO_RVALUE_REFERENCES 44 45 template <typename F> 46 F&& forward(typename boost::remove_reference<F>::type& f) 47 { 48 return static_cast<F&&>(f); 49 } 50 template <typename F> 51 F&& forward(typename boost::remove_reference<F>::type&& f) 52 { 53 return static_cast<F&&>(f); 54 } 55 56 template <class T> 57 typename decay<T>::type 58 decay_copy(T&& t) 59 { 60 return forward<T>(t); 61 } 62 63 #endif 64 65 66 67 68 40 69 template<typename F> 41 70 class thread_data: 42 71 public detail::thread_data_base … … 44 73 public: 45 74 #ifndef BOOST_NO_RVALUE_REFERENCES 46 75 thread_data(F&& f_): 47 f(static_cast<F&&>(f_)) 76 //f(static_cast<F&&>(f_)) 77 f(detail::forward<F>(f_)) 48 78 {} 49 thread_data(F& f_): 50 f(f_) 51 {} 79 // This overloading must be removed if we want the packaged_task's tests to pass. 80 // thread_data(F& f_): 81 // f(f_) 82 // {} 52 83 #else 53 84 thread_data(F f_): 54 85 f(f_) … … 128 159 template<typename F> 129 160 static inline detail::thread_data_ptr make_thread_info(F&& f) 130 161 { 131 return detail::thread_data_ptr(detail::heap_new<detail::thread_data<typename boost::remove_reference<F>::type> >(static_cast<F&&>(f))); 162 //return detail::thread_data_ptr(detail::heap_new<detail::thread_data<typename boost::remove_reference<F>::type> >(static_cast<F&&>(f))); 163 return detail::thread_data_ptr(detail::heap_new<detail::thread_data<typename boost::remove_reference<F>::type> >( 164 detail::forward<F>(f))); 132 165 } 133 166 static inline detail::thread_data_ptr make_thread_info(void (*f)()) 134 167 { 135 return detail::thread_data_ptr(detail::heap_new<detail::thread_data<void(*)()> >(static_cast<void(*&&)()>(f))); 168 //return detail::thread_data_ptr(detail::heap_new<detail::thread_data<void(*)()> >(static_cast<void(*&&)()>(f))); 169 return detail::thread_data_ptr(detail::heap_new<detail::thread_data<void(*)()> >( 170 detail::forward<void(*)()>(f))); 136 171 } 137 172 #else 138 173 template<typename F> … … 164 199 start_thread(); 165 200 } 166 201 #else 167 template <class F> 168 thread(F&& f): 169 thread_info(make_thread_info(static_cast<F&&>(f))) 202 template < 203 class F, 204 class Dummy = typename disable_if< is_same<typename decay<F>::type, thread> >::type 205 > 206 explicit thread(F&& f): 207 //thread_info(make_thread_info(static_cast<F&&>(f))) 208 thread_info(make_thread_info(detail::decay_copy(detail::forward<F>(f)))) 170 209 { 171 210 start_thread(); 172 211 }