Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LWG-2774 std::function construction vs assignment #2098

Merged
merged 12 commits into from
Dec 17, 2021
26 changes: 13 additions & 13 deletions stl/inc/functional
Original file line number Diff line number Diff line change
Expand Up @@ -886,9 +886,9 @@ public:

protected:
template <class _Fx, class _Function>
using _Enable_if_callable_t =
enable_if_t<conjunction_v<negation<is_same<decay_t<_Fx>, _Function>>, _Is_invocable_r<_Ret, _Fx, _Types...>>,
int>;
using _Enable_if_callable_t = enable_if_t<conjunction_v<negation<is_same<_Remove_cvref_t<_Fx>, _Function>>,
_Is_invocable_r<_Ret, decay_t<_Fx>&, _Types...>>,
int>;

bool _Empty() const noexcept {
return !_Getimpl();
Expand Down Expand Up @@ -1045,12 +1045,12 @@ public:
}

#if _USE_FUNCTION_INT_0_SFINAE
template <class _Fx, typename _Mybase::template _Enable_if_callable_t<_Fx&, function> = 0>
template <class _Fx, typename _Mybase::template _Enable_if_callable_t<_Fx, function> = 0>
#else // ^^^ _USE_FUNCTION_INT_0_SFINAE // !_USE_FUNCTION_INT_0_SFINAE vvv
template <class _Fx, class = typename _Mybase::template _Enable_if_callable_t<_Fx&, function>>
template <class _Fx, class = typename _Mybase::template _Enable_if_callable_t<_Fx, function>>
#endif // _USE_FUNCTION_INT_0_SFINAE
function(_Fx _Func) {
this->_Reset(_STD move(_Func));
function(_Fx&& _Func) {
this->_Reset(_STD forward<_Fx>(_Func));
}

#if _HAS_FUNCTION_ALLOCATOR_SUPPORT
Expand All @@ -1066,12 +1066,12 @@ public:
}

#if _USE_FUNCTION_INT_0_SFINAE
template <class _Fx, class _Alloc, typename _Mybase::template _Enable_if_callable_t<_Fx&, function> = 0>
template <class _Fx, class _Alloc, typename _Mybase::template _Enable_if_callable_t<_Fx, function> = 0>
#else // ^^^ _USE_FUNCTION_INT_0_SFINAE // !_USE_FUNCTION_INT_0_SFINAE vvv
template <class _Fx, class _Alloc, class = typename _Mybase::template _Enable_if_callable_t<_Fx&, function>>
template <class _Fx, class _Alloc, class = typename _Mybase::template _Enable_if_callable_t<_Fx, function>>
#endif // _USE_FUNCTION_INT_0_SFINAE
function(allocator_arg_t, const _Alloc& _Ax, _Fx _Func) {
this->_Reset_alloc(_STD move(_Func), _Ax);
function(allocator_arg_t, const _Alloc& _Ax, _Fx&& _Func) {
this->_Reset_alloc(_STD forward<_Fx>(_Func), _Ax);
}
#endif // _HAS_FUNCTION_ALLOCATOR_SUPPORT

Expand Down Expand Up @@ -1100,9 +1100,9 @@ public:
}

#if _USE_FUNCTION_INT_0_SFINAE
template <class _Fx, typename _Mybase::template _Enable_if_callable_t<decay_t<_Fx>&, function> = 0>
template <class _Fx, typename _Mybase::template _Enable_if_callable_t<_Fx, function> = 0>
#else // ^^^ _USE_FUNCTION_INT_0_SFINAE // !_USE_FUNCTION_INT_0_SFINAE vvv
template <class _Fx, class = typename _Mybase::template _Enable_if_callable_t<decay_t<_Fx>&, function>>
template <class _Fx, class = typename _Mybase::template _Enable_if_callable_t<_Fx, function>>
#endif // _USE_FUNCTION_INT_0_SFINAE
function& operator=(_Fx&& _Func) {
function(_STD forward<_Fx>(_Func)).swap(*this);
Expand Down