Skip to content

Commit

Permalink
[libcxx] Constrain function assignment operator (2574).
Browse files Browse the repository at this point in the history
This patch fixes LWG issue 2574.

Differential Review: https://reviews.llvm.org/D62928
  • Loading branch information
zoecarver committed May 13, 2020
1 parent 96282b1 commit 8aa2266
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion libcxx/include/functional
Expand Up @@ -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();
Expand Down
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion libcxx/www/cxx1z_status.html
Expand Up @@ -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>&sect;[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&amp;&amp;)</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&amp;&amp;)</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>
Expand Down

0 comments on commit 8aa2266

Please sign in to comment.