[libcxx-commits] [libcxx] 9f3e3ef - [libc++][NFC] Refactor __enable_if return types to defaulted template parameters
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Sep 1 17:52:37 PDT 2023
Author: Nikolas Klauser
Date: 2023-09-01T17:52:31-07:00
New Revision: 9f3e3efd98a29eb8df9e3ad43a573c9141d1ace2
URL: https://github.com/llvm/llvm-project/commit/9f3e3efd98a29eb8df9e3ad43a573c9141d1ace2
DIFF: https://github.com/llvm/llvm-project/commit/9f3e3efd98a29eb8df9e3ad43a573c9141d1ace2.diff
LOG: [libc++][NFC] Refactor __enable_if return types to defaulted template parameters
This brings most of the enable_ifs in libc++ to the same style. It also has the nice side-effect of reducing the size of names of these symbols, since the depedent return type is shorter.
Reviewed By: #libc, ldionne
Spies: ldionne, libcxx-commits
Differential Revision: https://reviews.llvm.org/D157787
Added:
Modified:
libcxx/include/__algorithm/iterator_operations.h
libcxx/include/__algorithm/sort.h
libcxx/include/__condition_variable/condition_variable.h
libcxx/include/__functional/bind.h
libcxx/include/__hash_table
libcxx/include/__split_buffer
libcxx/include/__tree
libcxx/include/array
libcxx/include/cmath
libcxx/include/forward_list
libcxx/include/map
libcxx/include/queue
libcxx/include/stack
libcxx/include/tuple
Removed:
################################################################################
diff --git a/libcxx/include/__algorithm/iterator_operations.h b/libcxx/include/__algorithm/iterator_operations.h
index 002978014cc71e..e6176da4f5606d 100644
--- a/libcxx/include/__algorithm/iterator_operations.h
+++ b/libcxx/include/__algorithm/iterator_operations.h
@@ -110,27 +110,23 @@ struct _IterOps<_ClassicAlgPolicy> {
}
// iter_move
- template <class _Iter>
+ template <class _Iter, __enable_if_t<is_reference<__deref_t<_Iter> >::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static
// If the result of dereferencing `_Iter` is a reference type, deduce the result of calling `std::move` on it. Note
// that the C++03 mode doesn't support `decltype(auto)` as the return type.
- __enable_if_t<
- is_reference<__deref_t<_Iter> >::value,
- __move_t<_Iter> >
+ __move_t<_Iter>
__iter_move(_Iter&& __i) {
__validate_iter_reference<_Iter>();
return std::move(*std::forward<_Iter>(__i));
}
- template <class _Iter>
+ template <class _Iter, __enable_if_t<!is_reference<__deref_t<_Iter> >::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static
// If the result of dereferencing `_Iter` is a value type, deduce the return value of this function to also be a
// value -- otherwise, after `operator*` returns a temporary, this function would return a dangling reference to that
// temporary. Note that the C++03 mode doesn't support `auto` as the return type.
- __enable_if_t<
- !is_reference<__deref_t<_Iter> >::value,
- __deref_t<_Iter> >
+ __deref_t<_Iter>
__iter_move(_Iter&& __i) {
__validate_iter_reference<_Iter>();
diff --git a/libcxx/include/__algorithm/sort.h b/libcxx/include/__algorithm/sort.h
index 3b594fa4d2a806..567c988ff0d3ce 100644
--- a/libcxx/include/__algorithm/sort.h
+++ b/libcxx/include/__algorithm/sort.h
@@ -175,23 +175,26 @@ inline _LIBCPP_HIDE_FROM_ABI void __partially_sorted_swap(_RandomAccessIterator
*__y = __r ? *__y : __tmp;
}
-template <class, class _Compare, class _RandomAccessIterator>
-inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void>
+template <class, class _Compare, class _RandomAccessIterator,
+ __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>::value, int> = 0>
+inline _LIBCPP_HIDE_FROM_ABI void
__sort3_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3,
_Compare __c) {
std::__cond_swap<_Compare>(__x2, __x3, __c);
std::__partially_sorted_swap<_Compare>(__x1, __x2, __x3, __c);
}
-template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
-inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<!__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void>
+template <class _AlgPolicy, class _Compare, class _RandomAccessIterator,
+ __enable_if_t<!__use_branchless_sort<_Compare, _RandomAccessIterator>::value, int> = 0>
+inline _LIBCPP_HIDE_FROM_ABI void
__sort3_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3,
_Compare __c) {
std::__sort3<_AlgPolicy, _Compare>(__x1, __x2, __x3, __c);
}
-template <class, class _Compare, class _RandomAccessIterator>
-inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void>
+template <class, class _Compare, class _RandomAccessIterator,
+ __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>::value, int> = 0>
+inline _LIBCPP_HIDE_FROM_ABI void
__sort4_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3,
_RandomAccessIterator __x4, _Compare __c) {
std::__cond_swap<_Compare>(__x1, __x3, __c);
@@ -201,15 +204,17 @@ __sort4_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2,
std::__cond_swap<_Compare>(__x2, __x3, __c);
}
-template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
-inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<!__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void>
+template <class _AlgPolicy, class _Compare, class _RandomAccessIterator,
+ __enable_if_t<!__use_branchless_sort<_Compare, _RandomAccessIterator>::value, int> = 0>
+inline _LIBCPP_HIDE_FROM_ABI void
__sort4_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3,
_RandomAccessIterator __x4, _Compare __c) {
std::__sort4<_AlgPolicy, _Compare>(__x1, __x2, __x3, __x4, __c);
}
-template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
-inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void>
+template <class _AlgPolicy, class _Compare, class _RandomAccessIterator,
+ __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>::value, int> = 0>
+inline _LIBCPP_HIDE_FROM_ABI void
__sort5_maybe_branchless(
_RandomAccessIterator __x1,
_RandomAccessIterator __x2,
@@ -225,8 +230,9 @@ __sort5_maybe_branchless(
std::__partially_sorted_swap<_Compare>(__x2, __x3, __x4, __c);
}
-template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
-inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<!__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void>
+template <class _AlgPolicy, class _Compare, class _RandomAccessIterator,
+ __enable_if_t<!__use_branchless_sort<_Compare, _RandomAccessIterator>::value, int> = 0>
+inline _LIBCPP_HIDE_FROM_ABI void
__sort5_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3,
_RandomAccessIterator __x4, _RandomAccessIterator __x5, _Compare __c) {
std::__sort5<_AlgPolicy, _Compare, _RandomAccessIterator>(
diff --git a/libcxx/include/__condition_variable/condition_variable.h b/libcxx/include/__condition_variable/condition_variable.h
index 7cbf21fe7311e8..4d8e590e29db7f 100644
--- a/libcxx/include/__condition_variable/condition_variable.h
+++ b/libcxx/include/__condition_variable/condition_variable.h
@@ -92,9 +92,8 @@ class _LIBCPP_EXPORTED_FROM_ABI condition_variable {
};
#endif // !_LIBCPP_HAS_NO_THREADS
-template <class _Rep, class _Period>
-inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<is_floating_point<_Rep>::value, chrono::nanoseconds>
-__safe_nanosecond_cast(chrono::duration<_Rep, _Period> __d) {
+template <class _Rep, class _Period, __enable_if_t<is_floating_point<_Rep>::value, int> = 0>
+inline _LIBCPP_HIDE_FROM_ABI chrono::nanoseconds __safe_nanosecond_cast(chrono::duration<_Rep, _Period> __d) {
using namespace chrono;
using __ratio = ratio_divide<_Period, nano>;
using __ns_rep = nanoseconds::rep;
@@ -113,9 +112,8 @@ __safe_nanosecond_cast(chrono::duration<_Rep, _Period> __d) {
return nanoseconds(static_cast<__ns_rep>(__result_float));
}
-template <class _Rep, class _Period>
-inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<!is_floating_point<_Rep>::value, chrono::nanoseconds>
-__safe_nanosecond_cast(chrono::duration<_Rep, _Period> __d) {
+template <class _Rep, class _Period, __enable_if_t<!is_floating_point<_Rep>::value, int> = 0>
+inline _LIBCPP_HIDE_FROM_ABI chrono::nanoseconds __safe_nanosecond_cast(chrono::duration<_Rep, _Period> __d) {
using namespace chrono;
if (__d.count() == 0) {
return nanoseconds(0);
diff --git a/libcxx/include/__functional/bind.h b/libcxx/include/__functional/bind.h
index 9ac920fa04fde3..364ab8d49ba5e0 100644
--- a/libcxx/include/__functional/bind.h
+++ b/libcxx/include/__functional/bind.h
@@ -98,13 +98,9 @@ __mu_expand(_Ti& __ti, tuple<_Uj...>& __uj, __tuple_indices<_Indx...>)
return __ti(_VSTD::forward<_Uj>(_VSTD::get<_Indx>(__uj))...);
}
-template <class _Ti, class ..._Uj>
+template <class _Ti, class ..._Uj, __enable_if_t<is_bind_expression<_Ti>::value, int> = 0>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
-typename __enable_if_t
-<
- is_bind_expression<_Ti>::value,
- __invoke_of<_Ti&, _Uj...>
->::type
+typename __invoke_of<_Ti&, _Uj...>::type
__mu(_Ti& __ti, tuple<_Uj...>& __uj)
{
typedef typename __make_tuple_indices<sizeof...(_Uj)>::type __indices;
diff --git a/libcxx/include/__hash_table b/libcxx/include/__hash_table
index 2ae7afdc10dea5..98337abe558330 100644
--- a/libcxx/include/__hash_table
+++ b/libcxx/include/__hash_table
@@ -194,16 +194,16 @@ struct __hash_key_value_types<__hash_value_type<_Key, _Tp> > {
return __v.first;
}
- template <class _Up>
+ template <class _Up, __enable_if_t<__is_same_uncvref<_Up, __node_value_type>::value, int> = 0>
_LIBCPP_INLINE_VISIBILITY
- static __enable_if_t<__is_same_uncvref<_Up, __node_value_type>::value, __container_value_type const&>
+ static __container_value_type const&
__get_value(_Up& __t) {
return __t.__get_value();
}
- template <class _Up>
+ template <class _Up, __enable_if_t<__is_same_uncvref<_Up, __container_value_type>::value, int> = 0>
_LIBCPP_INLINE_VISIBILITY
- static __enable_if_t<__is_same_uncvref<_Up, __container_value_type>::value, __container_value_type const&>
+ static __container_value_type const&
__get_value(_Up& __t) {
return __t;
}
@@ -904,9 +904,10 @@ public:
__can_extract_key<_Pp, key_type>());
}
- template <class _First, class _Second>
+ template <class _First, class _Second,
+ __enable_if_t<__can_extract_map_key<_First, key_type, __container_value_type>::value, int> = 0>
_LIBCPP_INLINE_VISIBILITY
- __enable_if_t<__can_extract_map_key<_First, key_type, __container_value_type>::value, pair<iterator, bool> >
+ pair<iterator, bool>
__emplace_unique(_First&& __f, _Second&& __s) {
return __emplace_unique_key_args(__f, _VSTD::forward<_First>(__f),
_VSTD::forward<_Second>(__s));
diff --git a/libcxx/include/__split_buffer b/libcxx/include/__split_buffer
index 6854f6a4b2f83f..da73f4c8322568 100644
--- a/libcxx/include/__split_buffer
+++ b/libcxx/include/__split_buffer
@@ -160,15 +160,13 @@ public:
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n);
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n, const_reference __x);
- template <class _InputIter>
+ template <class _InputIter, __enable_if_t<__has_exactly_input_iterator_category<_InputIter>::value, int> = 0>
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
- __enable_if_t<__has_exactly_input_iterator_category<_InputIter>::value>
- __construct_at_end(_InputIter __first, _InputIter __last);
+ void __construct_at_end(_InputIter __first, _InputIter __last);
- template <class _ForwardIterator>
+ template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0>
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
- __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value>
- __construct_at_end(_ForwardIterator __first, _ForwardIterator __last);
+ void __construct_at_end(_ForwardIterator __first, _ForwardIterator __last);
template <class _Iterator, class _Sentinel>
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
@@ -283,9 +281,9 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_referen
}
template <class _Tp, class _Allocator>
-template <class _InputIter>
-_LIBCPP_CONSTEXPR_SINCE_CXX20 __enable_if_t<__has_exactly_input_iterator_category<_InputIter>::value>
-__split_buffer<_Tp, _Allocator>::__construct_at_end(_InputIter __first, _InputIter __last)
+template <class _InputIter, __enable_if_t<__has_exactly_input_iterator_category<_InputIter>::value, int> >
+_LIBCPP_CONSTEXPR_SINCE_CXX20
+void __split_buffer<_Tp, _Allocator>::__construct_at_end(_InputIter __first, _InputIter __last)
{
__construct_at_end_with_sentinel(__first, __last);
}
@@ -312,9 +310,9 @@ void __split_buffer<_Tp, _Allocator>::__construct_at_end_with_sentinel(_Iterator
}
}
template <class _Tp, class _Allocator>
-template <class _ForwardIterator>
-_LIBCPP_CONSTEXPR_SINCE_CXX20 __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value>
-__split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last)
+template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> >
+_LIBCPP_CONSTEXPR_SINCE_CXX20
+void __split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last)
{
__construct_at_end_with_size(__first, std::distance(__first, __last));
}
diff --git a/libcxx/include/__tree b/libcxx/include/__tree
index 58d4a97c04035a..54ce71e442d037 100644
--- a/libcxx/include/__tree
+++ b/libcxx/include/__tree
@@ -615,9 +615,9 @@ struct __tree_key_value_types<__value_type<_Key, _Tp> > {
return __t.__get_value().first;
}
- template <class _Up>
+ template <class _Up, __enable_if_t<__is_same_uncvref<_Up, __container_value_type>::value, int> = 0>
_LIBCPP_INLINE_VISIBILITY
- static __enable_if_t<__is_same_uncvref<_Up, __container_value_type>::value, key_type const&>
+ static key_type const&
__get_key(_Up& __t) {
return __t.first;
}
@@ -1186,9 +1186,10 @@ public:
__can_extract_key<_Pp, key_type>());
}
- template <class _First, class _Second>
+ template <class _First, class _Second,
+ __enable_if_t<__can_extract_map_key<_First, key_type, __container_value_type>::value, int> = 0>
_LIBCPP_INLINE_VISIBILITY
- __enable_if_t<__can_extract_map_key<_First, key_type, __container_value_type>::value, pair<iterator, bool> >
+ pair<iterator, bool>
__emplace_unique(_First&& __f, _Second&& __s) {
return __emplace_unique_key_args(__f, _VSTD::forward<_First>(__f),
_VSTD::forward<_Second>(__s));
@@ -1228,9 +1229,10 @@ public:
__can_extract_key<_Pp, key_type>());
}
- template <class _First, class _Second>
+ template <class _First, class _Second,
+ __enable_if_t<__can_extract_map_key<_First, key_type, __container_value_type>::value, int> = 0>
_LIBCPP_INLINE_VISIBILITY
- __enable_if_t<__can_extract_map_key<_First, key_type, __container_value_type>::value, iterator>
+ iterator
__emplace_hint_unique(const_iterator __p, _First&& __f, _Second&& __s) {
return __emplace_hint_unique_key_args(__p, __f,
_VSTD::forward<_First>(__f),
diff --git a/libcxx/include/array b/libcxx/include/array
index 3fc25d4c30623d..c01d13ef358a55 100644
--- a/libcxx/include/array
+++ b/libcxx/include/array
@@ -444,9 +444,9 @@ operator<=>(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) {
#endif // _LIBCPP_STD_VER <= 17
-template <class _Tp, size_t _Size>
+template <class _Tp, size_t _Size, __enable_if_t<_Size == 0 || __is_swappable<_Tp>::value, int> = 0>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
-__enable_if_t<_Size == 0 || __is_swappable<_Tp>::value, void>
+void
swap(array<_Tp, _Size>& __x, array<_Tp, _Size>& __y)
_NOEXCEPT_(noexcept(__x.swap(__y)))
{
diff --git a/libcxx/include/cmath b/libcxx/include/cmath
index 86da2df0c0f70c..12bcd65b4abf7a 100644
--- a/libcxx/include/cmath
+++ b/libcxx/include/cmath
@@ -642,10 +642,9 @@ __constexpr_copysign(long double __x, long double __y) _NOEXCEPT {
return __builtin_copysignl(__x, __y);
}
-template <class _A1, class _A2>
+template <class _A1, class _A2, __enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
_LIBCPP_CONSTEXPR inline _LIBCPP_HIDE_FROM_ABI
- typename std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value,
- std::__promote<_A1, _A2> >::type
+ typename __promote<_A1, _A2>::type
__constexpr_copysign(_A1 __x, _A2 __y) _NOEXCEPT {
typedef typename std::__promote<_A1, _A2>::type __result_type;
static_assert((!(std::_IsSame<_A1, __result_type>::value && std::_IsSame<_A2, __result_type>::value)), "");
diff --git a/libcxx/include/forward_list b/libcxx/include/forward_list
index 6cb794070b7b8b..1dbf1a3ca51c9f 100644
--- a/libcxx/include/forward_list
+++ b/libcxx/include/forward_list
@@ -777,8 +777,8 @@ public:
// ~forward_list() = default;
- template <class _InputIterator>
- __enable_if_t<__has_input_iterator_category<_InputIterator>::value, void>
+ template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0>
+ void
_LIBCPP_HIDE_FROM_ABI assign(_InputIterator __f, _InputIterator __l);
#if _LIBCPP_STD_VER >= 23
@@ -872,9 +872,9 @@ public:
#endif // _LIBCPP_CXX03_LANG
_LIBCPP_HIDE_FROM_ABI iterator insert_after(const_iterator __p, const value_type& __v);
_LIBCPP_HIDE_FROM_ABI iterator insert_after(const_iterator __p, size_type __n, const value_type& __v);
- template <class _InputIterator>
+ template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0>
_LIBCPP_INLINE_VISIBILITY
- __enable_if_t<__has_input_iterator_category<_InputIterator>::value, iterator>
+ iterator
insert_after(const_iterator __p, _InputIterator __f, _InputIterator __l);
#if _LIBCPP_STD_VER >= 23
@@ -1170,8 +1170,8 @@ forward_list<_Tp, _Alloc>::operator=(initializer_list<value_type> __il)
#endif // _LIBCPP_CXX03_LANG
template <class _Tp, class _Alloc>
-template <class _InputIterator>
-__enable_if_t<__has_input_iterator_category<_InputIterator>::value, void>
+template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> >
+void
forward_list<_Tp, _Alloc>::assign(_InputIterator __f, _InputIterator __l)
{
__assign_with_sentinel(__f, __l);
@@ -1376,8 +1376,8 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, size_type __n,
}
template <class _Tp, class _Alloc>
-template <class _InputIterator>
-__enable_if_t<__has_input_iterator_category<_InputIterator>::value, typename forward_list<_Tp, _Alloc>::iterator>
+template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> >
+typename forward_list<_Tp, _Alloc>::iterator
forward_list<_Tp, _Alloc>::insert_after(const_iterator __p,
_InputIterator __f, _InputIterator __l)
{
diff --git a/libcxx/include/map b/libcxx/include/map
index 4152d58a2f8844..17bb715f249d75 100644
--- a/libcxx/include/map
+++ b/libcxx/include/map
@@ -1530,13 +1530,13 @@ public:
_LIBCPP_INLINE_VISIBILITY
const_iterator find(const key_type& __k) const {return __tree_.find(__k);}
#if _LIBCPP_STD_VER >= 14
- template <typename _K2>
+ template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
_LIBCPP_INLINE_VISIBILITY
- __enable_if_t<__is_transparent<_Compare, _K2>::value, iterator>
+ iterator
find(const _K2& __k) {return __tree_.find(__k);}
- template <typename _K2>
+ template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
_LIBCPP_INLINE_VISIBILITY
- __enable_if_t<__is_transparent<_Compare, _K2>::value, const_iterator>
+ const_iterator
find(const _K2& __k) const {return __tree_.find(__k);}
#endif
@@ -1544,18 +1544,18 @@ public:
size_type count(const key_type& __k) const
{return __tree_.__count_unique(__k);}
#if _LIBCPP_STD_VER >= 14
- template <typename _K2>
+ template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
_LIBCPP_INLINE_VISIBILITY
- __enable_if_t<__is_transparent<_Compare, _K2>::value, size_type>
+ size_type
count(const _K2& __k) const {return __tree_.__count_multi(__k);}
#endif
#if _LIBCPP_STD_VER >= 20
_LIBCPP_INLINE_VISIBILITY
bool contains(const key_type& __k) const {return find(__k) != end();}
- template <typename _K2>
+ template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
_LIBCPP_INLINE_VISIBILITY
- __enable_if_t<__is_transparent<_Compare, _K2>::value, bool>
+ bool
contains(const _K2& __k) const { return find(__k) != end(); }
#endif // _LIBCPP_STD_VER >= 20
@@ -1566,14 +1566,14 @@ public:
const_iterator lower_bound(const key_type& __k) const
{return __tree_.lower_bound(__k);}
#if _LIBCPP_STD_VER >= 14
- template <typename _K2>
+ template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
_LIBCPP_INLINE_VISIBILITY
- __enable_if_t<__is_transparent<_Compare, _K2>::value, iterator>
+ iterator
lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);}
- template <typename _K2>
+ template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
_LIBCPP_INLINE_VISIBILITY
- __enable_if_t<__is_transparent<_Compare, _K2>::value, const_iterator>
+ const_iterator
lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);}
#endif
@@ -1584,13 +1584,13 @@ public:
const_iterator upper_bound(const key_type& __k) const
{return __tree_.upper_bound(__k);}
#if _LIBCPP_STD_VER >= 14
- template <typename _K2>
+ template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
_LIBCPP_INLINE_VISIBILITY
- __enable_if_t<__is_transparent<_Compare, _K2>::value, iterator>
+ iterator
upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);}
- template <typename _K2>
+ template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
_LIBCPP_INLINE_VISIBILITY
- __enable_if_t<__is_transparent<_Compare, _K2>::value, const_iterator>
+ const_iterator
upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);}
#endif
@@ -1601,13 +1601,13 @@ public:
pair<const_iterator,const_iterator> equal_range(const key_type& __k) const
{return __tree_.__equal_range_unique(__k);}
#if _LIBCPP_STD_VER >= 14
- template <typename _K2>
+ template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
_LIBCPP_INLINE_VISIBILITY
- __enable_if_t<__is_transparent<_Compare, _K2>::value, pair<iterator,iterator>>
+ pair<iterator,iterator>
equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);}
- template <typename _K2>
+ template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
_LIBCPP_INLINE_VISIBILITY
- __enable_if_t<__is_transparent<_Compare, _K2>::value, pair<const_iterator,const_iterator>>
+ pair<const_iterator,const_iterator>
equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);}
#endif
@@ -2266,13 +2266,13 @@ public:
_LIBCPP_INLINE_VISIBILITY
const_iterator find(const key_type& __k) const {return __tree_.find(__k);}
#if _LIBCPP_STD_VER >= 14
- template <typename _K2>
+ template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
_LIBCPP_INLINE_VISIBILITY
- __enable_if_t<__is_transparent<_Compare, _K2>::value, iterator>
+ iterator
find(const _K2& __k) {return __tree_.find(__k);}
- template <typename _K2>
+ template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
_LIBCPP_INLINE_VISIBILITY
- __enable_if_t<__is_transparent<_Compare, _K2>::value, const_iterator>
+ const_iterator
find(const _K2& __k) const {return __tree_.find(__k);}
#endif
@@ -2280,18 +2280,18 @@ public:
size_type count(const key_type& __k) const
{return __tree_.__count_multi(__k);}
#if _LIBCPP_STD_VER >= 14
- template <typename _K2>
+ template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
_LIBCPP_INLINE_VISIBILITY
- __enable_if_t<__is_transparent<_Compare, _K2>::value, size_type>
+ size_type
count(const _K2& __k) const {return __tree_.__count_multi(__k);}
#endif
#if _LIBCPP_STD_VER >= 20
_LIBCPP_INLINE_VISIBILITY
bool contains(const key_type& __k) const {return find(__k) != end();}
- template <typename _K2>
+ template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
_LIBCPP_INLINE_VISIBILITY
- __enable_if_t<__is_transparent<_Compare, _K2>::value, bool>
+ bool
contains(const _K2& __k) const { return find(__k) != end(); }
#endif // _LIBCPP_STD_VER >= 20
@@ -2302,14 +2302,14 @@ public:
const_iterator lower_bound(const key_type& __k) const
{return __tree_.lower_bound(__k);}
#if _LIBCPP_STD_VER >= 14
- template <typename _K2>
+ template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
_LIBCPP_INLINE_VISIBILITY
- __enable_if_t<__is_transparent<_Compare, _K2>::value, iterator>
+ iterator
lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);}
- template <typename _K2>
+ template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
_LIBCPP_INLINE_VISIBILITY
- __enable_if_t<__is_transparent<_Compare, _K2>::value, const_iterator>
+ const_iterator
lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);}
#endif
@@ -2320,13 +2320,13 @@ public:
const_iterator upper_bound(const key_type& __k) const
{return __tree_.upper_bound(__k);}
#if _LIBCPP_STD_VER >= 14
- template <typename _K2>
+ template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
_LIBCPP_INLINE_VISIBILITY
- __enable_if_t<__is_transparent<_Compare, _K2>::value, iterator>
+ iterator
upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);}
- template <typename _K2>
+ template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
_LIBCPP_INLINE_VISIBILITY
- __enable_if_t<__is_transparent<_Compare, _K2>::value, const_iterator>
+ const_iterator
upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);}
#endif
@@ -2337,13 +2337,13 @@ public:
pair<const_iterator,const_iterator> equal_range(const key_type& __k) const
{return __tree_.__equal_range_multi(__k);}
#if _LIBCPP_STD_VER >= 14
- template <typename _K2>
+ template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
_LIBCPP_INLINE_VISIBILITY
- __enable_if_t<__is_transparent<_Compare, _K2>::value, pair<iterator,iterator>>
+ pair<iterator,iterator>
equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);}
- template <typename _K2>
+ template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
_LIBCPP_INLINE_VISIBILITY
- __enable_if_t<__is_transparent<_Compare, _K2>::value, pair<const_iterator,const_iterator>>
+ pair<const_iterator,const_iterator>
equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);}
#endif
diff --git a/libcxx/include/queue b/libcxx/include/queue
index b5944e8f9f92ac..21c18ef4315471 100644
--- a/libcxx/include/queue
+++ b/libcxx/include/queue
@@ -565,9 +565,9 @@ operator<=>(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y
#endif
-template <class _Tp, class _Container>
+template <class _Tp, class _Container, __enable_if_t<__is_swappable<_Container>::value, int> = 0>
inline _LIBCPP_INLINE_VISIBILITY
-__enable_if_t<__is_swappable<_Container>::value, void>
+void
swap(queue<_Tp, _Container>& __x, queue<_Tp, _Container>& __y)
_NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
{
@@ -1108,12 +1108,10 @@ priority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q)
swap(comp, __q.comp);
}
-template <class _Tp, class _Container, class _Compare>
+template <class _Tp, class _Container, class _Compare,
+ __enable_if_t<__is_swappable<_Container>::value && __is_swappable<_Compare>::value, int> = 0>
inline _LIBCPP_INLINE_VISIBILITY
-__enable_if_t<
- __is_swappable<_Container>::value && __is_swappable<_Compare>::value,
- void
->
+void
swap(priority_queue<_Tp, _Container, _Compare>& __x,
priority_queue<_Tp, _Container, _Compare>& __y)
_NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
diff --git a/libcxx/include/stack b/libcxx/include/stack
index 437f57d76bd55d..6d725a84b06a0f 100644
--- a/libcxx/include/stack
+++ b/libcxx/include/stack
@@ -414,9 +414,9 @@ operator<=>(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y
#endif
-template <class _Tp, class _Container>
+template <class _Tp, class _Container, __enable_if_t<__is_swappable<_Container>::value, int> = 0>
inline _LIBCPP_INLINE_VISIBILITY
-__enable_if_t<__is_swappable<_Container>::value, void>
+void
swap(stack<_Tp, _Container>& __x, stack<_Tp, _Container>& __y)
_NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
{
diff --git a/libcxx/include/tuple b/libcxx/include/tuple
index 02998a4e2b4a92..609ae537b3c0e7 100644
--- a/libcxx/include/tuple
+++ b/libcxx/include/tuple
@@ -1367,9 +1367,9 @@ template <class _Alloc, class ..._Tp>
tuple(allocator_arg_t, _Alloc, tuple<_Tp...>) -> tuple<_Tp...>;
#endif
-template <class ..._Tp>
+template <class ..._Tp, __enable_if_t<__all<__is_swappable<_Tp>::value...>::value, int> = 0>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
-__enable_if_t<__all<__is_swappable<_Tp>::value...>::value, void>
+void
swap(tuple<_Tp...>& __t, tuple<_Tp...>& __u)
_NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
{__t.swap(__u);}
More information about the libcxx-commits
mailing list