gcc/libstdc++-v3/include
Jonathan Wakely d91f618d15 PR libstdc++/91456 make INVOKE<R> work with uncopyable prvalues
In C++17 a function can return a prvalue of a type that cannot be moved
or copied. The current implementation of std::is_invocable_r uses
std::is_convertible to test the conversion to R required by INVOKE<R>.
That fails for non-copyable prvalues, because std::is_convertible is
defined in terms of std::declval which uses std::add_rvalue_reference.
In C++17 conversion from R to R involves no copies and so is not the
same as conversion from R&& to R.

This commit changes std::is_invocable_r to check the conversion without
using std::is_convertible.

std::function also contains a similar check using std::is_convertible,
which can be fixed by simply reusing std::is_invocable_r (but because
std::is_invocable_r is not defined for C++11 it uses the underlying
std::__is_invocable_impl trait directly).

	PR libstdc++/91456
	* include/bits/std_function.h (__check_func_return_type): Remove.
	(function::_Callable): Use std::__is_invocable_impl instead of
	__check_func_return_type.
	* include/std/type_traits (__is_invocable_impl): Add another defaulted
	template parameter. Define a separate partial specialization for
	INVOKE and INVOKE<void>. For INVOKE<R> replace is_convertible check
	with a check that models delayed temporary materialization.
	* testsuite/20_util/function/91456.cc: New test.
	* testsuite/20_util/is_invocable/91456.cc: New test.

From-SVN: r274542
2019-08-15 17:07:27 +01:00
..
backward Remove using-declarations that add std names to __gnu_cxx 2019-05-31 11:35:07 +01:00
bits PR libstdc++/91456 make INVOKE<R> work with uncopyable prvalues 2019-08-15 17:07:27 +01:00
c
c_compatibility
c_global Avoid undefined behaviour in std::byte operators (LWG 2950) 2019-06-18 12:39:43 +01:00
c_std
debug
decimal
experimental P0325R4 to_array from LFTS with updates 2019-08-08 11:18:53 +01:00
ext skip Cholesky decomposition in is>>n_mv_dist 2019-08-09 09:20:58 +00:00
parallel
precompiled Implement "P0631R4 Math Constants" for C++20 2019-07-31 17:40:39 +01:00
pstl pstl_config.h (_PSTL_PRAGMA_SIMD_SCAN, [...]): Define to OpenMP 5.0 pragmas even for GCC 10.0+. 2019-06-25 08:59:12 +02:00
std PR libstdc++/91456 make INVOKE<R> work with uncopyable prvalues 2019-08-15 17:07:27 +01:00
tr1
tr2
Makefile.am Implement "P0631R4 Math Constants" for C++20 2019-07-31 17:40:39 +01:00
Makefile.in Implement "P0631R4 Math Constants" for C++20 2019-07-31 17:40:39 +01:00