Skip to content

Commit 11fccc6

Browse files
committed
[libc++] Simplify a bunch of noexcept specifications
1 parent ad31e11 commit 11fccc6

File tree

28 files changed

+194
-651
lines changed

28 files changed

+194
-651
lines changed

libcxx/include/__hash_table

Lines changed: 17 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -518,13 +518,13 @@ public:
518518
_LIBCPP_HIDE_FROM_ABI __bucket_list_deallocator() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
519519
: __size_(0) {}
520520

521-
_LIBCPP_HIDE_FROM_ABI __bucket_list_deallocator(const allocator_type& __a, size_type __size)
522-
_NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
523-
: __size_(__size), __alloc_(__a) {}
521+
_LIBCPP_HIDE_FROM_ABI __bucket_list_deallocator(const allocator_type& __a, size_type __size) _NOEXCEPT
522+
: __size_(__size),
523+
__alloc_(__a) {}
524524

525-
_LIBCPP_HIDE_FROM_ABI __bucket_list_deallocator(__bucket_list_deallocator&& __x)
526-
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
527-
: __size_(std::move(__x.__size_)), __alloc_(std::move(__x.__alloc_)) {
525+
_LIBCPP_HIDE_FROM_ABI __bucket_list_deallocator(__bucket_list_deallocator&& __x) _NOEXCEPT
526+
: __size_(std::move(__x.__size_)),
527+
__alloc_(std::move(__x.__alloc_)) {
528528
__x.size() = 0;
529529
}
530530

@@ -740,17 +740,14 @@ public:
740740
_LIBCPP_HIDE_FROM_ABI __hash_table(const __hash_table& __u, const allocator_type& __a);
741741
_LIBCPP_HIDE_FROM_ABI __hash_table(__hash_table&& __u) _NOEXCEPT_(
742742
is_nothrow_move_constructible<__bucket_list>::value&& is_nothrow_move_constructible<__first_node>::value&&
743-
is_nothrow_move_constructible<__node_allocator>::value&& is_nothrow_move_constructible<hasher>::value&&
744-
is_nothrow_move_constructible<key_equal>::value);
743+
is_nothrow_move_constructible<hasher>::value&& is_nothrow_move_constructible<key_equal>::value);
745744
_LIBCPP_HIDE_FROM_ABI __hash_table(__hash_table&& __u, const allocator_type& __a);
746745
_LIBCPP_HIDE_FROM_ABI ~__hash_table();
747746

748747
_LIBCPP_HIDE_FROM_ABI __hash_table& operator=(const __hash_table& __u);
749748
_LIBCPP_HIDE_FROM_ABI __hash_table& operator=(__hash_table&& __u)
750-
_NOEXCEPT_(is_nothrow_move_assignable<hasher>::value&& is_nothrow_move_assignable<key_equal>::value &&
751-
((__node_traits::propagate_on_container_move_assignment::value &&
752-
is_nothrow_move_assignable<__node_allocator>::value) ||
753-
allocator_traits<__node_allocator>::is_always_equal::value));
749+
_NOEXCEPT_(is_nothrow_move_assignable<hasher>::value&& is_nothrow_move_assignable<key_equal>::value&&
750+
__is_allocator_aware_container_move_nothrow_v<allocator_type>);
754751
template <class _InputIterator>
755752
_LIBCPP_HIDE_FROM_ABI void __assign_unique(_InputIterator __first, _InputIterator __last);
756753
template <class _InputIterator>
@@ -944,14 +941,7 @@ public:
944941
_LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> __equal_range_multi(const _Key& __k) const;
945942

946943
_LIBCPP_HIDE_FROM_ABI void swap(__hash_table& __u)
947-
#if _LIBCPP_STD_VER <= 11
948-
_NOEXCEPT_(__is_nothrow_swappable_v<hasher>&& __is_nothrow_swappable_v<key_equal> &&
949-
(!allocator_traits<__pointer_allocator>::propagate_on_container_swap::value ||
950-
__is_nothrow_swappable_v<__pointer_allocator>) &&
951-
(!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>));
952-
#else
953944
_NOEXCEPT_(__is_nothrow_swappable_v<hasher>&& __is_nothrow_swappable_v<key_equal>);
954-
#endif
955945

