]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Optimize std::is_nothrow_invocable compilation performance
authorKen Matsui <kmatsui@gcc.gnu.org>
Wed, 21 Feb 2024 08:49:10 +0000 (00:49 -0800)
committerKen Matsui <kmatsui@gcc.gnu.org>
Thu, 13 Jun 2024 12:57:01 +0000 (05:57 -0700)
This patch optimizes the compilation performance of
std::is_nothrow_invocable by dispatching to the new
__is_nothrow_invocable built-in trait.

libstdc++-v3/ChangeLog:

* include/std/type_traits (is_nothrow_invocable): Use
__is_nothrow_invocable built-in trait.
* testsuite/20_util/is_nothrow_invocable/incomplete_args_neg.cc:
Handle the new error from __is_nothrow_invocable.
* testsuite/20_util/is_nothrow_invocable/incomplete_neg.cc:
Likewise.

Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
Reviewed-by: Patrick Palka <ppalka@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/include/std/type_traits
libstdc++-v3/testsuite/20_util/is_nothrow_invocable/incomplete_args_neg.cc
libstdc++-v3/testsuite/20_util/is_nothrow_invocable/incomplete_neg.cc

index fcaff88c193254d93eeda10cea3e3b8e483507d2..8c8219b2697c29a6bc5cff2d83e35959bfb4ae46 100644 (file)
@@ -3231,8 +3231,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   /// std::is_nothrow_invocable
   template<typename _Fn, typename... _ArgTypes>
     struct is_nothrow_invocable
+#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_nothrow_invocable)
+    : public __bool_constant<__is_nothrow_invocable(_Fn, _ArgTypes...)>
+#else
     : __and_<__is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>,
             __call_is_nothrow_<_Fn, _ArgTypes...>>::type
+#endif
     {
       static_assert(std::__is_complete_or_unbounded(__type_identity<_Fn>{}),
        "_Fn must be a complete class or an unbounded array");
index 3c225883eaf254b381c31d6e84c3190a5e46894c..3f8542dd366dff2edbefa229cd9a19ea788d54c2 100644 (file)
@@ -18,6 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-error "must be a complete class" "" { target *-*-* } 0 }
+// { dg-prune-output "invalid use of incomplete type" }
 
 #include <type_traits>
 
index 5a728bfa03bacefa2bc3a49520e6b28cf01a8344..d3bdf08448b5e3026621bac302d67c555549007b 100644 (file)
@@ -18,6 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-error "must be a complete class" "" { target *-*-* } 0 }
+// { dg-prune-output "invalid use of incomplete type" }
 
 #include <type_traits>