From 6c00d3aef1b0ec410e2c3392ceb8622d8b088e99 Mon Sep 17 00:00:00 2001 From: Christopher Di Bella Date: Wed, 4 Oct 2023 19:29:17 +0000 Subject: [PATCH] [libcxx] replaces SFINAE with requires-expressions in `bind_front` and `bind_back` 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::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, T &>' evaluated to false ``` --- libcxx/include/__functional/bind_back.h | 11 +++-------- libcxx/include/__functional/bind_front.h | 11 +++-------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/libcxx/include/__functional/bind_back.h b/libcxx/include/__functional/bind_back.h index 71dc63c86bdbee..0dd2befb524094 100644 --- a/libcxx/include/__functional/bind_back.h +++ b/libcxx/include/__functional/bind_back.h @@ -43,14 +43,9 @@ struct __bind_back_t : __perfect_forward<__bind_back_op using __perfect_forward<__bind_back_op>, _Fn, _BoundArgs>::__perfect_forward; }; -template , _Fn>, - is_move_constructible>, - is_constructible, _Args>..., - is_move_constructible>... - >::value ->> +template + requires is_constructible_v, _Fn> && is_move_constructible_v> && + (is_constructible_v, _Args> && ...) && (is_move_constructible_v> && ...) _LIBCPP_HIDE_FROM_ABI constexpr auto __bind_back(_Fn&& __f, _Args&&... __args) noexcept(noexcept(__bind_back_t, tuple...>>(_VSTD::forward<_Fn>(__f), _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)))) diff --git a/libcxx/include/__functional/bind_front.h b/libcxx/include/__functional/bind_front.h index 72bb6648095962..7ccd6e563b6e19 100644 --- a/libcxx/include/__functional/bind_front.h +++ b/libcxx/include/__functional/bind_front.h @@ -42,14 +42,9 @@ struct __bind_front_t : __perfect_forward<__bind_front_op, _Fn, _BoundArgs...> { using __perfect_forward<__bind_front_op, _Fn, _BoundArgs...>::__perfect_forward; }; -template , _Fn>, - is_move_constructible>, - is_constructible, _Args>..., - is_move_constructible>... - >::value ->> +template + requires is_constructible_v, _Fn> && is_move_constructible_v> && + (is_constructible_v, _Args> && ...) && (is_move_constructible_v> && ...) _LIBCPP_HIDE_FROM_ABI constexpr auto bind_front(_Fn&& __f, _Args&&... __args) { return __bind_front_t, decay_t<_Args>...>(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)...);