|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r77876 - in trunk/libs/thread/test: . sync/futures/packaged_task
From: vicente.botet_at_[hidden]
Date: 2012-04-09 20:24:08
Author: viboes
Date: 2012-04-09 20:24:07 EDT (Mon, 09 Apr 2012)
New Revision: 77876
URL: http://svn.boost.org/trac/boost/changeset/77876
Log:
Thread: Added pt func_ctor test + update some test to pass Sun compiler regression
Text files modified:
trunk/libs/thread/test/Jamfile.v2 | 1
trunk/libs/thread/test/sync/futures/packaged_task/func_ctor_pass.cpp | 54 ++++++++++++++++++++++++++++++++++++---
trunk/libs/thread/test/sync/futures/packaged_task/move_ctor_pass.cpp | 2
trunk/libs/thread/test/sync/futures/packaged_task/non_member_swap_pass.cpp | 2
4 files changed, 52 insertions(+), 7 deletions(-)
Modified: trunk/libs/thread/test/Jamfile.v2
==============================================================================
--- trunk/libs/thread/test/Jamfile.v2 (original)
+++ trunk/libs/thread/test/Jamfile.v2 2012-04-09 20:24:07 EDT (Mon, 09 Apr 2012)
@@ -243,6 +243,7 @@
[ thread-compile-fail-V2 ./sync/futures/packaged_task/copy_assign_fail.cpp : : packaged_task__copy_assign_f ]
[ thread-compile-fail-V2 ./sync/futures/packaged_task/copy_ctor_fail.cpp : : packaged_task__copy_ctor_f ]
[ thread-run2 ./sync/futures/packaged_task/default_ctor_pass.cpp : packaged_task__default_ctor_p ]
+ [ thread-run2 ./sync/futures/packaged_task/func_ctor_pass.cpp : packaged_task__func_ctor_p ]
#[ thread-run2 ./sync/futures/packaged_task/dtor_pass.cpp : packaged_task__dtor_p ]
[ thread-run2 ./sync/futures/packaged_task/get_future_pass.cpp : packaged_task__get_future_p ]
[ thread-run2 ./sync/futures/packaged_task/move_ctor_pass.cpp : packaged_task__move_ctor_p ]
Modified: trunk/libs/thread/test/sync/futures/packaged_task/func_ctor_pass.cpp
==============================================================================
--- trunk/libs/thread/test/sync/futures/packaged_task/func_ctor_pass.cpp (original)
+++ trunk/libs/thread/test/sync/futures/packaged_task/func_ctor_pass.cpp 2012-04-09 20:24:07 EDT (Mon, 09 Apr 2012)
@@ -32,8 +32,52 @@
static int n_copies;
explicit A(long i) : data_(i) {}
- A(A&& a) : data_(a.data_) {++n_moves; a.data_ = -1;}
- A(const A& a) : data_(a.data_) {++n_copies;}
+#ifndef BOOST_NO_RVALUE_REFERENCES
+ A(A&& a) : data_(a.data_)
+ {
+ ++n_moves; a.data_ = -1;
+ }
+#else
+
+#if defined BOOST_THREAD_USES_MOVE
+ operator ::boost::rv<A>&()
+ {
+ return *static_cast< ::boost::rv<A>* >(this);
+ }
+ operator const ::boost::rv<A>&() const
+ {
+ return *static_cast<const ::boost::rv<A>* >(this);
+ }
+ ::boost::rv<A>& move()
+ {
+ return *static_cast< ::boost::rv<A>* >(this);
+ }
+ const ::boost::rv<A>& move() const
+ {
+ return *static_cast<const ::boost::rv<A>* >(this);
+ }
+
+ A(boost::rv<A>& a) : data_(a.data_)
+ {
+ ++n_moves; a.data_ = -1;
+ }
+#else
+ operator boost::detail::thread_move_t<A>()
+ {
+ return boost::detail::thread_move_t<A>(*this);
+ }
+ boost::detail::thread_move_t<A> move()
+ {
+ return boost::detail::thread_move_t<A>(*this);
+ }
+ A(boost::detail::thread_move_t<A> a) : data_(a.data_)
+ {
+ ++n_moves; a.data_ = -1;
+ }
+
+#endif
+#endif
+ A(const A& a) : data_(a.data_) {++n_copies;}
long operator()() const {return data_;}
long operator()(long i, long j) const {return data_ + i + j;}
@@ -46,12 +90,12 @@
int main()
{
{
- boost::packaged_task<double> p(A(5));
+ boost::packaged_task<double> p(BOOST_EXPLICIT_MOVE(A(5)));
BOOST_TEST(p.valid());
boost::future<double> f = BOOST_EXPLICIT_MOVE(p.get_future());
//p(3, 'a');
p();
- BOOST_TEST(f.get() == 105.0);
+ BOOST_TEST(f.get() == 5.0);
BOOST_TEST(A::n_copies == 0);
BOOST_TEST(A::n_moves > 0);
}
@@ -64,7 +108,7 @@
boost::future<double> f = BOOST_EXPLICIT_MOVE(p.get_future());
//p(3, 'a');
p();
- BOOST_TEST(f.get() == 105.0);
+ BOOST_TEST(f.get() == 5.0);
BOOST_TEST(A::n_copies > 0);
BOOST_TEST(A::n_moves > 0);
}
Modified: trunk/libs/thread/test/sync/futures/packaged_task/move_ctor_pass.cpp
==============================================================================
--- trunk/libs/thread/test/sync/futures/packaged_task/move_ctor_pass.cpp (original)
+++ trunk/libs/thread/test/sync/futures/packaged_task/move_ctor_pass.cpp 2012-04-09 20:24:07 EDT (Mon, 09 Apr 2012)
@@ -42,7 +42,7 @@
boost::packaged_task<double> p = boost::move(p0);
BOOST_TEST(!p0.valid());
BOOST_TEST(p.valid());
- boost::future<double> f = p.get_future();
+ boost::future<double> f = BOOST_EXPLICIT_MOVE(p.get_future());
//p(3, 'a');
p();
BOOST_TEST(f.get() == 5.0);
Modified: trunk/libs/thread/test/sync/futures/packaged_task/non_member_swap_pass.cpp
==============================================================================
--- trunk/libs/thread/test/sync/futures/packaged_task/non_member_swap_pass.cpp (original)
+++ trunk/libs/thread/test/sync/futures/packaged_task/non_member_swap_pass.cpp 2012-04-09 20:24:07 EDT (Mon, 09 Apr 2012)
@@ -42,7 +42,7 @@
p.swap(p0);
BOOST_TEST(!p0.valid());
BOOST_TEST(p.valid());
- boost::future<double> f = p.get_future();
+ boost::future<double> f = BOOST_EXPLICIT_MOVE(p.get_future());
//p(3, 'a');
p();
BOOST_TEST(f.get() == 5.0);
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