[libcxx-commits] [libcxx] 8aa2266 - [libcxx] Constrain function assignment operator (2574).

via libcxx-commits libcxx-commits at lists.llvm.org
Tue May 12 18:58:04 PDT 2020


Author: zoecarver
Date: 2020-05-12T18:57:50-07:00
New Revision: 8aa2266fd8dd237c84daf12c2eec0df244558f49

URL: https://github.com/llvm/llvm-project/commit/8aa2266fd8dd237c84daf12c2eec0df244558f49
DIFF: https://github.com/llvm/llvm-project/commit/8aa2266fd8dd237c84daf12c2eec0df244558f49.diff

LOG: [libcxx] Constrain function assignment operator (2574).

This patch fixes LWG issue 2574.

Differential Review: https://reviews.llvm.org/D62928

Added: 
    

Modified: 
    libcxx/include/functional
    libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp
    libcxx/www/cxx1z_status.html

Removed: 
    


################################################################################
diff  --git a/libcxx/include/functional b/libcxx/include/functional
index fa55864bc5d6..9d1548583930 100644
--- a/libcxx/include/functional
+++ b/libcxx/include/functional
@@ -2387,7 +2387,7 @@ public:
     function& operator=(const function&);
     function& operator=(function&&) _NOEXCEPT;
     function& operator=(nullptr_t) _NOEXCEPT;
-    template<class _Fp, class = _EnableIfCallable<_Fp>>
+    template<class _Fp, class = _EnableIfCallable<typename decay<_Fp>::type>>
     function& operator=(_Fp&&);
 
     ~function();

diff  --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp
index a2458414b048..4fc7bcfc4871 100644
--- a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp
@@ -118,6 +118,26 @@ int main(int, char**)
         static_assert(!std::is_assignable<Fn&, RValueCallable&>::value, "");
         static_assert(!std::is_assignable<Fn&, RValueCallable>::value, "");
     }
+    {
+        using Fn = std::function<void(int, int, int)>;
+        static_assert(std::is_assignable<Fn&, Fn&&>::value, "");
+    }
+    {
+        using F1 = std::function<void(int, int)>;
+        using F2 = std::function<void(int, int, int)>;
+        static_assert(!std::is_assignable<F1&, F2&&>::value, "");
+    }
+    {
+        using F1 = std::function<int(int, int)>;
+        using F2 = std::function<A  (int, int)>;
+        static_assert(!std::is_assignable<F1&, F2&&>::value, "");
+        static_assert(!std::is_assignable<F2&, F1&&>::value, "");
+    }
+    {
+        using F1 = std::function<void(int, int)>;
+        using F2 = std::function<void(int, int)&&>;
+        static_assert(!std::is_assignable<F1&, F2&&>::value, "");
+    }
 #endif
 
   return 0;

diff  --git a/libcxx/www/cxx1z_status.html b/libcxx/www/cxx1z_status.html
index 83aedb96bdb7..c8b3374ba42e 100644
--- a/libcxx/www/cxx1z_status.html
+++ b/libcxx/www/cxx1z_status.html
@@ -299,7 +299,7 @@ <h3>Library Working group Issues Status</h3>
 	<tr><td><a href="https://wg21.link/LWG2566">2566</a></td><td>Requirements on the first template parameter of container adaptors</td><td>Jacksonville</td><td>Complete</td></tr>
 	<tr><td><a href="https://wg21.link/LWG2571">2571</a></td><td>§[map.modifiers]/2 imposes nonsensical requirement on <tt>insert(InputIterator, InputIterator)</tt></td><td>Jacksonville</td><td>Complete</td></tr>
 	<tr><td><a href="https://wg21.link/LWG2572">2572</a></td><td>The remarks for <tt>shared_ptr::operator*</tt> should apply to <i>cv</i>-qualified <tt>void</tt> as well</td><td>Jacksonville</td><td>Complete</td></tr>
-	<tr><td><a href="https://wg21.link/LWG2574">2574</a></td><td>[fund.ts.v2] <tt>std::experimental::function::operator=(F&&)</tt> should be constrained</td><td>Jacksonville</td><td></td></tr>
+	<tr><td><a href="https://wg21.link/LWG2574">2574</a></td><td>[fund.ts.v2] <tt>std::experimental::function::operator=(F&&)</tt> should be constrained</td><td>Jacksonville</td><td>Complete</td></tr>
 	<tr><td><a href="https://wg21.link/LWG2575">2575</a></td><td>[fund.ts.v2] <tt>experimental::function::assign</tt> should be removed</td><td>Jacksonville</td><td></td></tr>
 	<tr><td><a href="https://wg21.link/LWG2576">2576</a></td><td><tt>istream_iterator</tt> and <tt>ostream_iterator</tt> should use <tt>std::addressof</tt></td><td>Jacksonville</td><td>Complete</td></tr>
 	<tr><td><a href="https://wg21.link/LWG2577">2577</a></td><td><tt>{shared,unique}_lock</tt> should use <tt>std::addressof</tt></td><td>Jacksonville</td><td>Complete</td></tr>


        


More information about the libcxx-commits mailing list