[v13,20/26] libstdc++: Optimize std::decay compilation performance

Message ID 20240221093616.4001742-20-kmatsui@gcc.gnu.org
State Superseded
Headers
Series [v13,01/26] c++: Implement __is_const built-in trait |

Commit Message

Ken Matsui Feb. 21, 2024, 9:36 a.m. UTC
  This patch optimizes the compilation performance of std::decay
by dispatching to the new __decay built-in trait.

libstdc++-v3/ChangeLog:

	* include/std/type_traits (decay): Use __decay built-in trait.

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

Patch

diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index 18a5e4de2d3..2f4c8dd3b21 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -2316,6 +2316,11 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   /// @cond undocumented
 
+#if _GLIBCXX_USE_BUILTIN_TRAIT(__decay)
+  template<typename _Tp>
+    struct decay
+    { using type = __decay(_Tp); };
+#else
   // Decay trait for arrays and functions, used for perfect forwarding
   // in make_pair, make_tuple, etc.
   template<typename _Up>
@@ -2347,6 +2352,7 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template<typename _Tp>
     struct decay<_Tp&&>
     { using type = typename __decay_selector<_Tp>::type; };
+#endif
 
   /// @cond undocumented