Skip to content

Commit 5fab33a

Browse files
committed
[libc++] Avoid instantiating type_trait classes
Use `using` aliases to avoid instantiating lots of types Reviewed By: ldionne, #libc Spies: libcxx-commits, miyuki Differential Revision: https://reviews.llvm.org/D132785
1 parent 2fb68c0 commit 5fab33a

File tree

106 files changed

+376
-307
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+376
-307
lines changed

libcxx/include/__algorithm/copy.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pair<_InIter, _OutIter> __copy_impl(_InIter __first, _Sent __last, _OutIter __re
4040

4141
template <class _InValueT,
4242
class _OutValueT,
43-
class = __enable_if_t<is_same<typename remove_const<_InValueT>::type, _OutValueT>::value
43+
class = __enable_if_t<is_same<__remove_const_t<_InValueT>, _OutValueT>::value
4444
&& is_trivially_copy_assignable<_OutValueT>::value> >
4545
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
4646
pair<_InValueT*, _OutValueT*> __copy_impl(_InValueT* __first, _InValueT* __last, _OutValueT* __result) {
@@ -58,7 +58,7 @@ pair<_InValueT*, _OutValueT*> __copy_impl(_InValueT* __first, _InValueT* __last,
5858
}
5959

6060
template <class _InIter, class _OutIter,
61-
__enable_if_t<is_same<typename remove_const<__iter_value_type<_InIter> >::type, __iter_value_type<_OutIter> >::value
61+
__enable_if_t<is_same<__remove_const_t<__iter_value_type<_InIter> >, __iter_value_type<_OutIter> >::value
6262
&& __is_cpp17_contiguous_iterator<typename _InIter::iterator_type>::value
6363
&& __is_cpp17_contiguous_iterator<typename _OutIter::iterator_type>::value
6464
&& is_trivially_copy_assignable<__iter_value_type<_OutIter> >::value

libcxx/include/__algorithm/half_positive.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ typename enable_if
2929
>::type
3030
__half_positive(_Integral __value)
3131
{
32-
return static_cast<_Integral>(static_cast<typename make_unsigned<_Integral>::type>(__value) / 2);
32+
return static_cast<_Integral>(static_cast<__make_unsigned_t<_Integral> >(__value) / 2);
3333
}
3434

3535
template <typename _Tp>

libcxx/include/__algorithm/iterator_operations.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ struct _IterOps<_ClassicAlgPolicy> {
9797
template <class _Iter>
9898
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
9999
static void __validate_iter_reference() {
100-
static_assert(is_same<__deref_t<_Iter>, typename iterator_traits<__uncvref_t<_Iter> >::reference>::value,
100+
static_assert(is_same<__deref_t<_Iter>, typename iterator_traits<__remove_cvref_t<_Iter> >::reference>::value,
101101
"It looks like your iterator's `iterator_traits<It>::reference` does not match the return type of "
102102
"dereferencing the iterator, i.e., calling `*it`. This is undefined behavior according to [input.iterators] "
103103
"and can lead to dangling reference issues at runtime, so we are flagging this.");
@@ -147,16 +147,16 @@ struct _IterOps<_ClassicAlgPolicy> {
147147

148148
template <class _Iter>
149149
_LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX14
150-
__uncvref_t<_Iter> next(_Iter&& __it,
151-
typename iterator_traits<__uncvref_t<_Iter> >::difference_type __n = 1) {
150+
__remove_cvref_t<_Iter> next(_Iter&& __it,
151+
typename iterator_traits<__remove_cvref_t<_Iter> >::difference_type __n = 1) {
152152
return std::next(std::forward<_Iter>(__it), __n);
153153
}
154154

155155
// prev
156156
template <class _Iter>
157157
_LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX14
158-
__uncvref_t<_Iter> prev(_Iter&& __iter,
159-
typename iterator_traits<__uncvref_t<_Iter> >::difference_type __n = 1) {
158+
__remove_cvref_t<_Iter> prev(_Iter&& __iter,
159+
typename iterator_traits<__remove_cvref_t<_Iter> >::difference_type __n = 1) {
160160
return std::prev(std::forward<_Iter>(__iter), __n);
161161
}
162162

libcxx/include/__algorithm/move.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pair<_InIter, _OutIter> __move_impl(_InIter __first, _Sent __last, _OutIter __re
4141
template <class _AlgPolicy,
4242
class _InType,
4343
class _OutType,
44-
class = __enable_if_t<is_same<typename remove_const<_InType>::type, _OutType>::value
44+
class = __enable_if_t<is_same<__remove_const_t<_InType>, _OutType>::value
4545
&& is_trivially_move_assignable<_OutType>::value> >
4646
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
4747
pair<_InType*, _OutType*> __move_impl(_InType* __first, _InType* __last, _OutType* __result) {
@@ -70,7 +70,7 @@ struct __is_trivially_move_assignable_unwrapped
7070
template <class _AlgPolicy,
7171
class _InIter,
7272
class _OutIter,
73-
__enable_if_t<is_same<typename remove_const<typename iterator_traits<_InIter>::value_type>::type,
73+
__enable_if_t<is_same<__remove_const_t<typename iterator_traits<_InIter>::value_type>,
7474
typename iterator_traits<_OutIter>::value_type>::value
7575
&& __is_cpp17_contiguous_iterator<_InIter>::value
7676
&& __is_cpp17_contiguous_iterator<_OutIter>::value

libcxx/include/__algorithm/move_backward.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ template <class _AlgPolicy, class _Tp, class _Up>
4444
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
4545
typename enable_if
4646
<
47-
is_same<typename remove_const<_Tp>::type, _Up>::value &&
47+
is_same<__remove_const_t<_Tp>, _Up>::value &&
4848
is_trivially_move_assignable<_Up>::value,
4949
_Up*
5050
>::type

libcxx/include/__algorithm/partition.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ template <class _AlgPolicy, class _ForwardIterator, class _Sentinel, class _Pred
7979
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
8080
pair<_ForwardIterator, _ForwardIterator> __partition(
8181
_ForwardIterator __first, _Sentinel __last, _Predicate&& __pred, _IterCategory __iter_category) {
82-
return std::__partition_impl<__uncvref_t<_Predicate>&, _AlgPolicy>(
82+
return std::__partition_impl<__remove_cvref_t<_Predicate>&, _AlgPolicy>(
8383
std::move(__first), std::move(__last), __pred, __iter_category);
8484
}
8585

libcxx/include/__algorithm/ranges_iterator_concept.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace ranges {
2626

2727
template <class _IterMaybeQualified>
2828
consteval auto __get_iterator_concept() {
29-
using _Iter = __uncvref_t<_IterMaybeQualified>;
29+
using _Iter = __remove_cvref_t<_IterMaybeQualified>;
3030

3131
if constexpr (contiguous_iterator<_Iter>)
3232
return contiguous_iterator_tag();

libcxx/include/__algorithm/ranges_merge.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ template <
4747
class _Comp,
4848
class _Proj1,
4949
class _Proj2>
50-
_LIBCPP_HIDE_FROM_ABI constexpr merge_result<__uncvref_t<_InIter1>, __uncvref_t<_InIter2>, __uncvref_t<_OutIter>>
50+
_LIBCPP_HIDE_FROM_ABI constexpr merge_result<__remove_cvref_t<_InIter1>, __remove_cvref_t<_InIter2>, __remove_cvref_t<_OutIter>>
5151
__merge_impl(
5252
_InIter1&& __first1,
5353
_Sent1&& __last1,

libcxx/include/__algorithm/ranges_partition.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ struct __fn {
4444

4545
template <class _Iter, class _Sent, class _Proj, class _Pred>
4646
_LIBCPP_HIDE_FROM_ABI static constexpr
47-
subrange<__uncvref_t<_Iter>> __partition_fn_impl(_Iter&& __first, _Sent&& __last, _Pred&& __pred, _Proj&& __proj) {
47+
subrange<__remove_cvref_t<_Iter>> __partition_fn_impl(_Iter&& __first, _Sent&& __last, _Pred&& __pred, _Proj&& __proj) {
4848
auto&& __projected_pred = std::__make_projected(__pred, __proj);
4949
auto __result = std::__partition<_RangeAlgPolicy>(
5050
std::move(__first), std::move(__last), __projected_pred, __iterator_concept<_Iter>());

libcxx/include/__algorithm/ranges_partition_copy.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ struct __fn {
4343
template <class _InIter, class _Sent, class _OutIter1, class _OutIter2, class _Proj, class _Pred>
4444
_LIBCPP_HIDE_FROM_ABI constexpr
4545
static partition_copy_result<
46-
__uncvref_t<_InIter>, __uncvref_t<_OutIter1>, __uncvref_t<_OutIter2>
46+
__remove_cvref_t<_InIter>, __remove_cvref_t<_OutIter1>, __remove_cvref_t<_OutIter2>
4747
> __partition_copy_fn_impl( _InIter&& __first, _Sent&& __last, _OutIter1&& __out_true, _OutIter2&& __out_false,
4848
_Pred& __pred, _Proj& __proj) {
4949
for (; __first != __last; ++__first) {

0 commit comments

Comments
 (0)