Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r49112 - in trunk: boost/thread/detail libs/thread/test
From: anthony_at_[hidden]
Date: 2008-10-02 12:39:04


Author: anthonyw
Date: 2008-10-02 12:39:03 EDT (Thu, 02 Oct 2008)
New Revision: 49112
URL: http://svn.boost.org/trac/boost/changeset/49112

Log:
Test and fix for trac issue #2380: return boost::move(some_thread) now works
Text files modified:
   trunk/boost/thread/detail/move.hpp | 4 ++--
   trunk/boost/thread/detail/thread.hpp | 4 ++--
   trunk/libs/thread/test/test_thread_move.cpp | 13 +++++++++++++
   3 files changed, 17 insertions(+), 4 deletions(-)

Modified: trunk/boost/thread/detail/move.hpp
==============================================================================
--- trunk/boost/thread/detail/move.hpp (original)
+++ trunk/boost/thread/detail/move.hpp 2008-10-02 12:39:03 EDT (Thu, 02 Oct 2008)
@@ -41,9 +41,9 @@
 
 #ifndef BOOST_NO_SFINAE
     template<typename T>
- typename enable_if<boost::is_convertible<T&,detail::thread_move_t<T> >, detail::thread_move_t<T> >::type move(T& t)
+ typename enable_if<boost::is_convertible<T&,detail::thread_move_t<T> >, T >::type move(T& t)
     {
- return t;
+ return T(detail::thread_move_t<T>(t));
     }
 #endif
     

Modified: trunk/boost/thread/detail/thread.hpp
==============================================================================
--- trunk/boost/thread/detail/thread.hpp (original)
+++ trunk/boost/thread/detail/thread.hpp 2008-10-02 12:39:03 EDT (Thu, 02 Oct 2008)
@@ -339,9 +339,9 @@
         return t;
     }
 #else
- inline detail::thread_move_t<thread> move(detail::thread_move_t<thread> t)
+ inline thread move(detail::thread_move_t<thread> t)
     {
- return t;
+ return thread(t);
     }
 #endif
 

Modified: trunk/libs/thread/test/test_thread_move.cpp
==============================================================================
--- trunk/libs/thread/test/test_thread_move.cpp (original)
+++ trunk/libs/thread/test/test_thread_move.cpp 2008-10-02 12:39:03 EDT (Thu, 02 Oct 2008)
@@ -25,6 +25,18 @@
     x.join();
 }
 
+boost::thread make_thread_return_lvalue()
+{
+ boost::thread t(do_nothing);
+ return boost::move(t);
+}
+
+void test_move_from_function_return_lvalue()
+{
+ boost::thread x=make_thread_return_lvalue();
+ x.join();
+}
+
 
 boost::unit_test_framework::test_suite* init_unit_test_suite(int, char*[])
 {
@@ -33,5 +45,6 @@
 
     test->add(BOOST_TEST_CASE(test_move_on_construction));
     test->add(BOOST_TEST_CASE(test_move_from_function_return));
+ test->add(BOOST_TEST_CASE(test_move_from_function_return_lvalue));
     return test;
 }


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