diff --git a/libcxx/include/__split_buffer b/libcxx/include/__split_buffer index ea9d3d0463ef..e68b78508cc6 100644 --- a/libcxx/include/__split_buffer +++ b/libcxx/include/__split_buffer @@ -47,10 +47,10 @@ public: typedef typename add_lvalue_reference::type __alloc_ref; typedef typename add_lvalue_reference::type __alloc_const_ref; - _LIBCPP_INLINE_VISIBILITY __alloc_rr& __alloc() {return __end_cap_.second();} - _LIBCPP_INLINE_VISIBILITY const __alloc_rr& __alloc() const {return __end_cap_.second();} - _LIBCPP_INLINE_VISIBILITY pointer& __end_cap() {return __end_cap_.first();} - _LIBCPP_INLINE_VISIBILITY const pointer& __end_cap() const {return __end_cap_.first();} + _LIBCPP_INLINE_VISIBILITY __alloc_rr& __alloc() _NOEXCEPT {return __end_cap_.second();} + _LIBCPP_INLINE_VISIBILITY const __alloc_rr& __alloc() const _NOEXCEPT {return __end_cap_.second();} + _LIBCPP_INLINE_VISIBILITY pointer& __end_cap() _NOEXCEPT {return __end_cap_.first();} + _LIBCPP_INLINE_VISIBILITY const pointer& __end_cap() const _NOEXCEPT {return __end_cap_.first();} __split_buffer(); explicit __split_buffer(__alloc_rr& __a); @@ -59,17 +59,23 @@ public: ~__split_buffer(); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - __split_buffer(__split_buffer&& __c); + __split_buffer(__split_buffer&& __c) + _NOEXCEPT_(is_nothrow_move_constructible::value); __split_buffer(__split_buffer&& __c, const __alloc_rr& __a); - __split_buffer& operator=(__split_buffer&& __c); + __split_buffer& operator=(__split_buffer&& __c) + _NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value && + is_nothrow_move_assignable::value) || + !__alloc_traits::propagate_on_container_move_assignment::value); #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES - _LIBCPP_INLINE_VISIBILITY iterator begin() {return __begin_;} - _LIBCPP_INLINE_VISIBILITY const_iterator begin() const {return __begin_;} - _LIBCPP_INLINE_VISIBILITY iterator end() {return __end_;} - _LIBCPP_INLINE_VISIBILITY const_iterator end() const {return __end_;} + _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT {return __begin_;} + _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT {return __begin_;} + _LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT {return __end_;} + _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT {return __end_;} - _LIBCPP_INLINE_VISIBILITY void clear() {__destruct_at_end(__begin_);} + _LIBCPP_INLINE_VISIBILITY + void clear() _NOEXCEPT + {__destruct_at_end(__begin_);} _LIBCPP_INLINE_VISIBILITY size_type size() const {return static_cast(__end_ - __begin_);} _LIBCPP_INLINE_VISIBILITY bool empty() const {return __end_ == __begin_;} _LIBCPP_INLINE_VISIBILITY size_type capacity() const {return static_cast(__end_cap() - __first_);} @@ -82,7 +88,7 @@ public: _LIBCPP_INLINE_VISIBILITY const_reference back() const {return *(__end_ - 1);} void reserve(size_type __n); - void shrink_to_fit(); + void shrink_to_fit() _NOEXCEPT; void push_front(const_reference __x); void push_back(const_reference __x); #if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) @@ -120,40 +126,47 @@ public: void __destruct_at_begin(pointer __new_begin, false_type); void __destruct_at_begin(pointer __new_begin, true_type); - _LIBCPP_INLINE_VISIBILITY void __destruct_at_end(pointer __new_last) + _LIBCPP_INLINE_VISIBILITY + void __destruct_at_end(pointer __new_last) _NOEXCEPT {__destruct_at_end(__new_last, is_trivially_destructible());} - void __destruct_at_end(pointer __new_last, false_type); - void __destruct_at_end(pointer __new_last, true_type); + void __destruct_at_end(pointer __new_last, false_type) _NOEXCEPT; + void __destruct_at_end(pointer __new_last, true_type) _NOEXCEPT; - void swap(__split_buffer& __x); + void swap(__split_buffer& __x) + _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value|| + __is_nothrow_swappable<__alloc_rr>::value); bool __invariants() const; private: _LIBCPP_INLINE_VISIBILITY void __move_assign_alloc(const __split_buffer& __c, true_type) + _NOEXCEPT_(is_nothrow_move_assignable::value) { __alloc() = _STD::move(__c.__alloc()); } _LIBCPP_INLINE_VISIBILITY - void __move_assign_alloc(const __split_buffer& __c, false_type) + void __move_assign_alloc(const __split_buffer& __c, false_type) _NOEXCEPT {} _LIBCPP_INLINE_VISIBILITY static void __swap_alloc(__alloc_rr& __x, __alloc_rr& __y) + _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value|| + __is_nothrow_swappable<__alloc_rr>::value) {__swap_alloc(__x, __y, integral_constant());} _LIBCPP_INLINE_VISIBILITY static void __swap_alloc(__alloc_rr& __x, __alloc_rr& __y, true_type) + _NOEXCEPT_(__is_nothrow_swappable<__alloc_rr>::value) { using _STD::swap; swap(__x, __y); } _LIBCPP_INLINE_VISIBILITY - static void __swap_alloc(__alloc_rr& __x, __alloc_rr& __y, false_type) + static void __swap_alloc(__alloc_rr& __x, __alloc_rr& __y, false_type) _NOEXCEPT {} }; @@ -284,7 +297,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, true_t template _LIBCPP_INLINE_VISIBILITY inline void -__split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_type) +__split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_type) _NOEXCEPT { while (__new_last < __end_) __alloc_traits::destroy(__alloc(), --__end_); @@ -293,7 +306,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_typ template _LIBCPP_INLINE_VISIBILITY inline void -__split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, true_type) +__split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, true_type) _NOEXCEPT { __end_ = __new_last; } @@ -340,6 +353,7 @@ __split_buffer<_Tp, _Allocator>::~__split_buffer() template __split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c) + _NOEXCEPT_(is_nothrow_move_constructible::value) : __first_(_STD::move(__c.__first_)), __begin_(_STD::move(__c.__begin_)), __end_(_STD::move(__c.__end_)), @@ -380,6 +394,9 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c, const __al template __split_buffer<_Tp, _Allocator>& __split_buffer<_Tp, _Allocator>::operator=(__split_buffer&& __c) + _NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value && + is_nothrow_move_assignable::value) || + !__alloc_traits::propagate_on_container_move_assignment::value) { clear(); shrink_to_fit(); @@ -399,6 +416,8 @@ __split_buffer<_Tp, _Allocator>::operator=(__split_buffer&& __c) template void __split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x) + _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value|| + __is_nothrow_swappable<__alloc_rr>::value) { _STD::swap(__first_, __x.__first_); _STD::swap(__begin_, __x.__begin_); @@ -425,7 +444,7 @@ __split_buffer<_Tp, _Allocator>::reserve(size_type __n) template void -__split_buffer<_Tp, _Allocator>::shrink_to_fit() +__split_buffer<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT { if (capacity() > size()) { @@ -612,6 +631,16 @@ __split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args) #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +template +_LIBCPP_INLINE_VISIBILITY inline +void +swap(__split_buffer<_Tp, _Allocator>& __x, __split_buffer<_Tp, _Allocator>& __y) + _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) +{ + __x.swap(__y); +} + + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_SPLIT_BUFFER diff --git a/libcxx/include/deque b/libcxx/include/deque index 2063bd8786a0..1ffd9d81d876 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::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::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::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::value) {__move_assign_alloc(__c, integral_constant());} private: _LIBCPP_INLINE_VISIBILITY void __move_assign_alloc(const __deque_base& __c, true_type) + _NOEXCEPT_(is_nothrow_move_assignable::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::value) {__swap_alloc(__x, __y, integral_constant());} _LIBCPP_INLINE_VISIBILITY static void __swap_alloc(allocator_type& __x, allocator_type& __y, true_type) + _NOEXCEPT_(__is_nothrow_swappable::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 __deque_base<_Tp, _Allocator>::__deque_base(__deque_base&& __c) + _NOEXCEPT_(is_nothrow_move_constructible::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 void __deque_base<_Tp, _Allocator>::swap(__deque_base& __c) + _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value|| + __is_nothrow_swappable::value) { __map_.swap(__c.__map_); _STD::swap(__start_, __c.__start_); @@ -1183,9 +1201,14 @@ public: deque& operator=(initializer_list __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::value) || + (!__alloc_traits::propagate_on_container_move_assignment::value && + is_nothrow_move_assignable::value)); #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template @@ -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::value); void clear() _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY @@ -1448,6 +1473,7 @@ deque<_Tp, _Allocator>::operator=(const deque& __c) template 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 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::value) || + (!__alloc_traits::propagate_on_container_move_assignment::value && + is_nothrow_move_assignable::value)) { __move_assign(__c, integral_constant()); @@ -2713,6 +2744,8 @@ template inline _LIBCPP_INLINE_VISIBILITY void deque<_Tp, _Allocator>::swap(deque& __c) + _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || + __is_nothrow_swappable::value) { __base::swap(__c); } @@ -2778,6 +2811,7 @@ template _LIBCPP_INLINE_VISIBILITY inline void swap(deque<_Tp, _Allocator>& __x, deque<_Tp, _Allocator>& __y) + _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) { __x.swap(__y); }