Skip to content

Commit

Permalink
[libc++] Simplify unwrap_ref_decay a bit (llvm#121623)
Browse files Browse the repository at this point in the history
  • Loading branch information
philnik777 authored Jan 6, 2025
1 parent e4e2f53 commit ef2afa1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 17 deletions.
15 changes: 4 additions & 11 deletions libcxx/include/__type_traits/unwrap_ref.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ struct __unwrap_reference<reference_wrapper<_Tp> > {
using type _LIBCPP_NODEBUG = _Tp&;
};

template <class _Tp>
using __unwrap_ref_decay_t = typename __unwrap_reference<__decay_t<_Tp> >::type;

#if _LIBCPP_STD_VER >= 20
template <class _Tp>
struct unwrap_reference : __unwrap_reference<_Tp> {};
Expand All @@ -40,19 +43,9 @@ template <class _Tp>
struct unwrap_ref_decay : unwrap_reference<__decay_t<_Tp> > {};

template <class _Tp>
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 <class _Tp>
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
6 changes: 2 additions & 4 deletions libcxx/include/__utility/pair.h
Original file line number Diff line number Diff line change
Expand Up @@ -532,11 +532,9 @@ swap(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) noexcept(noexcept(__x
#endif

template <class _T1, class _T2>
inline _LIBCPP_HIDE_FROM_ABI
_LIBCPP_CONSTEXPR_SINCE_CXX14 pair<typename __unwrap_ref_decay<_T1>::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<typename __unwrap_ref_decay<_T1>::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 <class _T1, class _T2>
Expand Down
4 changes: 2 additions & 2 deletions libcxx/include/tuple
Original file line number Diff line number Diff line change
Expand Up @@ -1125,9 +1125,9 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 tuple<_Tp&...> tie(_T
}

template <class... _Tp>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 tuple<typename __unwrap_ref_decay<_Tp>::type...>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 tuple<__unwrap_ref_decay_t<_Tp>...>
make_tuple(_Tp&&... __t) {
return tuple<typename __unwrap_ref_decay<_Tp>::type...>(std::forward<_Tp>(__t)...);
return tuple<__unwrap_ref_decay_t<_Tp>...>(std::forward<_Tp>(__t)...);
}

template <class... _Tp>
Expand Down

0 comments on commit ef2afa1

Please sign in to comment.