libstdc++: Merge bind_front and bind_back binders

The _Bind_front and _Bind_back class templates are now merged into a single
_Binder implementation that accepts _Back as a template parameter. This makes
the bind_back implementation available in C++20 mode, allowing it to be used
for range adaptor closures.

With zero bound arguments, bind_back and bind_front have equivalent
functionality. Consequently, _Bind_back_t now produces the same type as
bind_front (_Binder<false, _Fd>). A simple copy of the functor cannot be
returned in this case, as it would visibly affect overload resolution
(see included test cases).

We also replace std::invoke in internal functions, with std::__invoke.

libstdc++-v3/ChangeLog:

	* include/std/functional: (std::_Indexed_bound_arg): Fixed
	indentation.
	(__Bound_arg_storage::_S_apply_front)
	(__Bound_arg_storage::_S_apply_front): Merged into _S_apply.
	(__Bound_arg_storage::_S_apply): Merged above, add _Back template
	parameter, replace std::invoke with std::__invoke.
	(std::_Bind_front): Renamed to std::_Binder and add _Back
	template parameter.
	(std::_Binder): Renamed from std::_Bind_front.
	(_Binder::_Result_t, _Binder::_S_noexcept_invoke): Define.
	(_Binder::operator()): Use _Result_t and _S_noexcept_invoke.
	(_Binder::_S_call): Handle zero args specially, replace std::invoke
	with std::__invoke.
	(std::_Bind_front_t, std::_Bind_back_t): Defined in terms
	of _Binder.
	(std::_Bind_back): Merged into _Binder.
	* testsuite/20_util/function_objects/bind_back/1.cc: New tests.
	* testsuite/20_util/function_objects/bind_back/111327.cc: Updated
	error messages.
	* testsuite/20_util/function_objects/bind_front/1.cc: New tests.
	* testsuite/20_util/function_objects/bind_front/111327.cc: Updated
	error messages.

Reviewed-by: Patrick Palka <ppalka@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
5 files changed