]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Optimize std::is_invocable compilation performance
authorKen Matsui <kmatsui@gcc.gnu.org>
Tue, 20 Feb 2024 02:13:01 +0000 (18:13 -0800)
committerKen Matsui <kmatsui@gcc.gnu.org>
Thu, 13 Jun 2024 12:56:53 +0000 (05:56 -0700)
This patch optimizes the compilation performance of std::is_invocable
by dispatching to the new __is_invocable built-in trait.

libstdc++-v3/ChangeLog:

* include/std/type_traits (is_invocable): Use __is_invocable
built-in trait.
* testsuite/20_util/is_invocable/incomplete_args_neg.cc: Handle
the new error from __is_invocable.
* testsuite/20_util/is_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_invocable/incomplete_args_neg.cc
libstdc++-v3/testsuite/20_util/is_invocable/incomplete_neg.cc

index 5402574efe9974752888d710f4fd3066767ff7e7..fcaff88c193254d93eeda10cea3e3b8e483507d2 100644 (file)
@@ -3201,7 +3201,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   /// std::is_invocable
   template<typename _Fn, typename... _ArgTypes>
     struct is_invocable
+#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_invocable)
+    : public __bool_constant<__is_invocable(_Fn, _ArgTypes...)>
+#else
     : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>::type
+#endif
     {
       static_assert(std::__is_complete_or_unbounded(__type_identity<_Fn>{}),
        "_Fn must be a complete class or an unbounded array");
index a575750f9e9ce8a436f77f6de3e18798e1155ebd..9619129b8170bd3408e3da42a238dc1b2b1bc76e 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 05848603555bbf4f7469235f3de9e56817db850b..b478ebce815d5d4c92a8047f561853619605edf8 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>