]> git.ipfire.org Git - thirdparty/gcc.git/commit
Add __is_nothrow_convertible to fix std::is_nothrow_invocable_r
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 14 May 2019 14:39:58 +0000 (14:39 +0000)
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 14 May 2019 14:39:58 +0000 (14:39 +0000)
commit2cfc6a76fdb4cfac3e52ad6339541b26aee9b23a
treebbe2f05868657c7771ea3a3e5a4dac499bfa24e3
parent83274070a2c31d2fb7f0f403cd251cc54b246027
Add __is_nothrow_convertible to fix std::is_nothrow_invocable_r

The definition of is_nothrow_invocable in terms of is_convertible and
is_nothrow_constructible is incorrect, because a type could have an
explicit constructor that means is_nothrow_constructible is true, but
implicit conversions could use a different constructor that is
potentially-throwing.

Fix it by adding a C++11 version of C++20's is_nothrow_convertible that
only considers implicit conversions.

* include/std/type_traits (__is_nt_convertible_helper): Define it
unconditionally, not only for C++20.
(__is_nothrow_convertible): Define internal trait for use in C++11.
(__is_nt_invocable_impl: Fix by using __is_nothrow_convertible.
(is_invocable_r_v, is_nothrow_invocable_r_v): Add missing parameter.
* testsuite/20_util/is_nothrow_convertible/value_ext.cc: New test.
* testsuite/20_util/is_nothrow_convertible/value.cc: Check with type
that has nothrow explicit conversion but potentially-throwing implicit
conversion.
* testsuite/20_util/is_nothrow_invocable/value.cc: Likewise.
* testsuite/20_util/is_nothrow_invocable/value_ext.cc: Fix helper
function to only consider implicit conversions.
* testsuite/20_util/tuple/cons/noexcept_specs.cc: Add comment.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@271171 138bc75d-0d04-0410-961f-82ee72b054a4
libstdc++-v3/ChangeLog
libstdc++-v3/include/std/type_traits
libstdc++-v3/testsuite/20_util/is_nothrow_convertible/value.cc
libstdc++-v3/testsuite/20_util/is_nothrow_convertible/value_ext.cc [new file with mode: 0644]
libstdc++-v3/testsuite/20_util/is_nothrow_invocable/value.cc
libstdc++-v3/testsuite/20_util/is_nothrow_invocable/value_ext.cc
libstdc++-v3/testsuite/20_util/tuple/cons/noexcept_specs.cc