diff mbox series

[v16,08/26] libstdc++: Optimize std::is_unbounded_array compilation performance

Message ID 20240502161614.3705912-9-kmatsui@gcc.gnu.org
State New
Headers show
Series Optimize more type traits | expand

Commit Message

Ken Matsui May 2, 2024, 4:13 p.m. UTC
This patch optimizes the compilation performance of
std::is_unbounded_array by dispatching to the new
__builtin_is_unbounded_array trait.

libstdc++-v3/ChangeLog:

	* include/std/type_traits (is_unbounded_array_v): Use
	__builtin_is_unbounded_array trait.

Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
---
 libstdc++-v3/include/std/type_traits | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index 812619803f4..3d7d00c3bb8 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -3710,11 +3710,17 @@  template<typename _Ret, typename _Fn, typename... _Args>
   /// True for a type that is an array of unknown bound.
   /// @ingroup variable_templates
   /// @since C++20
+# if _GLIBCXX_USE_BUILTIN_TRAIT(__builtin_is_unbounded_array)
+  template<typename _Tp>
+    inline constexpr bool is_unbounded_array_v =
+      __builtin_is_unbounded_array(_Tp);
+# else
   template<typename _Tp>
     inline constexpr bool is_unbounded_array_v = false;
 
   template<typename _Tp>
     inline constexpr bool is_unbounded_array_v<_Tp[]> = true;
+# endif
 
   /// True for a type that is an array of known bound.
   /// @since C++20