[PATCH 2/2] libstdc++: Optimize is_bounded_array trait performance

Ken Matsui kmatsui@gcc.gnu.org
Tue Sep 12 02:38:39 GMT 2023


This patch optimizes the performance of the is_bounded_array trait
by dispatching to the new __is_bounded_array built-in trait.

libstdc++-v3/ChangeLog:

	* include/std/type_traits (is_bounded_array_v): Use __is_bounded_array
	built-in trait.

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

diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index 677cd934b94..766f9a69445 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -3494,11 +3494,16 @@ template<typename _Ret, typename _Fn, typename... _Args>
   /// True for a type that is an array of known bound.
   /// @ingroup variable_templates
   /// @since C++20
+# if _GLIBCXX_USE_BUILTIN_TRAIT(__is_bounded_array)
+  template<typename _Tp>
+    inline constexpr bool is_bounded_array_v = __is_bounded_array(_Tp);
+# else
   template<typename _Tp>
     inline constexpr bool is_bounded_array_v = false;
 
   template<typename _Tp, size_t _Size>
     inline constexpr bool is_bounded_array_v<_Tp[_Size]> = true;
+# endif
 
   /// True for a type that is an array of unknown bound.
   /// @ingroup variable_templates
-- 
2.42.0



More information about the Libstdc++ mailing list