956946
_LIBCPP_HIDE_FROM_ABI size_type max_bucket_count() const _NOEXCEPT { return max_size(); }
957947
_LIBCPP_HIDE_FROM_ABI size_type bucket_size(size_type __n) const;
@@ -1011,15 +1001,11 @@ private:
10111001

10121002
_LIBCPP_HIDE_FROM_ABI void __move_assign(__hash_table& __u, false_type);
10131003
_LIBCPP_HIDE_FROM_ABI void __move_assign(__hash_table& __u, true_type)
1014-
_NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value&& is_nothrow_move_assignable<hasher>::value&&
1015-
is_nothrow_move_assignable<key_equal>::value);
1016-
_LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__hash_table& __u) _NOEXCEPT_(
1017-
!__node_traits::propagate_on_container_move_assignment::value ||
1018-
(is_nothrow_move_assignable<__pointer_allocator>::value && is_nothrow_move_assignable<__node_allocator>::value)) {
1004+
_NOEXCEPT_(is_nothrow_move_assignable<hasher>::value&& is_nothrow_move_assignable<key_equal>::value);
1005+
_LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__hash_table& __u) _NOEXCEPT {
10191006
__move_assign_alloc(__u, integral_constant<bool, __node_traits::propagate_on_container_move_assignment::value>());
10201007
}
1021-
_LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__hash_table& __u, true_type) _NOEXCEPT_(
1022-
is_nothrow_move_assignable<__pointer_allocator>::value&& is_nothrow_move_assignable<__node_allocator>::value) {
1008+
_LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__hash_table& __u, true_type) _NOEXCEPT {
10231009
__bucket_list_.get_deleter().__alloc() = std::move(__u.__bucket_list_.get_deleter().__alloc());
10241010
__node_alloc() = std::move(__u.__node_alloc());
10251011
}
@@ -1132,8 +1118,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const __hash_table& __u,
11321118
template <class _Tp, class _Hash, class _Equal, class _Alloc>
11331119
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u) _NOEXCEPT_(
11341120
is_nothrow_move_constructible<__bucket_list>::value&& is_nothrow_move_constructible<__first_node>::value&&
1135-
is_nothrow_move_constructible<__node_allocator>::value&& is_nothrow_move_constructible<hasher>::value&&
1136-
is_nothrow_move_constructible<key_equal>::value)
1121+
is_nothrow_move_constructible<hasher>::value&& is_nothrow_move_constructible<key_equal>::value)
11371122
: __bucket_list_(std::move(__u.__bucket_list_)),
11381123
__first_node_(std::move(__u.__first_node_)),
11391124
__node_alloc_(std::move(__u.__node_alloc_)),
@@ -1278,8 +1263,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__detach() _NOEXCEPT {
12781263

12791264
template <class _Tp, class _Hash, class _Equal, class _Alloc>
12801265
void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(__hash_table& __u, true_type)
1281-
_NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value&& is_nothrow_move_assignable<hasher>::value&&
1282-
is_nothrow_move_assignable<key_equal>::value) {
1266+
_NOEXCEPT_(is_nothrow_move_assignable<hasher>::value&& is_nothrow_move_assignable<key_equal>::value) {
12831267
clear();
12841268
__bucket_list_.reset(__u.__bucket_list_.release());
12851269
__bucket_list_.get_deleter().size() = __u.__bucket_list_.get_deleter().size();
@@ -1324,10 +1308,8 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(__hash_table& __u,
13241308

13251309
template <class _Tp, class _Hash, class _Equal, class _Alloc>
13261310
inline __hash_table<_Tp, _Hash, _Equal, _Alloc>& __hash_table<_Tp, _Hash, _Equal, _Alloc>::operator=(__hash_table&& __u)
1327-
_NOEXCEPT_(is_nothrow_move_assignable<hasher>::value&& is_nothrow_move_assignable<key_equal>::value &&
1328-
((__node_traits::propagate_on_container_move_assignment::value &&
1329-
is_nothrow_move_assignable<__node_allocator>::value) ||
1330-
allocator_traits<__node_allocator>::is_always_equal::value)) {
1311+
_NOEXCEPT_(is_nothrow_move_assignable<hasher>::value&& is_nothrow_move_assignable<key_equal>::value&&
1312+
__is_allocator_aware_container_move_nothrow_v<allocator_type>) {
13311313
__move_assign(__u, integral_constant<bool, __node_traits::propagate_on_container_move_assignment::value>());
13321314
return *this;
13331315
}
@@ -2060,15 +2042,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__equal_range_multi(const _Key& __k) c
20602042

20612043
template <class _Tp, class _Hash, class _Equal, class _Alloc>
20622044
void __hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u)
2063-
#if _LIBCPP_STD_VER <= 11
2064-
_NOEXCEPT_(__is_nothrow_swappable_v<hasher>&& __is_nothrow_swappable_v<key_equal> &&
2065-
(!allocator_traits<__pointer_allocator>::propagate_on_container_swap::value ||
2066-
__is_nothrow_swappable_v<__pointer_allocator>) &&
2067-
(!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>))
2068-
#else
2069-
_NOEXCEPT_(__is_nothrow_swappable_v<hasher>&& __is_nothrow_swappable_v<key_equal>)
2070-
#endif
2071-
{
2045+
_NOEXCEPT_(__is_nothrow_swappable_v<hasher>&& __is_nothrow_swappable_v<key_equal>) {
20722046
_LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
20732047
__node_traits::propagate_on_container_swap::value || this->__node_alloc() == __u.__node_alloc(),
20742048
"unordered container::swap: Either propagate_on_container_swap "

libcxx/include/__memory/allocator_traits.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,10 @@ inline const bool __is_cpp17_copy_insertable_v =
374374
(!__is_std_allocator_v<_Alloc> &&
375375
__has_construct_v<_Alloc, typename _Alloc::value_type*, const typename _Alloc::value_type&>));
376376

377+
template <typename _Alloc, typename _Traits = allocator_traits<_Alloc> >
378+
inline const bool __is_allocator_aware_container_move_nothrow_v =
379+
_Traits::propagate_on_container_move_assignment::value || _Traits::is_always_equal::value;
380+
377381
_LIBCPP_END_NAMESPACE_STD
378382

379383
_LIBCPP_POP_MACROS

libcxx/include/__memory/noexcept_move_assign_container.h

Lines changed: 0 additions & 37 deletions
This file was deleted.

libcxx/include/__split_buffer

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
#include <__type_traits/conditional.h>
2929
#include <__type_traits/enable_if.h>
3030
#include <__type_traits/integral_constant.h>
31-
#include <__type_traits/is_nothrow_assignable.h>
32-
#include <__type_traits/is_nothrow_constructible.h>
3331
#include <__type_traits/is_swappable.h>
3432
#include <__type_traits/is_trivially_destructible.h>
3533
#include <__type_traits/is_trivially_relocatable.h>
@@ -184,8 +182,7 @@ public:
184182
}
185183

186184
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
187-
__copy_without_alloc(__split_buffer_pointer_layout const& __other)
188-
_NOEXCEPT_(is_nothrow_copy_assignable<pointer>::value) {
185+
__copy_without_alloc(__split_buffer_pointer_layout const& __other) _NOEXCEPT {
189186
__front_cap_ = __other.__front_cap_;
190187
__begin_ = __other.__begin_;
191188
__end_ = __other.__end_;
@@ -341,8 +338,7 @@ public:
341338
}
342339

343340
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
344-
__copy_without_alloc(__split_buffer_size_layout const& __other)
345-
_NOEXCEPT_(is_nothrow_copy_assignable<pointer>::value) {
341+
__copy_without_alloc(__split_buffer_size_layout const& __other) _NOEXCEPT {
346342
__front_cap_ = __other.__front_cap_;
347343
__begin_ = __other.__begin_;
348344
__cap_ = __other.__cap_;
@@ -497,15 +493,11 @@ public:
497493
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
498494
__split_buffer(size_type __cap, size_type __start, __alloc_rr& __a);
499495

500-
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer(__split_buffer&& __c)
501-
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
496+
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer(__split_buffer&& __c) _NOEXCEPT;
502497

503498
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer(__split_buffer&& __c, const __alloc_rr& __a);
504499

505-
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer& operator=(__split_buffer&& __c)
506-
_NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value &&
507-
is_nothrow_move_assignable<allocator_type>::value) ||
508-
!__alloc_traits::propagate_on_container_move_assignment::value);
500+
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer& operator=(__split_buffer&& __c) _NOEXCEPT;
509501

510502
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~__split_buffer();
511503

@@ -559,8 +551,7 @@ public:
559551
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __destruct_at_end(pointer __new_last, false_type) _NOEXCEPT;
560552
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __destruct_at_end(pointer __new_last, true_type) _NOEXCEPT;
561553

562-
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void swap(__split_buffer& __x)
563-
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__alloc_rr>);
554+
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void swap(__split_buffer& __x) _NOEXCEPT;
564555

565556
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool __invariants() const {
566557
if (__front_cap() == nullptr) {
@@ -594,8 +585,8 @@ public:
594585
}
595586

596587
private:
597-
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__split_buffer& __c, true_type)
598-
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) {
588+
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
589+
__move_assign_alloc(__split_buffer& __c, true_type) _NOEXCEPT {
599590
__get_allocator() = std::move(__c.__get_allocator());
600591
}
601592

@@ -740,8 +731,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 __split_buffer<_Tp, _Allocator, _Layout>::~__split
740731
}
741732

742733
template <class _Tp, class _Allocator, template <class, class, class> class _Layout>
743-
_LIBCPP_CONSTEXPR_SINCE_CXX20 __split_buffer<_Tp, _Allocator, _Layout>::__split_buffer(__split_buffer&& __c)
744-
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
734+
_LIBCPP_CONSTEXPR_SINCE_CXX20 __split_buffer<_Tp, _Allocator, _Layout>::__split_buffer(__split_buffer&& __c) _NOEXCEPT
745735
: __base_type(std::move(__c)) {
746736
__c.__reset();
747737
}
@@ -767,10 +757,7 @@ __split_buffer<_Tp, _Allocator, _Layout>::__split_buffer(__split_buffer&& __c, c
767757

768758
template <class _Tp, class _Allocator, template <class, class, class> class _Layout>
769759
_LIBCPP_CONSTEXPR_SINCE_CXX20 __split_buffer<_Tp, _Allocator, _Layout>&
770-
__split_buffer<_Tp, _Allocator, _Layout>::operator=(__split_buffer&& __c)
771-
_NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value &&
772-
is_nothrow_move_assignable<allocator_type>::value) ||
773-
!__alloc_traits::propagate_on_container_move_assignment::value) {
760+
__split_buffer<_Tp, _Allocator, _Layout>::operator=(__split_buffer&& __c) _NOEXCEPT {
774761
clear();
775762
shrink_to_fit();
776763
__copy_without_alloc(__c);
@@ -780,8 +767,7 @@ __split_buffer<_Tp, _Allocator, _Layout>::operator=(__split_buffer&& __c)
780767
}
781768

782769
template <class _Tp, class _Allocator, template <class, class, class> class _Layout>
783-
_LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator, _Layout>::swap(__split_buffer& __x)
784-
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__alloc_rr>) {
770+
_LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator, _Layout>::swap(__split_buffer& __x) _NOEXCEPT {
785771
__base_type::swap(__x);
786772
}
787773

@@ -852,8 +838,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator, _Layout>::emp
852838

853839
template <class _Tp, class _Allocator, template <class, class, class> class _Layout>
854840
_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI void
855-
swap(__split_buffer<_Tp, _Allocator, _Layout>& __x, __split_buffer<_Tp, _Allocator, _Layout>& __y)
856-
_NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {
841+
swap(__split_buffer<_Tp, _Allocator, _Layout>& __x, __split_buffer<_Tp, _Allocator, _Layout>& __y) _NOEXCEPT {
857842
__x.swap(__y);
858843
}
859844

0 commit comments

Comments
 (0)