Skip to content

Commit 48c805b

Browse files
authored
[libcxx] replaces SFINAE with requires-expressions in bind_front and bind_back (#68249)
The diagnostics for `enable_if_t` are extremely opaque: ``` error: no matching function for call to 'bind_front' note: candidate template ignored: requirement 'integral_constant<bool, false>::value' was not satisfied ``` Using requires-expressions gives us a little more context: ``` error: no matching function for call to 'bind_front' note: candidate template ignored: constraints not satisfied note: because 'is_constructible_v<decay_t<T &>, T &>' evaluated to false ``` Pull request: #68249
1 parent 4a2a6a4 commit 48c805b

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

libcxx/include/__functional/bind_back.h

+3-8
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,9 @@ struct __bind_back_t : __perfect_forward<__bind_back_op<tuple_size_v<_BoundArgs>
4343
using __perfect_forward<__bind_back_op<tuple_size_v<_BoundArgs>>, _Fn, _BoundArgs>::__perfect_forward;
4444
};
4545

46-
template <class _Fn, class ..._Args, class = enable_if_t<
47-
_And<
48-
is_constructible<decay_t<_Fn>, _Fn>,
49-
is_move_constructible<decay_t<_Fn>>,
50-
is_constructible<decay_t<_Args>, _Args>...,
51-
is_move_constructible<decay_t<_Args>>...
52-
>::value
53-
>>
46+
template <class _Fn, class... _Args>
47+
requires is_constructible_v<decay_t<_Fn>, _Fn> && is_move_constructible_v<decay_t<_Fn>> &&
48+
(is_constructible_v<decay_t<_Args>, _Args> && ...) && (is_move_constructible_v<decay_t<_Args>> && ...)
5449
_LIBCPP_HIDE_FROM_ABI
5550
constexpr auto __bind_back(_Fn&& __f, _Args&&... __args)
5651
noexcept(noexcept(__bind_back_t<decay_t<_Fn>, tuple<decay_t<_Args>...>>(_VSTD::forward<_Fn>(__f), _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...))))

libcxx/include/__functional/bind_front.h

+3-8
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,9 @@ struct __bind_front_t : __perfect_forward<__bind_front_op, _Fn, _BoundArgs...> {
4242
using __perfect_forward<__bind_front_op, _Fn, _BoundArgs...>::__perfect_forward;
4343
};
4444

45-
template <class _Fn, class... _Args, class = enable_if_t<
46-
_And<
47-
is_constructible<decay_t<_Fn>, _Fn>,
48-
is_move_constructible<decay_t<_Fn>>,
49-
is_constructible<decay_t<_Args>, _Args>...,
50-
is_move_constructible<decay_t<_Args>>...
51-
>::value
52-
>>
45+
template <class _Fn, class... _Args>
46+
requires is_constructible_v<decay_t<_Fn>, _Fn> && is_move_constructible_v<decay_t<_Fn>> &&
47+
(is_constructible_v<decay_t<_Args>, _Args> && ...) && (is_move_constructible_v<decay_t<_Args>> && ...)
5348
_LIBCPP_HIDE_FROM_ABI
5449
constexpr auto bind_front(_Fn&& __f, _Args&&... __args) {
5550
return __bind_front_t<decay_t<_Fn>, decay_t<_Args>...>(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)...);

0 commit comments

Comments
 (0)