Skip to content

Commit 06d3d81

Browse files
philnik777paulhuggett
authored andcommitted
[libc++] Simplify unwrap_ref_decay a bit (llvm#121623)
1 parent c35d382 commit 06d3d81

File tree

3 files changed

+8
-17
lines changed

3 files changed

+8
-17
lines changed

libcxx/include/__type_traits/unwrap_ref.h

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ struct __unwrap_reference<reference_wrapper<_Tp> > {
2929
using type _LIBCPP_NODEBUG = _Tp&;
3030
};
3131

32+
template <class _Tp>
33+
using __unwrap_ref_decay_t = typename __unwrap_reference<__decay_t<_Tp> >::type;
34+
3235
#if _LIBCPP_STD_VER >= 20
3336
template <class _Tp>
3437
struct unwrap_reference : __unwrap_reference<_Tp> {};
@@ -40,19 +43,9 @@ template <class _Tp>
4043
struct unwrap_ref_decay : unwrap_reference<__decay_t<_Tp> > {};
4144

4245
template <class _Tp>
43-
using unwrap_ref_decay_t = typename unwrap_ref_decay<_Tp>::type;
46+
using unwrap_ref_decay_t = __unwrap_ref_decay_t<_Tp>;
4447
#endif // _LIBCPP_STD_VER >= 20
4548

46-
template <class _Tp>
47-
struct __unwrap_ref_decay
48-
#if _LIBCPP_STD_VER >= 20
49-
: unwrap_ref_decay<_Tp>
50-
#else
51-
: __unwrap_reference<__decay_t<_Tp> >
52-
#endif
53-
{
54-
};
55-
5649
_LIBCPP_END_NAMESPACE_STD
5750

5851
#endif // _LIBCPP___TYPE_TRAITS_UNWRAP_REF_H

libcxx/include/__utility/pair.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -532,11 +532,9 @@ swap(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) noexcept(noexcept(__x
532532
#endif
533533

534534
template <class _T1, class _T2>
535-
inline _LIBCPP_HIDE_FROM_ABI
536-
_LIBCPP_CONSTEXPR_SINCE_CXX14 pair<typename __unwrap_ref_decay<_T1>::type, typename __unwrap_ref_decay<_T2>::type>
535+
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<__unwrap_ref_decay_t<_T1>, __unwrap_ref_decay_t<_T2> >
537536
make_pair(_T1&& __t1, _T2&& __t2) {
538-
return pair<typename __unwrap_ref_decay<_T1>::type, typename __unwrap_ref_decay<_T2>::type>(
539-
std::forward<_T1>(__t1), std::forward<_T2>(__t2));
537+
return pair<__unwrap_ref_decay_t<_T1>, __unwrap_ref_decay_t<_T2> >(std::forward<_T1>(__t1), std::forward<_T2>(__t2));
540538
}
541539

542540
template <class _T1, class _T2>

libcxx/include/tuple

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,9 +1125,9 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 tuple<_Tp&...> tie(_T
11251125
}
11261126

11271127
template <class... _Tp>
1128-
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 tuple<typename __unwrap_ref_decay<_Tp>::type...>
1128+
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 tuple<__unwrap_ref_decay_t<_Tp>...>
11291129
make_tuple(_Tp&&... __t) {
1130-
return tuple<typename __unwrap_ref_decay<_Tp>::type...>(std::forward<_Tp>(__t)...);
1130+
return tuple<__unwrap_ref_decay_t<_Tp>...>(std::forward<_Tp>(__t)...);
11311131
}
11321132

11331133
template <class... _Tp>

0 commit comments

Comments
 (0)