[v13,18/26] libstdc++: Optimize std::add_rvalue_reference compilation performance

Message ID 20240221093616.4001742-18-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::add_rvalue_reference by dispatching to the new
__add_rvalue_reference built-in trait.

libstdc++-v3/ChangeLog:

	* include/std/type_traits (add_rvalue_reference): Use
	__add_rvalue_reference built-in trait.
	(__add_rvalue_reference_helper): Likewise.

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

Patch

diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index 17bf47d59d3..18a5e4de2d3 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -1185,6 +1185,11 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
     };
 
   /// @cond undocumented
+#if _GLIBCXX_USE_BUILTIN_TRAIT(__add_rvalue_reference)
+  template<typename _Tp>
+    struct __add_rvalue_reference_helper
+    { using type = __add_rvalue_reference(_Tp); };
+#else
   template<typename _Tp, typename = void>
     struct __add_rvalue_reference_helper
     { using type = _Tp; };
@@ -1192,6 +1197,7 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template<typename _Tp>
     struct __add_rvalue_reference_helper<_Tp, __void_t<_Tp&&>>
     { using type = _Tp&&; };
+#endif
 
   template<typename _Tp>
     using __add_rval_ref_t = typename __add_rvalue_reference_helper<_Tp>::type;
@@ -1748,9 +1754,15 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
 #endif
 
   /// add_rvalue_reference
+#if _GLIBCXX_USE_BUILTIN_TRAIT(__add_rvalue_reference)
+  template<typename _Tp>
+    struct add_rvalue_reference
+    { using type = __add_rvalue_reference(_Tp); };
+#else
   template<typename _Tp>
     struct add_rvalue_reference
     { using type = __add_rval_ref_t<_Tp>; };
+#endif
 
 #if __cplusplus > 201103L
   /// Alias template for remove_reference