Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r77875 - trunk/boost/thread
From: vicente.botet_at_[hidden]
Date: 2012-04-09 20:14:13


Author: viboes
Date: 2012-04-09 20:14:12 EDT (Mon, 09 Apr 2012)
New Revision: 77875
URL: http://svn.boost.org/trac/boost/changeset/77875

Log:
Thread: Fix packaged_task callable copy
Text files modified:
   trunk/boost/thread/future.hpp | 28 +++++++++++++++-------------
   1 files changed, 15 insertions(+), 13 deletions(-)

Modified: trunk/boost/thread/future.hpp
==============================================================================
--- trunk/boost/thread/future.hpp (original)
+++ trunk/boost/thread/future.hpp 2012-04-09 20:14:12 EDT (Mon, 09 Apr 2012)
@@ -19,6 +19,7 @@
 #include <boost/scoped_ptr.hpp>
 #include <boost/type_traits/is_fundamental.hpp>
 #include <boost/type_traits/is_convertible.hpp>
+#include <boost/type_traits/remove_reference.hpp>
 #include <boost/mpl/if.hpp>
 #include <boost/config.hpp>
 #include <boost/throw_exception.hpp>
@@ -1807,16 +1808,16 @@
         explicit packaged_task(R(*f)()):
             task(new detail::task_object<R,R(*)()>(f)),future_obtained(false)
         {}
- template <class F>
- explicit packaged_task(F const& f):
- task(new detail::task_object<R,F>(f)),future_obtained(false)
- {}
 #ifndef BOOST_NO_RVALUE_REFERENCES
         template <class F>
         explicit packaged_task(F&& f):
- task(new detail::task_object<R,F>(boost::forward<F>(f))),future_obtained(false)
+ task(new detail::task_object<R,typename remove_reference<F>::type>(boost::forward<F>(f))),future_obtained(false)
         {}
 #else
+ template <class F>
+ explicit packaged_task(F const& f):
+ task(new detail::task_object<R,F>(f)),future_obtained(false)
+ {}
 #if defined BOOST_THREAD_USES_MOVE
         template <class F>
         explicit packaged_task(boost::rv<F>& f):
@@ -1831,29 +1832,30 @@
 #endif
 
 #if defined BOOST_THREAD_PROVIDES_FUTURE_CTOR_ALLOCATORS
+#ifndef BOOST_NO_RVALUE_REFERENCES
         template <class F, class Allocator>
- packaged_task(boost::allocator_arg_t, Allocator a, const F& f)
+ packaged_task(boost::allocator_arg_t, Allocator a, F&& f)
         {
- typedef typename Allocator::template rebind<detail::task_object<R,F> >::other A2;
+ typedef typename remove_reference<F>::type FR;
+ typedef typename Allocator::template rebind<detail::task_object<R,FR> >::other A2;
           A2 a2(a);
           typedef thread_detail::allocator_destructor<A2> D;
 
- task = task_ptr(::new(a2.allocate(1)) detail::task_object<R,F>(f), D(a2, 1) );
- std::cout << __FILE__ ":"<<__LINE__<<std::endl;
+ task = task_ptr(::new(a2.allocate(1)) detail::task_object<R,FR>(boost::forward<F>(f)), D(a2, 1) );
           future_obtained = false;
         }
-#ifndef BOOST_NO_RVALUE_REFERENCES
+#else
         template <class F, class Allocator>
- packaged_task(boost::allocator_arg_t, Allocator a, F&& f)
+ packaged_task(boost::allocator_arg_t, Allocator a, const F& f)
         {
           typedef typename Allocator::template rebind<detail::task_object<R,F> >::other A2;
           A2 a2(a);
           typedef thread_detail::allocator_destructor<A2> D;
 
- task = task_ptr(::new(a2.allocate(1)) detail::task_object<R,F>(boost::forward<F>(f)), D(a2, 1) );
+ task = task_ptr(::new(a2.allocate(1)) detail::task_object<R,F>(f), D(a2, 1) );
+ std::cout << __FILE__ ":"<<__LINE__<<std::endl;
           future_obtained = false;
         }
-#else
 #if defined BOOST_THREAD_USES_MOVE
         template <class F, class Allocator>
         packaged_task(boost::allocator_arg_t, Allocator a, boost::rv<F>& f)


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk