Implement the first part of N4258: 'Cleaning up noexcept in the Library'. This patch deals with swapping containers, and implements a more strict noexcept specification (a conforming extension) than the standard mandates.
llvm-svn: 242056
diff --git a/libcxx/include/__hash_table b/libcxx/include/__hash_table
index d089bce..f3a2030 100644
--- a/libcxx/include/__hash_table
+++ b/libcxx/include/__hash_table
@@ -985,12 +985,14 @@
void swap(__hash_table& __u)
_NOEXCEPT_(
- (!allocator_traits<__pointer_allocator>::propagate_on_container_swap::value ||
- __is_nothrow_swappable<__pointer_allocator>::value) &&
- (!__node_traits::propagate_on_container_swap::value ||
- __is_nothrow_swappable<__node_allocator>::value) &&
- __is_nothrow_swappable<hasher>::value &&
- __is_nothrow_swappable<key_equal>::value);
+ __is_nothrow_swappable<hasher>::value && __is_nothrow_swappable<key_equal>::value
+#if _LIBCPP_STD_VER <= 11
+ && (!allocator_traits<__pointer_allocator>::propagate_on_container_swap::value
+ || __is_nothrow_swappable<__pointer_allocator>::value)
+ && (!__node_traits::propagate_on_container_swap::value
+ || __is_nothrow_swappable<__node_allocator>::value)
+#endif
+ );
_LIBCPP_INLINE_VISIBILITY
size_type max_bucket_count() const _NOEXCEPT
@@ -1118,38 +1120,6 @@
_LIBCPP_INLINE_VISIBILITY
void __move_assign_alloc(__hash_table&, false_type) _NOEXCEPT {}
- template <class _Ap>
- _LIBCPP_INLINE_VISIBILITY
- static
- void
- __swap_alloc(_Ap& __x, _Ap& __y)
- _NOEXCEPT_(
- !allocator_traits<_Ap>::propagate_on_container_swap::value ||
- __is_nothrow_swappable<_Ap>::value)
- {
- __swap_alloc(__x, __y,
- integral_constant<bool,
- allocator_traits<_Ap>::propagate_on_container_swap::value
- >());
- }
-
- template <class _Ap>
- _LIBCPP_INLINE_VISIBILITY
- static
- void
- __swap_alloc(_Ap& __x, _Ap& __y, true_type)
- _NOEXCEPT_(__is_nothrow_swappable<_Ap>::value)
- {
- using _VSTD::swap;
- swap(__x, __y);
- }
-
- template <class _Ap>
- _LIBCPP_INLINE_VISIBILITY
- static
- void
- __swap_alloc(_Ap&, _Ap&, false_type) _NOEXCEPT {}
-
void __deallocate(__node_pointer __np) _NOEXCEPT;
__node_pointer __detach() _NOEXCEPT;
@@ -2382,12 +2352,14 @@
void
__hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u)
_NOEXCEPT_(
- (!allocator_traits<__pointer_allocator>::propagate_on_container_swap::value ||
- __is_nothrow_swappable<__pointer_allocator>::value) &&
- (!__node_traits::propagate_on_container_swap::value ||
- __is_nothrow_swappable<__node_allocator>::value) &&
- __is_nothrow_swappable<hasher>::value &&
- __is_nothrow_swappable<key_equal>::value)
+ __is_nothrow_swappable<hasher>::value && __is_nothrow_swappable<key_equal>::value
+#if _LIBCPP_STD_VER <= 11
+ && (!allocator_traits<__pointer_allocator>::propagate_on_container_swap::value
+ || __is_nothrow_swappable<__pointer_allocator>::value)
+ && (!__node_traits::propagate_on_container_swap::value
+ || __is_nothrow_swappable<__node_allocator>::value)
+#endif
+ )
{
{
__node_pointer_pointer __npp = __bucket_list_.release();
@@ -2395,9 +2367,9 @@
__u.__bucket_list_.reset(__npp);
}
_VSTD::swap(__bucket_list_.get_deleter().size(), __u.__bucket_list_.get_deleter().size());
- __swap_alloc(__bucket_list_.get_deleter().__alloc(),
+ __swap_allocator(__bucket_list_.get_deleter().__alloc(),
__u.__bucket_list_.get_deleter().__alloc());
- __swap_alloc(__node_alloc(), __u.__node_alloc());
+ __swap_allocator(__node_alloc(), __u.__node_alloc());
_VSTD::swap(__p1_.first().__next_, __u.__p1_.first().__next_);
__p2_.swap(__u.__p2_);
__p3_.swap(__u.__p3_);