gcc/libstdc++-v3/testsuite
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
..
17_intro Fix failing tests for use of non-reserved names 2019-05-20 15:38:21 +01:00
18_support PR libstdc++/51333 Define recursive_init_error constructor non-inline 2019-07-29 15:27:19 +01:00
19_diagnostics Add test for std::hash<std::error_code> 2019-05-07 16:30:29 +01:00
20_util PR libstdc++/91456 make INVOKE<R> work with uncopyable prvalues 2019-08-15 17:07:27 +01:00
21_strings Replace std::to_string for integers with optimized version 2019-06-12 15:52:02 +01:00
22_locale P0482R5 char8_t: Updates to existing standard library tests 2019-02-22 01:16:08 +00:00
23_containers P0325R4 to_array from LFTS with updates 2019-08-08 11:18:53 +01:00
24_iterators Fix non-standard behaviour of std::istream_iterator 2019-06-19 23:57:10 +01:00
25_algorithms Implement C++20 p0879 - Constexpr for swap and swap related functions. 2019-08-14 17:54:15 +00:00
26_numerics Specialize std::numbers constants for __float128 2019-08-06 16:57:51 +01:00
27_io PR libstdc++/91067 fix missing exports for filesystem iterators 2019-07-03 22:06:25 +01:00
28_regex PR libstdc++/89023 fix test that fails when <omp.h> not available 2019-02-11 12:56:59 +00:00
29_atomics Fix inaccurate comment in new test 2019-07-12 16:45:16 +01:00
30_threads LWG 2921 remove packaged_task constructors taking allocators 2019-05-23 22:40:56 +01:00
abi Update copyright years. 2019-01-01 13:31:55 +01:00
backward Update copyright years. 2019-01-01 13:31:55 +01:00
config Update copyright years. 2019-01-01 13:31:55 +01:00
data
decimal Update copyright years. 2019-01-01 13:31:55 +01:00
experimental PR libstdc++/90281 Fix string conversions for filesystem::path 2019-06-17 15:19:04 +01:00
ext skip Cholesky decomposition in is>>n_mv_dist 2019-08-09 09:20:58 +00:00
lib PR libstdc++/90252 fix effective-target check for TBB 2019-05-21 14:50:41 +01:00
libstdc++-abi Update copyright years. 2019-01-01 13:31:55 +01:00
libstdc++-dg Update copyright years. 2019-01-01 13:31:55 +01:00
libstdc++-prettyprinters Improve tests for std::vector<bool> printer 2019-06-20 10:04:55 +01:00
libstdc++-xmethods Update copyright years. 2019-01-01 13:31:55 +01:00
performance Update copyright years. 2019-01-01 13:31:55 +01:00
special_functions PR libstdc++/86655 - std::assoc_legendre should not constrain 2019-03-06 13:38:32 +00:00
tr1 PR libstdc++/86655 - std::assoc_legendre should not constrain 2019-03-06 13:38:32 +00:00
tr2 Update copyright years. 2019-01-01 13:31:55 +01:00
util 2019-07-26 François Dumont <fdumont@gcc.gnu.org> 2019-07-26 05:05:48 +00:00
Makefile.am Remove Profile Mode, deprecated since GCC 7.1 2019-05-13 11:50:21 +01:00
Makefile.in Remove Profile Mode, deprecated since GCC 7.1 2019-05-13 11:50:21 +01:00