I've become quite disatsified with the lack of noexcept specifications on container move construction, move assignment operator and swap. Without proper decoration on at least move construction, vectors of containers will have unacceptable performance. Here's the fix for deque.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@132480 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -930,21 +930,29 @@ protected:
|
||||
|
||||
__deque_base();
|
||||
explicit __deque_base(const allocator_type& __a);
|
||||
public:
|
||||
~__deque_base();
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
__deque_base(__deque_base&& __c);
|
||||
__deque_base(__deque_base&& __c)
|
||||
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
|
||||
__deque_base(__deque_base&& __c, const allocator_type& __a);
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
void swap(__deque_base& __c);
|
||||
void swap(__deque_base& __c)
|
||||
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value||
|
||||
__is_nothrow_swappable<allocator_type>::value);
|
||||
protected:
|
||||
void clear() _NOEXCEPT;
|
||||
|
||||
bool __invariants() const;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __move_assign(__deque_base& __c)
|
||||
_NOEXCEPT_(is_nothrow_move_assignable<__map>::value &&
|
||||
(!__alloc_traits::propagate_on_container_move_assignment::value ||
|
||||
is_nothrow_move_assignable<allocator_type>::value))
|
||||
{
|
||||
__map_ = _STD::move(__c.__map_);
|
||||
__start_ = __c.__start_;
|
||||
@@ -955,27 +963,33 @@ protected:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __move_assign_alloc(__deque_base& __c)
|
||||
_NOEXCEPT_(!__alloc_traits::propagate_on_container_move_assignment::value ||
|
||||
is_nothrow_move_assignable<allocator_type>::value)
|
||||
{__move_assign_alloc(__c, integral_constant<bool,
|
||||
__alloc_traits::propagate_on_container_move_assignment::value>());}
|
||||
|
||||
private:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __move_assign_alloc(const __deque_base& __c, true_type)
|
||||
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
|
||||
{
|
||||
__alloc() = _STD::move(__c.__alloc());
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __move_assign_alloc(const __deque_base& __c, false_type)
|
||||
void __move_assign_alloc(const __deque_base& __c, false_type) _NOEXCEPT
|
||||
{}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void __swap_alloc(allocator_type& __x, allocator_type& __y)
|
||||
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
|
||||
__is_nothrow_swappable<allocator_type>::value)
|
||||
{__swap_alloc(__x, __y, integral_constant<bool,
|
||||
__alloc_traits::propagate_on_container_swap::value>());}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void __swap_alloc(allocator_type& __x, allocator_type& __y, true_type)
|
||||
_NOEXCEPT_(__is_nothrow_swappable<allocator_type>::value)
|
||||
{
|
||||
using _STD::swap;
|
||||
swap(__x, __y);
|
||||
@@ -983,6 +997,7 @@ private:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void __swap_alloc(allocator_type& __x, allocator_type& __y, false_type)
|
||||
_NOEXCEPT
|
||||
{}
|
||||
};
|
||||
|
||||
@@ -1073,6 +1088,7 @@ __deque_base<_Tp, _Allocator>::~__deque_base()
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
__deque_base<_Tp, _Allocator>::__deque_base(__deque_base&& __c)
|
||||
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
|
||||
: __map_(_STD::move(__c.__map_)),
|
||||
__start_(_STD::move(__c.__start_)),
|
||||
__size_(_STD::move(__c.__size_))
|
||||
@@ -1105,6 +1121,8 @@ __deque_base<_Tp, _Allocator>::__deque_base(__deque_base&& __c, const allocator_
|
||||
template <class _Tp, class _Allocator>
|
||||
void
|
||||
__deque_base<_Tp, _Allocator>::swap(__deque_base& __c)
|
||||
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value||
|
||||
__is_nothrow_swappable<allocator_type>::value)
|
||||
{
|
||||
__map_.swap(__c.__map_);
|
||||
_STD::swap(__start_, __c.__start_);
|
||||
@@ -1183,9 +1201,14 @@ public:
|
||||
deque& operator=(initializer_list<value_type> __il) {assign(__il); return *this;}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
deque(deque&& __c);
|
||||
deque(deque&& __c) _NOEXCEPT_(is_nothrow_move_constructible<__base>::value);
|
||||
deque(deque&& __c, const allocator_type& __a);
|
||||
deque& operator=(deque&& __c);
|
||||
deque& operator=(deque&& __c)
|
||||
_NOEXCEPT_(
|
||||
(__alloc_traits::propagate_on_container_move_assignment::value &&
|
||||
is_nothrow_move_assignable<allocator_type>::value) ||
|
||||
(!__alloc_traits::propagate_on_container_move_assignment::value &&
|
||||
is_nothrow_move_assignable<value_type>::value));
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
template <class _InputIter>
|
||||
@@ -1290,7 +1313,9 @@ public:
|
||||
iterator erase(const_iterator __p);
|
||||
iterator erase(const_iterator __f, const_iterator __l);
|
||||
|
||||
void swap(deque& __c);
|
||||
void swap(deque& __c)
|
||||
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
|
||||
__is_nothrow_swappable<allocator_type>::value);
|
||||
void clear() _NOEXCEPT;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@@ -1448,6 +1473,7 @@ deque<_Tp, _Allocator>::operator=(const deque& __c)
|
||||
template <class _Tp, class _Allocator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
deque<_Tp, _Allocator>::deque(deque&& __c)
|
||||
_NOEXCEPT_(is_nothrow_move_constructible<__base>::value)
|
||||
: __base(_STD::move(__c))
|
||||
{
|
||||
}
|
||||
@@ -1468,6 +1494,11 @@ template <class _Tp, class _Allocator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
deque<_Tp, _Allocator>&
|
||||
deque<_Tp, _Allocator>::operator=(deque&& __c)
|
||||
_NOEXCEPT_(
|
||||
(__alloc_traits::propagate_on_container_move_assignment::value &&
|
||||
is_nothrow_move_assignable<allocator_type>::value) ||
|
||||
(!__alloc_traits::propagate_on_container_move_assignment::value &&
|
||||
is_nothrow_move_assignable<value_type>::value))
|
||||
{
|
||||
__move_assign(__c, integral_constant<bool,
|
||||
__alloc_traits::propagate_on_container_move_assignment::value>());
|
||||
@@ -2713,6 +2744,8 @@ template <class _Tp, class _Allocator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
deque<_Tp, _Allocator>::swap(deque& __c)
|
||||
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
|
||||
__is_nothrow_swappable<allocator_type>::value)
|
||||
{
|
||||
__base::swap(__c);
|
||||
}
|
||||
@@ -2778,6 +2811,7 @@ template <class _Tp, class _Allocator>
|
||||
_LIBCPP_INLINE_VISIBILITY inline
|
||||
void
|
||||
swap(deque<_Tp, _Allocator>& __x, deque<_Tp, _Allocator>& __y)
|
||||
_NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
|
||||
{
|
||||
__x.swap(__y);
|
||||
}
|
||||
|
Reference in New Issue
Block a user