[libcxx] r205709 - Fix PR19819

Marshall Clow mclow.lists at gmail.com
Mon Apr 7 06:32:26 PDT 2014


Author: marshall
Date: Mon Apr  7 08:32:26 2014
New Revision: 205709

URL: http://llvm.org/viewvc/llvm-project?rev=205709&view=rev
Log:
Fix PR19819

Modified:
    libcxx/trunk/include/future
    libcxx/trunk/test/thread/futures/futures.tas/futures.task.members/ctor_func.pass.cpp
    libcxx/trunk/test/thread/futures/futures.tas/futures.task.members/ctor_func_alloc.pass.cpp

Modified: libcxx/trunk/include/future
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/future?rev=205709&r1=205708&r2=205709&view=diff
==============================================================================
--- libcxx/trunk/include/future (original)
+++ libcxx/trunk/include/future Mon Apr  7 08:32:26 2014
@@ -1872,7 +1872,7 @@ template <class _Fp>
 __packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function(_Fp&& __f)
     : __f_(nullptr)
 {
-    typedef typename remove_reference<_Fp>::type _FR;
+    typedef typename remove_reference<typename decay<_Fp>::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..
     : __f_(nullptr)
 {
     typedef allocator_traits<_Alloc> __alloc_traits;
-    typedef typename remove_reference<_Fp>::type _FR;
+    typedef typename remove_reference<typename decay<_Fp>::type>::type _FR;
     typedef __packaged_task_func<_FR, _Alloc, _Rp(_ArgTypes...)> _FF;
     if (sizeof(_FF) <= sizeof(__buf_))
     {

Modified: libcxx/trunk/test/thread/futures/futures.tas/futures.task.members/ctor_func.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/thread/futures/futures.tas/futures.task.members/ctor_func.pass.cpp?rev=205709&r1=205708&r2=205709&view=diff
==============================================================================
--- libcxx/trunk/test/thread/futures/futures.tas/futures.task.members/ctor_func.pass.cpp (original)
+++ libcxx/trunk/test/thread/futures/futures.tas/futures.task.members/ctor_func.pass.cpp Mon Apr  7 08:32:26 2014
@@ -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<int(int)> p(&func);
+        assert(p.valid());
+        std::future<int> f = p.get_future();
+        p(4);
+        assert(f.get() == 4);
+    }
+    {
+        std::packaged_task<int(int)> p(func);
+        assert(p.valid());
+        std::future<int> f = p.get_future();
+        p(4);
+        assert(f.get() == 4);
+    }
 }

Modified: libcxx/trunk/test/thread/futures/futures.tas/futures.task.members/ctor_func_alloc.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/thread/futures/futures.tas/futures.task.members/ctor_func_alloc.pass.cpp?rev=205709&r1=205708&r2=205709&view=diff
==============================================================================
--- libcxx/trunk/test/thread/futures/futures.tas/futures.task.members/ctor_func_alloc.pass.cpp (original)
+++ libcxx/trunk/test/thread/futures/futures.tas/futures.task.members/ctor_func_alloc.pass.cpp Mon Apr  7 08:32:26 2014
@@ -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<double(int, char)> 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<int(int)> p(std::allocator_arg, test_allocator<A>(), &func);
+        assert(test_alloc_base::count > 0);
+        assert(p.valid());
+        std::future<int> 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<int(int)> p(std::allocator_arg, test_allocator<A>(), func);
+        assert(test_alloc_base::count > 0);
+        assert(p.valid());
+        std::future<int> f = p.get_future();
+        p(4);
+        assert(f.get() == 4);
+    }
+    assert(test_alloc_base::count == 0);
 }





More information about the cfe-commits mailing list