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.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@242056 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -985,12 +985,14 @@ public:
|
||||
|
||||
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 @@ private:
|
||||
_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 @@ template <class _Tp, class _Hash, class _Equal, class _Alloc>
|
||||
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 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u)
|
||||
__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_);
|
||||
|
Reference in New Issue
Block a user