Skip to content

Commit 8b3ad40

Browse files
committed
[libc++] Use template variables in a bunch of places instead of class templates
1 parent bdf8c99 commit 8b3ad40

Some content is hidden

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

71 files changed

+657
-744
lines changed

libcxx/include/__algorithm/equal.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ template <class _Tp,
184184
class _Up,
185185
class _BinaryPredicate,
186186
__enable_if_t<__desugars_to_v<__equal_tag, _BinaryPredicate, _Tp, _Up> && !is_volatile<_Tp>::value &&
187-
!is_volatile<_Up>::value && __libcpp_is_trivially_equality_comparable<_Tp, _Up>::value,
187+
!is_volatile<_Up>::value && __is_trivially_equality_comparable_v<_Tp, _Up>,
188188
int> = 0>
189189
[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
190190
__equal_iter_impl(_Tp* __first1, _Tp* __last1, _Up* __first2, _BinaryPredicate&) {
@@ -225,7 +225,7 @@ template <class _Tp,
225225
class _Proj2,
226226
__enable_if_t<__desugars_to_v<__equal_tag, _Pred, _Tp, _Up> && __is_identity<_Proj1>::value &&
227227
__is_identity<_Proj2>::value && !is_volatile<_Tp>::value && !is_volatile<_Up>::value &&
228-
__libcpp_is_trivially_equality_comparable<_Tp, _Up>::value,
228+
__is_trivially_equality_comparable_v<_Tp, _Up>,
229229
int> = 0>
230230
[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
231231
__equal_impl(_Tp* __first1, _Tp* __last1, _Up* __first2, _Up*, _Pred&, _Proj1&, _Proj2&) {

libcxx/include/__algorithm/equal_range.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ __equal_range(_Iter __first, _Sent __last, const _Tp& __value, _Compare&& __comp
5858
template <class _ForwardIterator, class _Tp, class _Compare>
5959
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_ForwardIterator, _ForwardIterator>
6060
equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) {
61-
static_assert(__is_callable<_Compare&, decltype(*__first), const _Tp&>::value, "The comparator has to be callable");
61+
static_assert(__is_callable_v<_Compare&, decltype(*__first), const _Tp&>, "The comparator has to be callable");
6262
static_assert(is_copy_constructible<_ForwardIterator>::value, "Iterator has to be copy constructible");
6363
return std::__equal_range<_ClassicAlgPolicy>(
6464
std::move(__first),

libcxx/include/__algorithm/find.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ __find(_Iter __first, _Sent __last, const _Tp& __value, _Proj& __proj) {
5252
}
5353

5454
// trivially equality comparable implementations
55-
template <class _Tp,
56-
class _Up,
57-
class _Proj,
58-
__enable_if_t<__is_identity<_Proj>::value && __libcpp_is_trivially_equality_comparable<_Tp, _Up>::value &&
59-
sizeof(_Tp) == 1,
60-
int> = 0>
55+
template <
56+
class _Tp,
57+
class _Up,
58+
class _Proj,
59+
__enable_if_t<__is_identity<_Proj>::value && __is_trivially_equality_comparable_v<_Tp, _Up> && sizeof(_Tp) == 1,
60+
int> = 0>
6161
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __find(_Tp* __first, _Tp* __last, const _Up& __value, _Proj&) {
6262
if (auto __ret = std::__constexpr_memchr(__first, __value, __last - __first))
6363
return __ret;
@@ -68,7 +68,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __find(_Tp* __first, _T
6868
template <class _Tp,
6969
class _Up,
7070
class _Proj,
71-
__enable_if_t<__is_identity<_Proj>::value && __libcpp_is_trivially_equality_comparable<_Tp, _Up>::value &&
71+
__enable_if_t<__is_identity<_Proj>::value && __is_trivially_equality_comparable_v<_Tp, _Up> &&
7272
sizeof(_Tp) == sizeof(wchar_t) && _LIBCPP_ALIGNOF(_Tp) >= _LIBCPP_ALIGNOF(wchar_t),
7373
int> = 0>
7474
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __find(_Tp* __first, _Tp* __last, const _Up& __value, _Proj&) {
@@ -83,7 +83,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __find(_Tp* __first, _T
8383
template <class _Tp,
8484
class _Up,
8585
class _Proj,
86-
__enable_if_t<__is_identity<_Proj>::value && !__libcpp_is_trivially_equality_comparable<_Tp, _Up>::value &&
86+
__enable_if_t<__is_identity<_Proj>::value && !__is_trivially_equality_comparable_v<_Tp, _Up> &&
8787
is_integral<_Tp>::value && is_integral<_Up>::value &&
8888
is_signed<_Tp>::value == is_signed<_Up>::value,
8989
int> = 0>

libcxx/include/__algorithm/includes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ includes(_InputIterator1 __first1,
5353
_InputIterator2 __last2,
5454
_Compare __comp) {
5555
static_assert(
56-
__is_callable<_Compare&, decltype(*__first1), decltype(*__first2)>::value, "The comparator has to be callable");
56+
__is_callable_v<_Compare&, decltype(*__first1), decltype(*__first2)>, "The comparator has to be callable");
5757

5858
return std::__includes(
5959
std::move(__first1),

libcxx/include/__algorithm/is_permutation.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __is_permutation(
250250
template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
251251
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool is_permutation(
252252
_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _BinaryPredicate __pred) {
253-
static_assert(__is_callable<_BinaryPredicate&, decltype(*__first1), decltype(*__first2)>::value,
253+
static_assert(__is_callable_v<_BinaryPredicate&, decltype(*__first1), decltype(*__first2)>,
254254
"The comparator has to be callable");
255255

256256
return std::__is_permutation<_ClassicAlgPolicy>(std::move(__first1), std::move(__last1), std::move(__first2), __pred);
@@ -287,7 +287,7 @@ template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredica
287287
_ForwardIterator2 __first2,
288288
_ForwardIterator2 __last2,
289289
_BinaryPredicate __pred) {
290-
static_assert(__is_callable<_BinaryPredicate&, decltype(*__first1), decltype(*__first2)>::value,
290+
static_assert(__is_callable_v<_BinaryPredicate&, decltype(*__first1), decltype(*__first2)>,
291291
"The comparator has to be callable");
292292

293293
return std::__is_permutation<_ClassicAlgPolicy>(

libcxx/include/__algorithm/lexicographical_compare.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ template <class _Tp,
6666
class _Proj2,
6767
class _Comp,
6868
__enable_if_t<__desugars_to_v<__totally_ordered_less_tag, _Comp, _Tp, _Tp> && !is_volatile<_Tp>::value &&
69-
__libcpp_is_trivially_equality_comparable<_Tp, _Tp>::value &&
70-
__is_identity<_Proj1>::value && __is_identity<_Proj2>::value,
69+
__is_trivially_equality_comparable_v<_Tp, _Tp> && __is_identity<_Proj1>::value &&
70+
__is_identity<_Proj2>::value,
7171
int> = 0>
7272
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
7373
__lexicographical_compare(_Tp* __first1, _Tp* __last1, _Tp* __first2, _Tp* __last2, _Comp&, _Proj1&, _Proj2&) {

libcxx/include/__algorithm/lower_bound.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ __lower_bound(_ForwardIterator __first, _Sent __last, const _Type& __value, _Com
9292
template <class _ForwardIterator, class _Tp, class _Compare>
9393
[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
9494
lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) {
95-
static_assert(__is_callable<_Compare&, decltype(*__first), const _Tp&>::value, "The comparator has to be callable");
95+
static_assert(__is_callable_v<_Compare&, decltype(*__first), const _Tp&>, "The comparator has to be callable");
9696
auto __proj = std::__identity();
9797
return std::__lower_bound<_ClassicAlgPolicy>(__first, __last, __value, __comp, __proj);
9898
}

libcxx/include/__algorithm/max_element.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ template <class _ForwardIterator, class _Compare>
3939
[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator
4040
max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) {
4141
static_assert(
42-
__is_callable<_Compare&, decltype(*__first), decltype(*__first)>::value, "The comparator has to be callable");
42+
__is_callable_v<_Compare&, decltype(*__first), decltype(*__first)>, "The comparator has to be callable");
4343
return std::__max_element<__comp_ref_type<_Compare> >(__first, __last, __comp);
4444
}
4545

libcxx/include/__algorithm/min_element.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
5353
static_assert(
5454
__has_forward_iterator_category<_ForwardIterator>::value, "std::min_element requires a ForwardIterator");
5555
static_assert(
56-
__is_callable<_Compare&, decltype(*__first), decltype(*__first)>::value, "The comparator has to be callable");
56+
__is_callable_v<_Compare&, decltype(*__first), decltype(*__first)>, "The comparator has to be callable");
5757

5858
return std::__min_element<__comp_ref_type<_Compare> >(std::move(__first), std::move(__last), __comp);
5959
}

libcxx/include/__algorithm/minmax.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ minmax(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __
4040
template <class _Tp, class _Compare>
4141
[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Tp, _Tp>
4242
minmax(initializer_list<_Tp> __t, _Compare __comp) {
43-
static_assert(__is_callable<_Compare&, _Tp, _Tp>::value, "The comparator has to be callable");
43+
static_assert(__is_callable_v<_Compare&, _Tp, _Tp>, "The comparator has to be callable");
4444
__identity __proj;
4545
auto __ret = std::__minmax_element_impl(__t.begin(), __t.end(), __comp, __proj);
4646
return pair<_Tp, _Tp>(*__ret.first, *__ret.second);

0 commit comments

Comments
 (0)