[v26,07/23] libstdc++: Optimize std::is_bounded_array compilation performance

Message ID 20231207053633.1001720-8-kmatsui@gcc.gnu.org
State Accepted
Headers
Series [v26,01/23] c++: Sort built-in traits alphabetically |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Ken Matsui Dec. 7, 2023, 5:33 a.m. UTC
  This patch optimizes the compilation performance of std::is_bounded_array
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(+)
  

Patch

diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index 64f9d67fe29..2a1a0aa80ff 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -3506,11 +3506,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