Skip to content

Commit 05f9348

Browse files
committed
[libc++] Refactor<__type_traits/is_swappable.h>
1 parent f5960c1 commit 05f9348

File tree

26 files changed

+124
-164
lines changed

26 files changed

+124
-164
lines changed

libcxx/include/__hash_table

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -928,13 +928,12 @@ public:
928928

929929
_LIBCPP_HIDE_FROM_ABI void swap(__hash_table& __u)
930930
#if _LIBCPP_STD_VER <= 11
931-
_NOEXCEPT_(__is_nothrow_swappable<hasher>::value&& __is_nothrow_swappable<key_equal>::value &&
931+
_NOEXCEPT_(__is_nothrow_swappable_v<hasher>&& __is_nothrow_swappable_v<key_equal> &&
932932
(!allocator_traits<__pointer_allocator>::propagate_on_container_swap::value ||
933-
__is_nothrow_swappable<__pointer_allocator>::value) &&
934-
(!__node_traits::propagate_on_container_swap::value ||
935-
__is_nothrow_swappable<__node_allocator>::value));
933+
__is_nothrow_swappable_v<__pointer_allocator>) &&
934+
(!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>));
936935
#else
937-
_NOEXCEPT_(__is_nothrow_swappable<hasher>::value&& __is_nothrow_swappable<key_equal>::value);
936+
_NOEXCEPT_(__is_nothrow_swappable_v<hasher>&& __is_nothrow_swappable_v<key_equal>);
938937
#endif
939938

