From ef2afa1e83fad5f813e5d12f4a88acbaf8cf85fe Mon Sep 17 00:00:00 2001 From: Nikolas Klauser Date: Mon, 6 Jan 2025 12:12:40 +0100 Subject: [PATCH] [libc++] Simplify unwrap_ref_decay a bit (#121623) --- libcxx/include/__type_traits/unwrap_ref.h | 15 ++++----------- libcxx/include/__utility/pair.h | 6 ++---- libcxx/include/tuple | 4 ++-- 3 files changed, 8 insertions(+), 17 deletions(-) diff --git a/libcxx/include/__type_traits/unwrap_ref.h b/libcxx/include/__type_traits/unwrap_ref.h index 74c4fde915c3..5ac037333d08 100644 --- a/libcxx/include/__type_traits/unwrap_ref.h +++ b/libcxx/include/__type_traits/unwrap_ref.h @@ -29,6 +29,9 @@ struct __unwrap_reference > { using type _LIBCPP_NODEBUG = _Tp&; }; +template +using __unwrap_ref_decay_t = typename __unwrap_reference<__decay_t<_Tp> >::type; + #if _LIBCPP_STD_VER >= 20 template struct unwrap_reference : __unwrap_reference<_Tp> {}; @@ -40,19 +43,9 @@ template struct unwrap_ref_decay : unwrap_reference<__decay_t<_Tp> > {}; template -using unwrap_ref_decay_t = typename unwrap_ref_decay<_Tp>::type; +using unwrap_ref_decay_t = __unwrap_ref_decay_t<_Tp>; #endif // _LIBCPP_STD_VER >= 20 -template -struct __unwrap_ref_decay -#if _LIBCPP_STD_VER >= 20 - : unwrap_ref_decay<_Tp> -#else - : __unwrap_reference<__decay_t<_Tp> > -#endif -{ -}; - _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___TYPE_TRAITS_UNWRAP_REF_H diff --git a/libcxx/include/__utility/pair.h b/libcxx/include/__utility/pair.h index f9d0f4e47231..bb81e30926d7 100644 --- a/libcxx/include/__utility/pair.h +++ b/libcxx/include/__utility/pair.h @@ -532,11 +532,9 @@ swap(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) noexcept(noexcept(__x #endif template -inline _LIBCPP_HIDE_FROM_ABI -_LIBCPP_CONSTEXPR_SINCE_CXX14 pair::type, typename __unwrap_ref_decay<_T2>::type> +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<__unwrap_ref_decay_t<_T1>, __unwrap_ref_decay_t<_T2> > make_pair(_T1&& __t1, _T2&& __t2) { - return pair::type, typename __unwrap_ref_decay<_T2>::type>( - std::forward<_T1>(__t1), std::forward<_T2>(__t2)); + return pair<__unwrap_ref_decay_t<_T1>, __unwrap_ref_decay_t<_T2> >(std::forward<_T1>(__t1), std::forward<_T2>(__t2)); } template diff --git a/libcxx/include/tuple b/libcxx/include/tuple index b2478746f5e2..e4f1fc209b73 100644 --- a/libcxx/include/tuple +++ b/libcxx/include/tuple @@ -1125,9 +1125,9 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 tuple<_Tp&...> tie(_T } template -inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 tuple::type...> +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 tuple<__unwrap_ref_decay_t<_Tp>...> make_tuple(_Tp&&... __t) { - return tuple::type...>(std::forward<_Tp>(__t)...); + return tuple<__unwrap_ref_decay_t<_Tp>...>(std::forward<_Tp>(__t)...); } template