summaryrefslogtreecommitdiffstats
path: root/libcxx/include/deque
diff options
context:
space:
mode:
authorHoward Hinnant <hhinnant@apple.com>2011-06-02 20:00:14 +0000
committerHoward Hinnant <hhinnant@apple.com>2011-06-02 20:00:14 +0000
commit9eebe11dd5572b1af5de487427d63614d39c2031 (patch)
tree973069f5a9a4deabf49c95b03773415ce0301a77 /libcxx/include/deque
parentaa318ae495e9429c71a7382e164991b0df02f763 (diff)
downloadbcm5719-llvm-9eebe11dd5572b1af5de487427d63614d39c2031.tar.gz
bcm5719-llvm-9eebe11dd5572b1af5de487427d63614d39c2031.zip
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.
llvm-svn: 132480
Diffstat (limited to 'libcxx/include/deque')
-rw-r--r--libcxx/include/deque46
1 files changed, 40 insertions, 6 deletions
diff --git a/libcxx/include/deque b/libcxx/include/deque
index 2063bd8786a..1ffd9d81d87 100644
--- a/libcxx/include/deque
+++ b/libcxx/include/deque
@@ -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);
}
OpenPOWER on IntegriCloud