[gcc r15-1253] libstdc++: Optimize std::is_invocable compilation performance
Ken Matsui
kmatsui@gcc.gnu.org
Thu Jun 13 12:58:42 GMT 2024
https://gcc.gnu.org/g:dbb26feeb67d033d9dff51042044997aa5db9226
commit r15-1253-gdbb26feeb67d033d9dff51042044997aa5db9226
Author: Ken Matsui <kmatsui@gcc.gnu.org>
Date: Mon Feb 19 18:13:01 2024 -0800
libstdc++: Optimize std::is_invocable compilation performance
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>
Diff:
---
libstdc++-v3/include/std/type_traits | 4 ++++
libstdc++-v3/testsuite/20_util/is_invocable/incomplete_args_neg.cc | 1 +
libstdc++-v3/testsuite/20_util/is_invocable/incomplete_neg.cc | 1 +
3 files changed, 6 insertions(+)
diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index 5402574efe99..fcaff88c1932 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -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");
diff --git a/libstdc++-v3/testsuite/20_util/is_invocable/incomplete_args_neg.cc b/libstdc++-v3/testsuite/20_util/is_invocable/incomplete_args_neg.cc
index a575750f9e9c..9619129b8170 100644
--- a/libstdc++-v3/testsuite/20_util/is_invocable/incomplete_args_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/is_invocable/incomplete_args_neg.cc
@@ -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>
diff --git a/libstdc++-v3/testsuite/20_util/is_invocable/incomplete_neg.cc b/libstdc++-v3/testsuite/20_util/is_invocable/incomplete_neg.cc
index 05848603555b..b478ebce815d 100644
--- a/libstdc++-v3/testsuite/20_util/is_invocable/incomplete_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/is_invocable/incomplete_neg.cc
@@ -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>
More information about the Gcc-cvs
mailing list