From 886c6a645f451ddb56df609c2bb6fe7388045f3e Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Mon, 7 Apr 2014 13:32:26 +0000 Subject: [PATCH] Fix PR19819 llvm-svn: 205709 --- libcxx/include/future | 4 ++-- .../futures.task.members/ctor_func.pass.cpp | 16 +++++++++++++ .../futures.task.members/ctor_func_alloc.pass.cpp | 28 +++++++++++++++++++++- 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/libcxx/include/future b/libcxx/include/future index 73d5456..de00f25 100644 --- a/libcxx/include/future +++ b/libcxx/include/future @@ -1872,7 +1872,7 @@ template __packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function(_Fp&& __f) : __f_(nullptr) { - typedef typename remove_reference<_Fp>::type _FR; + typedef typename remove_reference::type>::type _FR; typedef __packaged_task_func<_FR, allocator<_FR>, _Rp(_ArgTypes...)> _FF; if (sizeof(_FF) <= sizeof(__buf_)) { @@ -1897,7 +1897,7 @@ __packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function( : __f_(nullptr) { typedef allocator_traits<_Alloc> __alloc_traits; - typedef typename remove_reference<_Fp>::type _FR; + typedef typename remove_reference::type>::type _FR; typedef __packaged_task_func<_FR, _Alloc, _Rp(_ArgTypes...)> _FF; if (sizeof(_FF) <= sizeof(__buf_)) { diff --git a/libcxx/test/thread/futures/futures.tas/futures.task.members/ctor_func.pass.cpp b/libcxx/test/thread/futures/futures.tas/futures.task.members/ctor_func.pass.cpp index 7009f30..58e9982 100644 --- a/libcxx/test/thread/futures/futures.tas/futures.task.members/ctor_func.pass.cpp +++ b/libcxx/test/thread/futures/futures.tas/futures.task.members/ctor_func.pass.cpp @@ -35,6 +35,8 @@ public: int A::n_moves = 0; int A::n_copies = 0; +int func(int i) { return i; } + int main() { { @@ -58,4 +60,18 @@ int main() assert(A::n_copies > 0); assert(A::n_moves > 0); } + { + std::packaged_task p(&func); + assert(p.valid()); + std::future f = p.get_future(); + p(4); + assert(f.get() == 4); + } + { + std::packaged_task p(func); + assert(p.valid()); + std::future f = p.get_future(); + p(4); + assert(f.get() == 4); + } } diff --git a/libcxx/test/thread/futures/futures.tas/futures.task.members/ctor_func_alloc.pass.cpp b/libcxx/test/thread/futures/futures.tas/futures.task.members/ctor_func_alloc.pass.cpp index 2e0cf5d..e7070c5 100644 --- a/libcxx/test/thread/futures/futures.tas/futures.task.members/ctor_func_alloc.pass.cpp +++ b/libcxx/test/thread/futures/futures.tas/futures.task.members/ctor_func_alloc.pass.cpp @@ -37,6 +37,8 @@ public: int A::n_moves = 0; int A::n_copies = 0; +int func(int i) { return i; } + int main() { { @@ -52,7 +54,7 @@ int main() } assert(test_alloc_base::count == 0); A::n_copies = 0; - A::n_copies = 0; + A::n_moves = 0; { A a(5); std::packaged_task p(std::allocator_arg, @@ -66,4 +68,28 @@ int main() assert(A::n_moves > 0); } assert(test_alloc_base::count == 0); + A::n_copies = 0; + A::n_moves = 0; + { + A a(5); + std::packaged_task p(std::allocator_arg, test_allocator(), &func); + assert(test_alloc_base::count > 0); + assert(p.valid()); + std::future f = p.get_future(); + p(4); + assert(f.get() == 4); + } + assert(test_alloc_base::count == 0); + A::n_copies = 0; + A::n_moves = 0; + { + A a(5); + std::packaged_task p(std::allocator_arg, test_allocator(), func); + assert(test_alloc_base::count > 0); + assert(p.valid()); + std::future f = p.get_future(); + p(4); + assert(f.get() == 4); + } + assert(test_alloc_base::count == 0); } -- 2.7.4