940939
_LIBCPP_HIDE_FROM_ABI size_type max_bucket_count() const _NOEXCEPT { return max_size(); }
@@ -1985,12 +1984,12 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__equal_range_multi(const _Key& __k) c
19851984
template <class _Tp, class _Hash, class _Equal, class _Alloc>
19861985
void __hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u)
19871986
#if _LIBCPP_STD_VER <= 11
1988-
_NOEXCEPT_(__is_nothrow_swappable<hasher>::value&& __is_nothrow_swappable<key_equal>::value &&
1987+
_NOEXCEPT_(__is_nothrow_swappable_v<hasher>&& __is_nothrow_swappable_v<key_equal> &&
19891988
(!allocator_traits<__pointer_allocator>::propagate_on_container_swap::value ||
1990-
__is_nothrow_swappable<__pointer_allocator>::value) &&
1991-
(!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable<__node_allocator>::value))
1989+
__is_nothrow_swappable_v<__pointer_allocator>) &&
1990+
(!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>))
19921991
#else
1993-
_NOEXCEPT_(__is_nothrow_swappable<hasher>::value&& __is_nothrow_swappable<key_equal>::value)
1992+
_NOEXCEPT_(__is_nothrow_swappable_v<hasher>&& __is_nothrow_swappable_v<key_equal>)
19941993
#endif
19951994
{
19961995
_LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(

libcxx/include/__memory/compressed_pair.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ class __compressed_pair : private __compressed_pair_elem<_T1, 0>, private __comp
150150
}
151151

152152
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void swap(__compressed_pair& __x)
153-
_NOEXCEPT_(__is_nothrow_swappable<_T1>::value&& __is_nothrow_swappable<_T2>::value) {
153+
_NOEXCEPT_(__is_nothrow_swappable_v<_T1>&& __is_nothrow_swappable_v<_T2>) {
154154
using std::swap;
155155
swap(first(), __x.first());
156156
swap(second(), __x.second());
@@ -160,7 +160,7 @@ class __compressed_pair : private __compressed_pair_elem<_T1, 0>, private __comp
160160
template <class _T1, class _T2>
161161
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void
162162
swap(__compressed_pair<_T1, _T2>& __x, __compressed_pair<_T1, _T2>& __y)
163-
_NOEXCEPT_(__is_nothrow_swappable<_T1>::value&& __is_nothrow_swappable<_T2>::value) {
163+
_NOEXCEPT_(__is_nothrow_swappable_v<_T1>&& __is_nothrow_swappable_v<_T2>) {
164164
__x.swap(__y);
165165
}
166166

libcxx/include/__memory/swap_allocator.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __swap_allocator(_Alloc
2626
#if _LIBCPP_STD_VER >= 14
2727
_NOEXCEPT
2828
#else
29-
_NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value)
29+
_NOEXCEPT_(__is_nothrow_swappable_v<_Alloc>)
3030
#endif
3131
{
3232
using std::swap;
@@ -42,7 +42,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __swap_allocator
4242
#if _LIBCPP_STD_VER >= 14
4343
_NOEXCEPT
4444
#else
45-
_NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value)
45+
_NOEXCEPT_(__is_nothrow_swappable_v<_Alloc>)
4646
#endif
4747
{
4848
std::__swap_allocator(

libcxx/include/__memory/unique_ptr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS unique_ptr<_Tp[], _Dp>
471471
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void swap(unique_ptr& __u) _NOEXCEPT { __ptr_.swap(__u.__ptr_); }
472472
};
473473

474-
template <class _Tp, class _Dp, __enable_if_t<__is_swappable<_Dp>::value, int> = 0>
474+
template <class _Tp, class _Dp, __enable_if_t<__is_swappable_v<_Dp>, int> = 0>
475475
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
476476
swap(unique_ptr<_Tp, _Dp>& __x, unique_ptr<_Tp, _Dp>& __y) _NOEXCEPT {
477477
__x.swap(__y);

libcxx/include/__split_buffer

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public:
187187
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __destruct_at_end(pointer __new_last, true_type) _NOEXCEPT;
188188

189189
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void swap(__split_buffer& __x)
190-
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable<__alloc_rr>::value);
190+
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__alloc_rr>);
191191

192192
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool __invariants() const;
193193

@@ -409,7 +409,7 @@ __split_buffer<_Tp, _Allocator>::operator=(__split_buffer&& __c)
409409

410410
template <class _Tp, class _Allocator>
411411
_LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x)
412-
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable<__alloc_rr>::value) {
412+
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__alloc_rr>) {
413413
std::swap(__first_, __x.__first_);
414414
std::swap(__begin_, __x.__begin_);
415415
std::swap(__end_, __x.__end_);

libcxx/include/__tree

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,11 +1006,10 @@ public:
10061006

10071007
_LIBCPP_HIDE_FROM_ABI void swap(__tree& __t)
10081008
#if _LIBCPP_STD_VER <= 11
1009-
_NOEXCEPT_(__is_nothrow_swappable<value_compare>::value &&
1010-
(!__node_traits::propagate_on_container_swap::value ||
1011-
__is_nothrow_swappable<__node_allocator>::value));
1009+
_NOEXCEPT_(__is_nothrow_swappable_v<value_compare> &&
1010+
(!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>));
10121011
#else
1013-
_NOEXCEPT_(__is_nothrow_swappable<value_compare>::value);
1012+
_NOEXCEPT_(__is_nothrow_swappable_v<value_compare>);
10141013
#endif
10151014

10161015
template <class _Key, class... _Args>
@@ -1549,10 +1548,10 @@ void __tree<_Tp, _Compare, _Allocator>::destroy(__node_pointer __nd) _NOEXCEPT {
15491548
template <class _Tp, class _Compare, class _Allocator>
15501549
void __tree<_Tp, _Compare, _Allocator>::swap(__tree& __t)
15511550
#if _LIBCPP_STD_VER <= 11
1552-
_NOEXCEPT_(__is_nothrow_swappable<value_compare>::value &&
1553-
(!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable<__node_allocator>::value))
1551+
_NOEXCEPT_(__is_nothrow_swappable_v<value_compare> &&
1552+
(!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>))
15541553
#else
1555-
_NOEXCEPT_(__is_nothrow_swappable<value_compare>::value)
1554+
_NOEXCEPT_(__is_nothrow_swappable_v<value_compare>)
15561555
#endif
15571556
{
15581557
using std::swap;

libcxx/include/__type_traits/is_swappable.h

Lines changed: 35 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,12 @@
1111

1212
#include <__config>
1313
#include <__type_traits/add_lvalue_reference.h>
14-
#include <__type_traits/conditional.h>
1514
#include <__type_traits/enable_if.h>
1615
#include <__type_traits/is_assignable.h>
1716
#include <__type_traits/is_constructible.h>
1817
#include <__type_traits/is_nothrow_assignable.h>
1918
#include <__type_traits/is_nothrow_constructible.h>
20-
#include <__type_traits/is_referenceable.h>
21-
#include <__type_traits/is_same.h>
22-
#include <__type_traits/is_void.h>
23-
#include <__type_traits/nat.h>
19+
#include <__type_traits/void_t.h>
2420
#include <__utility/declval.h>
2521
#include <cstddef>
2622

@@ -30,10 +26,17 @@
3026

3127
_LIBCPP_BEGIN_NAMESPACE_STD
3228

29+
template <class _Tp, class _Up, class = void>
30+
inline const bool __is_swappable_with_v = false;
31+
3332
template <class _Tp>
34-
struct __is_swappable;
33+
inline const bool __is_swappable_v = __is_swappable_with_v<_Tp&, _Tp&>;
34+
35+
template <class _Tp, class _Up, bool = __is_swappable_with_v<_Tp, _Up> >
36+
inline const bool __is_nothrow_swappable_with_v = false;
37+
3538
template <class _Tp>
36-
struct __is_nothrow_swappable;
39+
inline const bool __is_nothrow_swappable_v = __is_nothrow_swappable_with_v<_Tp&, _Tp&>;
3740

3841
#ifndef _LIBCPP_CXX03_LANG
3942
template <class _Tp>
@@ -47,85 +50,52 @@ template <class _Tp>
4750
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __swap_result_t<_Tp> swap(_Tp& __x, _Tp& __y)
4851
_NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value&& is_nothrow_move_assignable<_Tp>::value);
4952

50-
template <class _Tp, size_t _Np, __enable_if_t<__is_swappable<_Tp>::value, int> = 0>
51-
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np])
52-
_NOEXCEPT_(__is_nothrow_swappable<_Tp>::value);
53+
template <class _Tp, size_t _Np, __enable_if_t<__is_swappable_v<_Tp>, int> = 0>
54+
inline _LIBCPP_HIDE_FROM_ABI
55+
_LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable_v<_Tp>);
5356

54-
namespace __detail {
5557
// ALL generic swap overloads MUST already have a declaration available at this point.
5658

57-
template <class _Tp, class _Up = _Tp, bool _NotVoid = !is_void<_Tp>::value && !is_void<_Up>::value>
58-
struct __swappable_with {
59-
template <class _LHS, class _RHS>
60-
static decltype(swap(std::declval<_LHS>(), std::declval<_RHS>())) __test_swap(int);
61-
template <class, class>
62-
static __nat __test_swap(long);
63-
64-
// Extra parens are needed for the C++03 definition of decltype.
65-
typedef decltype((__test_swap<_Tp, _Up>(0))) __swap1;
66-
typedef decltype((__test_swap<_Up, _Tp>(0))) __swap2;
67-
68-
static const bool value = _IsNotSame<__swap1, __nat>::value && _IsNotSame<__swap2, __nat>::value;
69-
};
59+
template <class _Tp, class _Up>
60+
inline const bool __is_swappable_with_v<_Tp,
61+
_Up,
62+
__void_t<decltype(swap(std::declval<_Tp>(), std::declval<_Up>())),
63+
decltype(swap(std::declval<_Up>(), std::declval<_Tp>()))> > = true;
7064

65+
#ifndef _LIBCPP_CXX03_LANG // C++03 doesn't have noexcept, so things are never nothrow swappable
7166
template <class _Tp, class _Up>
72-
struct __swappable_with<_Tp, _Up, false> : false_type {};
73-
74-
template <class _Tp, class _Up = _Tp, bool _Swappable = __swappable_with<_Tp, _Up>::value>
75-
struct __nothrow_swappable_with {
76-
static const bool value =
77-
#ifndef _LIBCPP_HAS_NO_NOEXCEPT
78-
noexcept(swap(std::declval<_Tp>(), std::declval<_Up>()))&& noexcept(
79-
swap(std::declval<_Up>(), std::declval<_Tp>()));
80-
#else
81-
false;
67+
inline const bool __is_nothrow_swappable_with_v<_Tp, _Up, true> =
68+
noexcept(swap(std::declval<_Tp>(), std::declval<_Up>())) &&
69+
noexcept(swap(std::declval<_Up>(), std::declval<_Tp>()));
8270
#endif
83-
};
8471

85-
template <class _Tp, class _Up>
86-
struct __nothrow_swappable_with<_Tp, _Up, false> : false_type {};
72+
#if _LIBCPP_STD_VER >= 17
8773

88-
} // namespace __detail
74+
template <class _Tp, class _Up>
75+
inline constexpr bool is_swappable_with_v = __is_swappable_with_v<_Tp, _Up>;
8976

90-
template <class _Tp>
91-
struct __is_swappable : public integral_constant<bool, __detail::__swappable_with<_Tp&>::value> {};
77+
template <class _Tp, class _Up>
78+
struct _LIBCPP_TEMPLATE_VIS is_swappable_with : bool_constant<is_swappable_with_v<_Tp, _Up>> {};
9279

9380
template <class _Tp>
94-
struct __is_nothrow_swappable : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp&>::value> {};
95-
96-
#if _LIBCPP_STD_VER >= 17
97-
98-
template <class _Tp, class _Up>
99-
struct _LIBCPP_TEMPLATE_VIS is_swappable_with
100-
: public integral_constant<bool, __detail::__swappable_with<_Tp, _Up>::value> {};
81+
inline constexpr bool is_swappable_v =
82+
is_swappable_with_v<__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<_Tp>>;
10183

10284
template <class _Tp>
103-
struct _LIBCPP_TEMPLATE_VIS is_swappable
104-
: public __conditional_t<__libcpp_is_referenceable<_Tp>::value,
105-
is_swappable_with<__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<_Tp> >,
106-
false_type> {};
85+
struct _LIBCPP_TEMPLATE_VIS is_swappable : bool_constant<is_swappable_v<_Tp>> {};
10786

10887
template <class _Tp, class _Up>
109-
struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable_with
110-
: public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp, _Up>::value> {};
111-
112-
template <class _Tp>
113-
struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable
114-
: public __conditional_t<__libcpp_is_referenceable<_Tp>::value,
115-
is_nothrow_swappable_with<__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<_Tp> >,
116-
false_type> {};
88+
inline constexpr bool is_nothrow_swappable_with_v = __is_nothrow_swappable_with_v<_Tp, _Up>;
11789

11890
template <class _Tp, class _Up>
119-
inline constexpr bool is_swappable_with_v = is_swappable_with<_Tp, _Up>::value;
91+
struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable_with : bool_constant<is_nothrow_swappable_with_v<_Tp, _Up>> {};
12092

12193
template <class _Tp>
122-
inline constexpr bool is_swappable_v = is_swappable<_Tp>::value;
123-
124-
template <class _Tp, class _Up>
125-
inline constexpr bool is_nothrow_swappable_with_v = is_nothrow_swappable_with<_Tp, _Up>::value;
94+
inline constexpr bool is_nothrow_swappable_v =
95+
is_nothrow_swappable_with_v<__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<_Tp>>;
12696

12797
template <class _Tp>
128-
inline constexpr bool is_nothrow_swappable_v = is_nothrow_swappable<_Tp>::value;
98+
struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable : bool_constant<is_nothrow_swappable_v<_Tp>> {};
12999

130100
#endif // _LIBCPP_STD_VER >= 17
131101

libcxx/include/__utility/pair.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -408,15 +408,15 @@ struct _LIBCPP_TEMPLATE_VIS pair
408408
#endif // _LIBCPP_CXX03_LANG
409409

410410
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(pair& __p)
411-
_NOEXCEPT_(__is_nothrow_swappable<first_type>::value&& __is_nothrow_swappable<second_type>::value) {
411+
_NOEXCEPT_(__is_nothrow_swappable_v<first_type>&& __is_nothrow_swappable_v<second_type>) {
412412
using std::swap;
413413
swap(first, __p.first);
414414
swap(second, __p.second);
415415
}
416416

417417
#if _LIBCPP_STD_VER >= 23
418418
_LIBCPP_HIDE_FROM_ABI constexpr void swap(const pair& __p) const
419-
noexcept(__is_nothrow_swappable<const first_type>::value && __is_nothrow_swappable<const second_type>::value) {
419+
noexcept(__is_nothrow_swappable_v<const first_type> && __is_nothrow_swappable_v<const second_type>) {
420420
using std::swap;
421421
swap(first, __p.first);
422422
swap(second, __p.second);
@@ -512,15 +512,15 @@ struct common_type<pair<_T1, _T2>, pair<_U1, _U2>> {
512512
};
513513
#endif // _LIBCPP_STD_VER >= 23
514514

515-
template <class _T1, class _T2, __enable_if_t<__is_swappable<_T1>::value && __is_swappable<_T2>::value, int> = 0>
515+
template <class _T1, class _T2, __enable_if_t<__is_swappable_v<_T1> && __is_swappable_v<_T2>, int> = 0>
516516
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y)
517-
_NOEXCEPT_(__is_nothrow_swappable<_T1>::value&& __is_nothrow_swappable<_T2>::value) {
517+
_NOEXCEPT_(__is_nothrow_swappable_v<_T1>&& __is_nothrow_swappable_v<_T2>) {
518518
__x.swap(__y);
519519
}
520520

521521
#if _LIBCPP_STD_VER >= 23
522522
template <class _T1, class _T2>
523-
requires(__is_swappable<const _T1>::value && __is_swappable<const _T2>::value)
523+
requires(__is_swappable_v<const _T1> && __is_swappable_v<const _T2>)
524524
_LIBCPP_HIDE_FROM_ABI constexpr void
525525
swap(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) noexcept(noexcept(__x.swap(__y))) {
526526
__x.swap(__y);

libcxx/include/__utility/swap.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ inline _LIBCPP_HIDE_FROM_ABI __swap_result_t<_Tp> _LIBCPP_CONSTEXPR_SINCE_CXX20
4444
__y = std::move(__t);
4545
}
4646

47-
template <class _Tp, size_t _Np, __enable_if_t<__is_swappable<_Tp>::value, int> >
47+
template <class _Tp, size_t _Np, __enable_if_t<__is_swappable_v<_Tp>, int> >
4848
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np])
49-
_NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) {
49+
_NOEXCEPT_(__is_nothrow_swappable_v<_Tp>) {
5050
for (size_t __i = 0; __i != _Np; ++__i) {
5151
swap(__a[__i], __b[__i]);
5252
}

libcxx/include/array

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,7 @@ struct _LIBCPP_TEMPLATE_VIS array {
192192
std::fill_n(data(), _Size, __u);
193193
}
194194

195-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(array& __a)
196-
_NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) {
195+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(array& __a) _NOEXCEPT_(__is_nothrow_swappable_v<_Tp>) {
197196
std::swap_ranges(data(), data() + _Size, __a.data());
198197
}
199198

@@ -428,7 +427,7 @@ operator<=>(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) {
428427

429428
#endif // _LIBCPP_STD_VER <= 17
430429

431-
template <class _Tp, size_t _Size, __enable_if_t<_Size == 0 || __is_swappable<_Tp>::value, int> = 0>
430+
template <class _Tp, size_t _Size, __enable_if_t<_Size == 0 || __is_swappable_v<_Tp>, int> = 0>
432431
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(array<_Tp, _Size>& __x, array<_Tp, _Size>& __y)
433432
_NOEXCEPT_(noexcept(__x.swap(__y))) {
434433
__x.swap(__y);

libcxx/include/deque

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ template <class T, class Allocator, class Predicate>
214214
#include <__type_traits/is_allocator.h>
215215
#include <__type_traits/is_convertible.h>
216216
#include <__type_traits/is_same.h>
217+
#include <__type_traits/is_swappable.h>
217218
#include <__type_traits/type_identity.h>
218219
#include <__utility/forward.h>
219220
#include <__utility/move.h>
@@ -794,7 +795,7 @@ public:
794795
#if _LIBCPP_STD_VER >= 14
795796
_NOEXCEPT;
796797
#else
797-
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable<allocator_type>::value);
798+
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>);
798799
#endif
799800
_LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT;
800801

@@ -2482,7 +2483,7 @@ inline void deque<_Tp, _Allocator>::swap(deque& __c)
24822483
#if _LIBCPP_STD_VER >= 14
24832484
_NOEXCEPT
24842485
#else
2485-
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable<allocator_type>::value)
2486+
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>)
24862487
#endif
24872488
{
24882489
__map_.swap(__c.__map_);

libcxx/include/experimental/propagate_const

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,7 @@ public:
266266

267267
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR element_type& operator*() { return *get(); }
268268

269-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR void swap(propagate_const& __pt)
270-
_NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) {
269+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR void swap(propagate_const& __pt) _NOEXCEPT_(__is_nothrow_swappable_v<_Tp>) {
271270
using std::swap;
272271
swap(__t_, __pt.__t_);
273272
}
@@ -391,7 +390,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator>=(const _Tp& __t, const pr
391390

392391
template <class _Tp>
393392
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR void swap(propagate_const<_Tp>& __pc1, propagate_const<_Tp>& __pc2)
394-
_NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) {
393+
_NOEXCEPT_(__is_nothrow_swappable_v<_Tp>) {
395394
__pc1.swap(__pc2);
396395
}
397396

0 commit comments

Comments
 (0)