This patch optimizes the compilation performance of std::add_lvalue_reference by dispatching to the new __builtin_add_lvalue_reference trait.
libstdc++-v3/ChangeLog: * include/std/type_traits (add_lvalue_reference): Use __builtin_add_lvalue_reference trait. (__add_lvalue_reference_helper): Likewise. Signed-off-by: Ken Matsui <kmat...@gcc.gnu.org> --- libstdc++-v3/include/std/type_traits | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 8f756712c63..4e97e45f130 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -1157,6 +1157,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION }; /// @cond undocumented +#if _GLIBCXX_USE_BUILTIN_TRAIT(__builtin_add_lvalue_reference) + template<typename _Tp> + struct __add_lvalue_reference_helper + { using type = __builtin_add_lvalue_reference(_Tp); }; +#else template<typename _Tp, typename = void> struct __add_lvalue_reference_helper { using type = _Tp; }; @@ -1164,6 +1169,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename _Tp> struct __add_lvalue_reference_helper<_Tp, __void_t<_Tp&>> { using type = _Tp&; }; +#endif template<typename _Tp> using __add_lval_ref_t = typename __add_lvalue_reference_helper<_Tp>::type; @@ -1731,9 +1737,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif /// add_lvalue_reference +#if _GLIBCXX_USE_BUILTIN_TRAIT(__builtin_add_lvalue_reference) + template<typename _Tp> + struct add_lvalue_reference + { using type = __builtin_add_lvalue_reference(_Tp); }; +#else template<typename _Tp> struct add_lvalue_reference { using type = __add_lval_ref_t<_Tp>; }; +#endif /// add_rvalue_reference template<typename _Tp> -- 2.44.0