diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2019-10-24 12:54:13 +0000 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2019-10-24 12:54:13 +0000 |
commit | 3b4ababd69d86082e1bdf52157c44a9336adcb3d (patch) | |
tree | 568ca6d8ee26dab6a6718a2063a5a31d7e591691 /libstdc++-v3/doc/xml/manual/allocator.xml | |
parent | f537742b10bb7ce24f5c17a3c369aa3041a901dc (diff) |
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).
Backport from mainline
2019-08-15 Jonathan Wakely <jwakely@redhat.com>
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.
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/gcc-9-branch@277380 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/doc/xml/manual/allocator.xml')
0 files changed, 0 insertions, 0 deletions