diff options
author | Howard Hinnant <hhinnant@apple.com> | 2011-06-04 14:31:57 +0000 |
---|---|---|
committer | Howard Hinnant <hhinnant@apple.com> | 2011-06-04 14:31:57 +0000 |
commit | 1052ee39cbaf1a8e47df0b5b6a63d5b492367dfb (patch) | |
tree | 0d8b8ef44bace592be18400fb065095c92b26fbf | |
parent | 4f163dfed1e6198cdd3bfd65c85ff16a48528c6a (diff) | |
download | bcm5719-llvm-1052ee39cbaf1a8e47df0b5b6a63d5b492367dfb.tar.gz bcm5719-llvm-1052ee39cbaf1a8e47df0b5b6a63d5b492367dfb.zip |
noexcept for <map>.
llvm-svn: 132639
12 files changed, 752 insertions, 92 deletions
diff --git a/libcxx/include/__tree b/libcxx/include/__tree index edba15a3389..a325d9d5f08 100644 --- a/libcxx/include/__tree +++ b/libcxx/include/__tree @@ -632,7 +632,7 @@ public: #endif pointer; - _LIBCPP_INLINE_VISIBILITY __tree_iterator() {} + _LIBCPP_INLINE_VISIBILITY __tree_iterator() _NOEXCEPT {} _LIBCPP_INLINE_VISIBILITY reference operator*() const {return __ptr_->__value_;} _LIBCPP_INLINE_VISIBILITY pointer operator->() const {return &__ptr_->__value_;} @@ -662,7 +662,7 @@ public: private: _LIBCPP_INLINE_VISIBILITY - explicit __tree_iterator(__node_pointer __p) : __ptr_(__p) {} + explicit __tree_iterator(__node_pointer __p) _NOEXCEPT : __ptr_(__p) {} template <class, class, class> friend class __tree; template <class, class, class> friend class _LIBCPP_VISIBLE __tree_const_iterator; template <class> friend class _LIBCPP_VISIBLE __map_iterator; @@ -716,7 +716,8 @@ private: __non_const_iterator; public: _LIBCPP_INLINE_VISIBILITY - __tree_const_iterator(__non_const_iterator __p) : __ptr_(__p.__ptr_) {} + __tree_const_iterator(__non_const_iterator __p) _NOEXCEPT + : __ptr_(__p.__ptr_) {} _LIBCPP_INLINE_VISIBILITY reference operator*() const {return __ptr_->__value_;} _LIBCPP_INLINE_VISIBILITY pointer operator->() const {return &__ptr_->__value_;} @@ -746,7 +747,8 @@ public: private: _LIBCPP_INLINE_VISIBILITY - explicit __tree_const_iterator(__node_pointer __p) : __ptr_(__p) {} + explicit __tree_const_iterator(__node_pointer __p) _NOEXCEPT + : __ptr_(__p) {} template <class, class, class> friend class __tree; template <class, class, class, class> friend class _LIBCPP_VISIBLE map; template <class, class, class, class> friend class _LIBCPP_VISIBLE multimap; @@ -805,7 +807,7 @@ private: public: _LIBCPP_INLINE_VISIBILITY - __node_pointer __end_node() + __node_pointer __end_node() _NOEXCEPT { return static_cast<__node_pointer> ( @@ -813,7 +815,7 @@ public: ); } _LIBCPP_INLINE_VISIBILITY - __node_const_pointer __end_node() const + __node_const_pointer __end_node() const _NOEXCEPT { return static_cast<__node_const_pointer> ( @@ -821,39 +823,45 @@ public: ); } _LIBCPP_INLINE_VISIBILITY - __node_allocator& __node_alloc() {return __pair1_.second();} + __node_allocator& __node_alloc() _NOEXCEPT {return __pair1_.second();} private: _LIBCPP_INLINE_VISIBILITY - const __node_allocator& __node_alloc() const {return __pair1_.second();} + const __node_allocator& __node_alloc() const _NOEXCEPT + {return __pair1_.second();} _LIBCPP_INLINE_VISIBILITY - __node_pointer& __begin_node() {return __begin_node_;} + __node_pointer& __begin_node() _NOEXCEPT {return __begin_node_;} _LIBCPP_INLINE_VISIBILITY - const __node_pointer& __begin_node() const {return __begin_node_;} + const __node_pointer& __begin_node() const _NOEXCEPT {return __begin_node_;} public: _LIBCPP_INLINE_VISIBILITY - allocator_type __alloc() const {return allocator_type(__node_alloc());} + allocator_type __alloc() const _NOEXCEPT + {return allocator_type(__node_alloc());} private: _LIBCPP_INLINE_VISIBILITY - size_type& size() {return __pair3_.first();} + size_type& size() _NOEXCEPT {return __pair3_.first();} public: _LIBCPP_INLINE_VISIBILITY - const size_type& size() const {return __pair3_.first();} + const size_type& size() const _NOEXCEPT {return __pair3_.first();} _LIBCPP_INLINE_VISIBILITY - value_compare& value_comp() {return __pair3_.second();} + value_compare& value_comp() _NOEXCEPT {return __pair3_.second();} _LIBCPP_INLINE_VISIBILITY - const value_compare& value_comp() const {return __pair3_.second();} + const value_compare& value_comp() const _NOEXCEPT + {return __pair3_.second();} public: _LIBCPP_INLINE_VISIBILITY - __node_pointer __root() + __node_pointer __root() _NOEXCEPT {return static_cast<__node_pointer> (__end_node()->__left_);} _LIBCPP_INLINE_VISIBILITY - __node_const_pointer __root() const + __node_const_pointer __root() const _NOEXCEPT {return static_cast<__node_const_pointer>(__end_node()->__left_);} typedef __tree_iterator<value_type, __node_pointer, difference_type> iterator; typedef __tree_const_iterator<value_type, __node_const_pointer, difference_type> const_iterator; - explicit __tree(const value_compare& __comp); + explicit __tree(const value_compare& __comp) + _NOEXCEPT_( + is_nothrow_default_constructible<__node_allocator>::value && + is_nothrow_copy_constructible<value_compare>::value); explicit __tree(const allocator_type& __a); __tree(const value_compare& __comp, const allocator_type& __a); __tree(const __tree& __t); @@ -863,28 +871,40 @@ public: template <class _InputIterator> void __assign_multi(_InputIterator __first, _InputIterator __last); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - __tree(__tree&& __t); + __tree(__tree&& __t) + _NOEXCEPT_( + is_nothrow_move_constructible<__node_allocator>::value && + is_nothrow_move_constructible<value_compare>::value); __tree(__tree&& __t, const allocator_type& __a); - __tree& operator=(__tree&& __t); + __tree& operator=(__tree&& __t) + _NOEXCEPT_( + __node_traits::propagate_on_container_move_assignment::value && + is_nothrow_move_assignable<value_compare>::value && + is_nothrow_move_assignable<__node_allocator>::value); #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES ~__tree(); _LIBCPP_INLINE_VISIBILITY - iterator begin() {return iterator(__begin_node());} + iterator begin() _NOEXCEPT {return iterator(__begin_node());} _LIBCPP_INLINE_VISIBILITY - const_iterator begin() const {return const_iterator(__begin_node());} + const_iterator begin() const _NOEXCEPT {return const_iterator(__begin_node());} _LIBCPP_INLINE_VISIBILITY - iterator end() {return iterator(__end_node());} + iterator end() _NOEXCEPT {return iterator(__end_node());} _LIBCPP_INLINE_VISIBILITY - const_iterator end() const {return const_iterator(__end_node());} + const_iterator end() const _NOEXCEPT {return const_iterator(__end_node());} _LIBCPP_INLINE_VISIBILITY - size_type max_size() const {return __node_traits::max_size(__node_alloc());} + size_type max_size() const _NOEXCEPT + {return __node_traits::max_size(__node_alloc());} - void clear(); + void clear() _NOEXCEPT; - void swap(__tree& __t); + void swap(__tree& __t) + _NOEXCEPT_( + __is_nothrow_swappable<value_compare>::value && + (!__node_traits::propagate_on_container_swap::value || + __is_nothrow_swappable<__node_allocator>::value)); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_VARIADICS @@ -1019,7 +1039,7 @@ private: __node_holder __construct_node(const value_type& __v); #endif - void destroy(__node_pointer __nd); + void destroy(__node_pointer __nd) _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY void __copy_assign_alloc(const __tree& __t) @@ -1033,31 +1053,42 @@ private: void __copy_assign_alloc(const __tree& __t, false_type) {} void __move_assign(__tree& __t, false_type); - void __move_assign(__tree& __t, true_type); + void __move_assign(__tree& __t, true_type) + _NOEXCEPT_(is_nothrow_move_assignable<value_compare>::value && + is_nothrow_move_assignable<__node_allocator>::value); _LIBCPP_INLINE_VISIBILITY void __move_assign_alloc(__tree& __t) + _NOEXCEPT_( + !__node_traits::propagate_on_container_move_assignment::value || + is_nothrow_move_assignable<__node_allocator>::value) {__move_assign_alloc(__t, integral_constant<bool, __node_traits::propagate_on_container_move_assignment::value>());} _LIBCPP_INLINE_VISIBILITY void __move_assign_alloc(__tree& __t, true_type) + _NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value) {__node_alloc() = _STD::move(__t.__node_alloc());} _LIBCPP_INLINE_VISIBILITY - void __move_assign_alloc(__tree& __t, false_type) {} + void __move_assign_alloc(__tree& __t, false_type) _NOEXCEPT {} _LIBCPP_INLINE_VISIBILITY static void __swap_alloc(__node_allocator& __x, __node_allocator& __y) + _NOEXCEPT_( + !__node_traits::propagate_on_container_swap::value || + __is_nothrow_swappable<__node_allocator>::value) {__swap_alloc(__x, __y, integral_constant<bool, __node_traits::propagate_on_container_swap::value>());} _LIBCPP_INLINE_VISIBILITY static void __swap_alloc(__node_allocator& __x, __node_allocator& __y, true_type) + _NOEXCEPT_(__is_nothrow_swappable<__node_allocator>::value) { using _STD::swap; swap(__x, __y); } _LIBCPP_INLINE_VISIBILITY static void __swap_alloc(__node_allocator& __x, __node_allocator& __y, false_type) + _NOEXCEPT {} __node_pointer __detach(); @@ -1066,6 +1097,9 @@ private: template <class _Tp, class _Compare, class _Allocator> __tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp) + _NOEXCEPT_( + is_nothrow_default_constructible<__node_allocator>::value && + is_nothrow_copy_constructible<value_compare>::value) : __pair3_(0, __comp) { __begin_node() = __end_node(); @@ -1240,6 +1274,9 @@ __tree<_Tp, _Compare, _Allocator>::__tree(const __tree& __t) template <class _Tp, class _Compare, class _Allocator> __tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t) + _NOEXCEPT_( + is_nothrow_move_constructible<__node_allocator>::value && + is_nothrow_move_constructible<value_compare>::value) : __begin_node_(_STD::move(__t.__begin_node_)), __pair1_(_STD::move(__t.__pair1_)), __pair3_(_STD::move(__t.__pair3_)) @@ -1284,6 +1321,8 @@ __tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t, const allocator_type& __ template <class _Tp, class _Compare, class _Allocator> void __tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, true_type) + _NOEXCEPT_(is_nothrow_move_assignable<value_compare>::value && + is_nothrow_move_assignable<__node_allocator>::value) { destroy(static_cast<__node_pointer>(__end_node()->__left_)); __begin_node_ = __t.__begin_node_; @@ -1350,6 +1389,11 @@ __tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, false_type) template <class _Tp, class _Compare, class _Allocator> __tree<_Tp, _Compare, _Allocator>& __tree<_Tp, _Compare, _Allocator>::operator=(__tree&& __t) + _NOEXCEPT_( + __node_traits::propagate_on_container_move_assignment::value && + is_nothrow_move_assignable<value_compare>::value && + is_nothrow_move_assignable<__node_allocator>::value) + { __move_assign(__t, integral_constant<bool, __node_traits::propagate_on_container_move_assignment::value>()); @@ -1366,7 +1410,7 @@ __tree<_Tp, _Compare, _Allocator>::~__tree() template <class _Tp, class _Compare, class _Allocator> void -__tree<_Tp, _Compare, _Allocator>::destroy(__node_pointer __nd) +__tree<_Tp, _Compare, _Allocator>::destroy(__node_pointer __nd) _NOEXCEPT { if (__nd != nullptr) { @@ -1381,6 +1425,10 @@ __tree<_Tp, _Compare, _Allocator>::destroy(__node_pointer __nd) template <class _Tp, class _Compare, class _Allocator> void __tree<_Tp, _Compare, _Allocator>::swap(__tree& __t) + _NOEXCEPT_( + __is_nothrow_swappable<value_compare>::value && + (!__node_traits::propagate_on_container_swap::value || + __is_nothrow_swappable<__node_allocator>::value)) { using _STD::swap; swap(__begin_node_, __t.__begin_node_); @@ -1399,7 +1447,7 @@ __tree<_Tp, _Compare, _Allocator>::swap(__tree& __t) template <class _Tp, class _Compare, class _Allocator> void -__tree<_Tp, _Compare, _Allocator>::clear() +__tree<_Tp, _Compare, _Allocator>::clear() _NOEXCEPT { destroy(__root()); size() = 0; @@ -2221,6 +2269,16 @@ __tree<_Tp, _Compare, _Allocator>::remove(const_iterator __p) return __node_holder(__np, _D(__node_alloc())); } +template <class _Tp, class _Compare, class _Allocator> +inline _LIBCPP_INLINE_VISIBILITY +void +swap(__tree<_Tp, _Compare, _Allocator>& __x, + __tree<_Tp, _Compare, _Allocator>& __y) + _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) +{ + __x.swap(__y); +} + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___TREE diff --git a/libcxx/include/map b/libcxx/include/map index 1c77c49c5ca..9f1c8a7e883 100644 --- a/libcxx/include/map +++ b/libcxx/include/map @@ -54,7 +54,11 @@ public: }; // construct/copy/destroy: - map(); + map() + noexcept( + is_nothrow_default_constructible<allocator_type>::value && + is_nothrow_default_constructible<key_compare>::value && + is_nothrow_copy_constructible<key_compare>::value); explicit map(const key_compare& comp); map(const key_compare& comp, const allocator_type& a); template <class InputIterator> @@ -64,7 +68,10 @@ public: map(InputIterator first, InputIterator last, const key_compare& comp, const allocator_type& a); map(const map& m); - map(map&& m); + map(map&& m) + noexcept( + is_nothrow_move_constructible<allocator_type>::value && + is_nothrow_move_constructible<key_compare>::value); explicit map(const allocator_type& a); map(const map& m, const allocator_type& a); map(map&& m, const allocator_type& a); @@ -73,7 +80,11 @@ public: ~map(); map& operator=(const map& m); - map& operator=(map&& m); + map& operator=(map&& m) + noexcept( + allocator_type::propagate_on_container_move_assignment::value && + is_nothrow_move_assignable<allocator_type>::value && + is_nothrow_move_assignable<keycompare>::value); map& operator=(initializer_list<value_type> il); // iterators: @@ -124,7 +135,11 @@ public: iterator erase(const_iterator first, const_iterator last); void clear(); - void swap(map& m); + void swap(map& m) + noexcept( + __is_nothrow_swappable<key_compare>::value && + (!allocator_type::propagate_on_container_swap::value || + __is_nothrow_swappable<allocator_type>::value)); // observers: allocator_type get_allocator() const; @@ -176,7 +191,8 @@ operator<=(const map<Key, T, Compare, Allocator>& x, // specialized algorithms: template <class Key, class T, class Compare, class Allocator> void -swap(map<Key, T, Compare, Allocator>& x, map<Key, T, Compare, Allocator>& y); +swap(map<Key, T, Compare, Allocator>& x, map<Key, T, Compare, Allocator>& y) + noexcept(noexcept(x.swap(y))); template <class Key, class T, class Compare = less<Key>, class Allocator = allocator<pair<const Key, T>>> @@ -213,7 +229,12 @@ public: }; // construct/copy/destroy: - explicit multimap(const key_compare& comp = key_compare()); + multimap() + noexcept( + is_nothrow_default_constructible<allocator_type>::value && + is_nothrow_default_constructible<key_compare>::value && + is_nothrow_copy_constructible<key_compare>::value); + explicit multimap(const key_compare& comp); multimap(const key_compare& comp, const allocator_type& a); template <class InputIterator> multimap(InputIterator first, InputIterator last, const key_compare& comp); @@ -221,7 +242,10 @@ public: multimap(InputIterator first, InputIterator last, const key_compare& comp, const allocator_type& a); multimap(const multimap& m); - multimap(multimap&& m); + multimap(multimap&& m) + noexcept( + is_nothrow_move_constructible<allocator_type>::value && + is_nothrow_move_constructible<key_compare>::value); explicit multimap(const allocator_type& a); multimap(const multimap& m, const allocator_type& a); multimap(multimap&& m, const allocator_type& a); @@ -231,7 +255,11 @@ public: ~multimap(); multimap& operator=(const multimap& m); - multimap& operator=(multimap&& m); + multimap& operator=(multimap&& m) + noexcept( + allocator_type::propagate_on_container_move_assignment::value && + is_nothrow_move_assignable<allocator_type>::value && + is_nothrow_move_assignable<keycompare>::value); multimap& operator=(initializer_list<value_type> il); // iterators: @@ -275,7 +303,11 @@ public: iterator erase(const_iterator first, const_iterator last); void clear(); - void swap(multimap& m); + void swap(multimap& m) + noexcept( + __is_nothrow_swappable<key_compare>::value && + (!allocator_type::propagate_on_container_swap::value || + __is_nothrow_swappable<allocator_type>::value)); // observers: allocator_type get_allocator() const; @@ -328,7 +360,8 @@ operator<=(const multimap<Key, T, Compare, Allocator>& x, template <class Key, class T, class Compare, class Allocator> void swap(multimap<Key, T, Compare, Allocator>& x, - multimap<Key, T, Compare, Allocator>& y); + multimap<Key, T, Compare, Allocator>& y) + noexcept(noexcept(x.swap(y))); } // std @@ -354,11 +387,15 @@ class __map_value_compare typedef pair<const _Key, _Tp> _CP; public: _LIBCPP_INLINE_VISIBILITY - __map_value_compare() : _Compare() {} + __map_value_compare() + _NOEXCEPT_(is_nothrow_default_constructible<_Compare>::value) + : _Compare() {} _LIBCPP_INLINE_VISIBILITY - __map_value_compare(_Compare c) : _Compare(c) {} + __map_value_compare(_Compare c) + _NOEXCEPT_(is_nothrow_copy_constructible<_Compare>::value) + : _Compare(c) {} _LIBCPP_INLINE_VISIBILITY - const _Compare& key_comp() const {return *this;} + const _Compare& key_comp() const _NOEXCEPT {return *this;} _LIBCPP_INLINE_VISIBILITY bool operator()(const _CP& __x, const _CP& __y) const {return static_cast<const _Compare&>(*this)(__x.first, __y.first);} @@ -398,11 +435,15 @@ class __map_value_compare<_Key, _Tp, _Compare, false> public: _LIBCPP_INLINE_VISIBILITY - __map_value_compare() : comp() {} + __map_value_compare() + _NOEXCEPT_(is_nothrow_default_constructible<_Compare>::value) + : comp() {} _LIBCPP_INLINE_VISIBILITY - __map_value_compare(_Compare c) : comp(c) {} + __map_value_compare(_Compare c) + _NOEXCEPT_(is_nothrow_copy_constructible<_Compare>::value) + : comp(c) {} _LIBCPP_INLINE_VISIBILITY - const _Compare& key_comp() const {return comp;} + const _Compare& key_comp() const _NOEXCEPT {return comp;} _LIBCPP_INLINE_VISIBILITY bool operator()(const _CP& __x, const _CP& __y) const @@ -454,7 +495,7 @@ public: bool __second_constructed; _LIBCPP_INLINE_VISIBILITY - explicit __map_node_destructor(allocator_type& __na) + explicit __map_node_destructor(allocator_type& __na) _NOEXCEPT : __na_(__na), __first_constructed(false), __second_constructed(false) @@ -462,7 +503,7 @@ public: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY - __map_node_destructor(__tree_node_destructor<allocator_type>&& __x) + __map_node_destructor(__tree_node_destructor<allocator_type>&& __x) _NOEXCEPT : __na_(__x.__na_), __first_constructed(__x.__value_constructed), __second_constructed(__x.__value_constructed) @@ -472,7 +513,7 @@ public: #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY - void operator()(pointer __p) + void operator()(pointer __p) _NOEXCEPT { if (__second_constructed) __alloc_traits::destroy(__na_, _STD::addressof(__p->__value_.second)); @@ -509,10 +550,10 @@ public: pointer; _LIBCPP_INLINE_VISIBILITY - __map_iterator() {} + __map_iterator() _NOEXCEPT {} _LIBCPP_INLINE_VISIBILITY - __map_iterator(_TreeIterator __i) : __i_(__i) {} + __map_iterator(_TreeIterator __i) _NOEXCEPT : __i_(__i) {} _LIBCPP_INLINE_VISIBILITY reference operator*() const {return *operator->();} @@ -574,13 +615,14 @@ public: pointer; _LIBCPP_INLINE_VISIBILITY - __map_const_iterator() {} + __map_const_iterator() _NOEXCEPT {} _LIBCPP_INLINE_VISIBILITY - __map_const_iterator(_TreeIterator __i) : __i_(__i) {} + __map_const_iterator(_TreeIterator __i) _NOEXCEPT : __i_(__i) {} _LIBCPP_INLINE_VISIBILITY __map_const_iterator( __map_iterator<typename _TreeIterator::__non_const_iterator> __i) + _NOEXCEPT : __i_(__i.__i_) {} _LIBCPP_INLINE_VISIBILITY @@ -676,6 +718,10 @@ public: _LIBCPP_INLINE_VISIBILITY explicit map(const key_compare& __comp = key_compare()) + _NOEXCEPT_( + is_nothrow_default_constructible<allocator_type>::value && + is_nothrow_default_constructible<key_compare>::value && + is_nothrow_copy_constructible<key_compare>::value) : __tree_(__vc(__comp)) {} _LIBCPP_INLINE_VISIBILITY @@ -711,6 +757,7 @@ public: _LIBCPP_INLINE_VISIBILITY map(map&& __m) + _NOEXCEPT_(is_nothrow_move_constructible<__base>::value) : __tree_(_STD::move(__m.__tree_)) { } @@ -733,6 +780,7 @@ public: _LIBCPP_INLINE_VISIBILITY map& operator=(map&& __m) + _NOEXCEPT_(is_nothrow_move_assignable<__base>::value) { __tree_ = _STD::move(__m.__tree_); return *this; @@ -761,38 +809,41 @@ public: } _LIBCPP_INLINE_VISIBILITY - iterator begin() {return __tree_.begin();} + iterator begin() _NOEXCEPT {return __tree_.begin();} _LIBCPP_INLINE_VISIBILITY - const_iterator begin() const {return __tree_.begin();} + const_iterator begin() const _NOEXCEPT {return __tree_.begin();} _LIBCPP_INLINE_VISIBILITY - iterator end() {return __tree_.end();} + iterator end() _NOEXCEPT {return __tree_.end();} _LIBCPP_INLINE_VISIBILITY - const_iterator end() const {return __tree_.end();} + const_iterator end() const _NOEXCEPT {return __tree_.end();} _LIBCPP_INLINE_VISIBILITY - reverse_iterator rbegin() {return reverse_iterator(end());} + reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());} _LIBCPP_INLINE_VISIBILITY - const_reverse_iterator rbegin() const {return const_reverse_iterator(end());} + const_reverse_iterator rbegin() const _NOEXCEPT + {return const_reverse_iterator(end());} _LIBCPP_INLINE_VISIBILITY - reverse_iterator rend() {return reverse_iterator(begin());} + reverse_iterator rend() _NOEXCEPT + {return reverse_iterator(begin());} _LIBCPP_INLINE_VISIBILITY - const_reverse_iterator rend() const {return const_reverse_iterator(begin());} + const_reverse_iterator rend() const _NOEXCEPT + {return const_reverse_iterator(begin());} _LIBCPP_INLINE_VISIBILITY - const_iterator cbegin() const {return begin();} + const_iterator cbegin() const _NOEXCEPT {return begin();} _LIBCPP_INLINE_VISIBILITY - const_iterator cend() const {return end();} + const_iterator cend() const _NOEXCEPT {return end();} _LIBCPP_INLINE_VISIBILITY - const_reverse_iterator crbegin() const {return rbegin();} + const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();} _LIBCPP_INLINE_VISIBILITY - const_reverse_iterator crend() const {return rend();} + const_reverse_iterator crend() const _NOEXCEPT {return rend();} _LIBCPP_INLINE_VISIBILITY - bool empty() const {return __tree_.size() == 0;} + bool empty() const _NOEXCEPT {return __tree_.size() == 0;} _LIBCPP_INLINE_VISIBILITY - size_type size() const {return __tree_.size();} + size_type size() const _NOEXCEPT {return __tree_.size();} _LIBCPP_INLINE_VISIBILITY - size_type max_size() const {return __tree_.max_size();} + size_type max_size() const _NOEXCEPT {return __tree_.max_size();} mapped_type& operator[](const key_type& __k); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -803,7 +854,7 @@ public: const mapped_type& at(const key_type& __k) const; _LIBCPP_INLINE_VISIBILITY - allocator_type get_allocator() const {return __tree_.__alloc();} + allocator_type get_allocator() const _NOEXCEPT {return __tree_.__alloc();} _LIBCPP_INLINE_VISIBILITY key_compare key_comp() const {return __tree_.value_comp().key_comp();} _LIBCPP_INLINE_VISIBILITY @@ -896,10 +947,12 @@ public: iterator erase(const_iterator __f, const_iterator __l) {return __tree_.erase(__f.__i_, __l.__i_);} _LIBCPP_INLINE_VISIBILITY - void clear() {__tree_.clear();} + void clear() _NOEXCEPT {__tree_.clear();} _LIBCPP_INLINE_VISIBILITY - void swap(map& __m) {__tree_.swap(__m.__tree_);} + void swap(map& __m) + _NOEXCEPT_(__is_nothrow_swappable<__base>::value) + {__tree_.swap(__m.__tree_);} _LIBCPP_INLINE_VISIBILITY iterator find(const key_type& __k) {return __tree_.find(__k);} @@ -1344,6 +1397,7 @@ inline _LIBCPP_INLINE_VISIBILITY void swap(map<_Key, _Tp, _Compare, _Allocator>& __x, map<_Key, _Tp, _Compare, _Allocator>& __y) + _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) { __x.swap(__y); } @@ -1405,6 +1459,10 @@ public: _LIBCPP_INLINE_VISIBILITY explicit multimap(const key_compare& __comp = key_compare()) + _NOEXCEPT_( + is_nothrow_default_constructible<allocator_type>::value && + is_nothrow_default_constructible<key_compare>::value && + is_nothrow_copy_constructible<key_compare>::value) : __tree_(__vc(__comp)) {} _LIBCPP_INLINE_VISIBILITY @@ -1441,6 +1499,7 @@ public: _LIBCPP_INLINE_VISIBILITY multimap(multimap&& __m) + _NOEXCEPT_(is_nothrow_move_constructible<__base>::value) : __tree_(_STD::move(__m.__tree_)) { } @@ -1463,6 +1522,7 @@ public: _LIBCPP_INLINE_VISIBILITY multimap& operator=(multimap&& __m) + _NOEXCEPT_(is_nothrow_move_assignable<__base>::value) { __tree_ = _STD::move(__m.__tree_); return *this; @@ -1490,45 +1550,48 @@ public: } _LIBCPP_INLINE_VISIBILITY - iterator begin() {return __tree_.begin();} + iterator begin() _NOEXCEPT {return __tree_.begin();} _LIBCPP_INLINE_VISIBILITY - const_iterator begin() const {return __tree_.begin();} + const_iterator begin() const _NOEXCEPT {return __tree_.begin();} _LIBCPP_INLINE_VISIBILITY - iterator end() {return __tree_.end();} + iterator end() _NOEXCEPT {return __tree_.end();} _LIBCPP_INLINE_VISIBILITY - const_iterator end() const {return __tree_.end();} + const_iterator end() const _NOEXCEPT {return __tree_.end();} _LIBCPP_INLINE_VISIBILITY - reverse_iterator rbegin() {return reverse_iterator(end());} + reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());} _LIBCPP_INLINE_VISIBILITY - const_reverse_iterator rbegin() const {return const_reverse_iterator(end());} + const_reverse_iterator rbegin() const _NOEXCEPT + {return const_reverse_iterator(end());} _LIBCPP_INLINE_VISIBILITY - reverse_iterator rend() {return reverse_iterator(begin());} + reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());} _LIBCPP_INLINE_VISIBILITY - const_reverse_iterator rend() const {return const_reverse_iterator(begin());} + const_reverse_iterator rend() const _NOEXCEPT + {return const_reverse_iterator(begin());} _LIBCPP_INLINE_VISIBILITY - const_iterator cbegin() const {return begin();} + const_iterator cbegin() const _NOEXCEPT {return begin();} _LIBCPP_INLINE_VISIBILITY - const_iterator cend() const {return end();} + const_iterator cend() const _NOEXCEPT {return end();} _LIBCPP_INLINE_VISIBILITY - const_reverse_iterator crbegin() const {return rbegin();} + const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();} _LIBCPP_INLINE_VISIBILITY - const_reverse_iterator crend() const {return rend();} + const_reverse_iterator crend() const _NOEXCEPT {return rend();} _LIBCPP_INLINE_VISIBILITY - bool empty() const {return __tree_.size() == 0;} + bool empty() const _NOEXCEPT {return __tree_.size() == 0;} _LIBCPP_INLINE_VISIBILITY - size_type size() const {return __tree_.size();} + size_type size() const _NOEXCEPT {return __tree_.size();} _LIBCPP_INLINE_VISIBILITY - size_type max_size() const {return __tree_.max_size();} + size_type max_size() const _NOEXCEPT {return __tree_.max_size();} _LIBCPP_INLINE_VISIBILITY - allocator_type get_allocator() const {return __tree_.__alloc();} + allocator_type get_allocator() const _NOEXCEPT {return __tree_.__alloc();} _LIBCPP_INLINE_VISIBILITY - key_compare key_comp() const {return __tree_.value_comp().key_comp();} + key_compare key_comp() const {return __tree_.value_comp().key_comp();} _LIBCPP_INLINE_VISIBILITY - value_compare value_comp() const {return value_compare(__tree_.value_comp().key_comp());} + value_compare value_comp() const + {return value_compare(__tree_.value_comp().key_comp());} #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -1615,7 +1678,9 @@ public: void clear() {__tree_.clear();} _LIBCPP_INLINE_VISIBILITY - void swap(multimap& __m) {__tree_.swap(__m.__tree_);} + void swap(multimap& __m) + _NOEXCEPT_(__is_nothrow_swappable<__base>::value) + {__tree_.swap(__m.__tree_);} _LIBCPP_INLINE_VISIBILITY iterator find(const key_type& __k) {return __tree_.find(__k);} @@ -1821,6 +1886,7 @@ inline _LIBCPP_INLINE_VISIBILITY void swap(multimap<_Key, _Tp, _Compare, _Allocator>& __x, multimap<_Key, _Tp, _Compare, _Allocator>& __y) + _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) { __x.swap(__y); } diff --git a/libcxx/test/containers/associative/map/map.cons/default_noexcept.pass.cpp b/libcxx/test/containers/associative/map/map.cons/default_noexcept.pass.cpp new file mode 100644 index 00000000000..4e497b92a23 --- /dev/null +++ b/libcxx/test/containers/associative/map/map.cons/default_noexcept.pass.cpp @@ -0,0 +1,53 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <map> + +// map() +// noexcept( +// is_nothrow_default_constructible<allocator_type>::value && +// is_nothrow_default_constructible<key_compare>::value && +// is_nothrow_copy_constructible<key_compare>::value); + +// This tests a conforming extension + +#include <map> +#include <cassert> + +#include "../../../MoveOnly.h" +#include "../../../test_allocator.h" + +template <class T> +struct some_comp +{ + typedef T value_type; + some_comp(); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::map<MoveOnly, MoveOnly> C; + static_assert(std::is_nothrow_default_constructible<C>::value, ""); + } + { + typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C; + static_assert(std::is_nothrow_default_constructible<C>::value, ""); + } + { + typedef std::map<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C; + static_assert(!std::is_nothrow_default_constructible<C>::value, ""); + } + { + typedef std::map<MoveOnly, MoveOnly, some_comp<MoveOnly>> C; + static_assert(!std::is_nothrow_default_constructible<C>::value, ""); + } +#endif +} diff --git a/libcxx/test/containers/associative/map/map.cons/dtor_noexcept.pass.cpp b/libcxx/test/containers/associative/map/map.cons/dtor_noexcept.pass.cpp new file mode 100644 index 00000000000..c3b99707c87 --- /dev/null +++ b/libcxx/test/containers/associative/map/map.cons/dtor_noexcept.pass.cpp @@ -0,0 +1,51 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <map> + +// ~map() // implied noexcept; + +#include <map> +#include <cassert> + +#include "../../../MoveOnly.h" +#include "../../../test_allocator.h" + +#if __has_feature(cxx_noexcept) + +template <class T> +struct some_comp +{ + typedef T value_type; + ~some_comp() noexcept(false); +}; + +#endif + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::map<MoveOnly, MoveOnly> C; + static_assert(std::is_nothrow_destructible<C>::value, ""); + } + { + typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C; + static_assert(std::is_nothrow_destructible<C>::value, ""); + } + { + typedef std::map<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C; + static_assert(std::is_nothrow_destructible<C>::value, ""); + } + { + typedef std::map<MoveOnly, MoveOnly, some_comp<MoveOnly>> C; + static_assert(!std::is_nothrow_destructible<C>::value, ""); + } +#endif +} diff --git a/libcxx/test/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp b/libcxx/test/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp new file mode 100644 index 00000000000..4a35a9227de --- /dev/null +++ b/libcxx/test/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp @@ -0,0 +1,53 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <map> + +// map& operator=(map&& c) +// noexcept( +// allocator_type::propagate_on_container_move_assignment::value && +// is_nothrow_move_assignable<allocator_type>::value && +// is_nothrow_move_assignable<key_compare>::value); + +// This tests a conforming extension + +#include <map> +#include <cassert> + +#include "../../../MoveOnly.h" +#include "../../../test_allocator.h" + +template <class T> +struct some_comp +{ + typedef T value_type; + some_comp& operator=(const some_comp&); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::map<MoveOnly, MoveOnly> C; + static_assert(std::is_nothrow_move_assignable<C>::value, ""); + } + { + typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C; + static_assert(!std::is_nothrow_move_assignable<C>::value, ""); + } + { + typedef std::map<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C; + static_assert(std::is_nothrow_move_assignable<C>::value, ""); + } + { + typedef std::map<MoveOnly, MoveOnly, some_comp<MoveOnly>> C; + static_assert(!std::is_nothrow_move_assignable<C>::value, ""); + } +#endif +} diff --git a/libcxx/test/containers/associative/map/map.cons/move_noexcept.pass.cpp b/libcxx/test/containers/associative/map/map.cons/move_noexcept.pass.cpp new file mode 100644 index 00000000000..18b595fd739 --- /dev/null +++ b/libcxx/test/containers/associative/map/map.cons/move_noexcept.pass.cpp @@ -0,0 +1,51 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <map> + +// map(map&&) +// noexcept(is_nothrow_move_constructible<allocator_type>::value && +// is_nothrow_move_constructible<key_compare>::value); + +// This tests a conforming extension + +#include <map> +#include <cassert> + +#include "../../../MoveOnly.h" +#include "../../../test_allocator.h" + +template <class T> +struct some_comp +{ + typedef T value_type; + some_comp(const some_comp&); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::map<MoveOnly, MoveOnly> C; + static_assert(std::is_nothrow_move_constructible<C>::value, ""); + } + { + typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C; + static_assert(std::is_nothrow_move_constructible<C>::value, ""); + } + { + typedef std::map<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C; + static_assert(std::is_nothrow_move_constructible<C>::value, ""); + } + { + typedef std::map<MoveOnly, MoveOnly, some_comp<MoveOnly>> C; + static_assert(!std::is_nothrow_move_constructible<C>::value, ""); + } +#endif +} diff --git a/libcxx/test/containers/associative/map/map.special/swap_noexcept.pass.cpp b/libcxx/test/containers/associative/map/map.special/swap_noexcept.pass.cpp new file mode 100644 index 00000000000..5f75032ea59 --- /dev/null +++ b/libcxx/test/containers/associative/map/map.special/swap_noexcept.pass.cpp @@ -0,0 +1,60 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <map> + +// void swap(map& c) +// noexcept(!allocator_type::propagate_on_container_swap::value || +// __is_nothrow_swappable<allocator_type>::value); + +// This tests a conforming extension + +#include <map> +#include <cassert> + +#include "../../../MoveOnly.h" +#include "../../../test_allocator.h" + +template <class T> +struct some_comp +{ + typedef T value_type; + + some_comp() {} + some_comp(const some_comp&) {} + void deallocate(void*, unsigned) {} + + typedef std::true_type propagate_on_container_swap; +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::map<MoveOnly, MoveOnly> C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::map<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::map<MoveOnly, MoveOnly, some_comp<MoveOnly>> C; + C c1, c2; + static_assert(!noexcept(swap(c1, c2)), ""); + } +#endif +} diff --git a/libcxx/test/containers/associative/multimap/multimap.cons/default_noexcept.pass.cpp b/libcxx/test/containers/associative/multimap/multimap.cons/default_noexcept.pass.cpp new file mode 100644 index 00000000000..56f119a2201 --- /dev/null +++ b/libcxx/test/containers/associative/multimap/multimap.cons/default_noexcept.pass.cpp @@ -0,0 +1,53 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <map> + +// multimap() +// noexcept( +// is_nothrow_default_constructible<allocator_type>::value && +// is_nothrow_default_constructible<key_compare>::value && +// is_nothrow_copy_constructible<key_compare>::value); + +// This tests a conforming extension + +#include <map> +#include <cassert> + +#include "../../../MoveOnly.h" +#include "../../../test_allocator.h" + +template <class T> +struct some_comp +{ + typedef T value_type; + some_comp(); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::multimap<MoveOnly, MoveOnly> C; + static_assert(std::is_nothrow_default_constructible<C>::value, ""); + } + { + typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C; + static_assert(std::is_nothrow_default_constructible<C>::value, ""); + } + { + typedef std::multimap<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C; + static_assert(!std::is_nothrow_default_constructible<C>::value, ""); + } + { + typedef std::multimap<MoveOnly, MoveOnly, some_comp<MoveOnly>> C; + static_assert(!std::is_nothrow_default_constructible<C>::value, ""); + } +#endif +} diff --git a/libcxx/test/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp b/libcxx/test/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp new file mode 100644 index 00000000000..f1d8afdc33d --- /dev/null +++ b/libcxx/test/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp @@ -0,0 +1,51 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <map> + +// ~multimap() // implied noexcept; + +#include <map> +#include <cassert> + +#include "../../../MoveOnly.h" +#include "../../../test_allocator.h" + +#if __has_feature(cxx_noexcept) + +template <class T> +struct some_comp +{ + typedef T value_type; + ~some_comp() noexcept(false); +}; + +#endif + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::multimap<MoveOnly, MoveOnly> C; + static_assert(std::is_nothrow_destructible<C>::value, ""); + } + { + typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C; + static_assert(std::is_nothrow_destructible<C>::value, ""); + } + { + typedef std::multimap<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C; + static_assert(std::is_nothrow_destructible<C>::value, ""); + } + { + typedef std::multimap<MoveOnly, MoveOnly, some_comp<MoveOnly>> C; + static_assert(!std::is_nothrow_destructible<C>::value, ""); + } +#endif +} diff --git a/libcxx/test/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp b/libcxx/test/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp new file mode 100644 index 00000000000..cada1b1d7b0 --- /dev/null +++ b/libcxx/test/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp @@ -0,0 +1,53 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <map> + +// multimap& operator=(multimap&& c) +// noexcept( +// allocator_type::propagate_on_container_move_assignment::value && +// is_nothrow_move_assignable<allocator_type>::value && +// is_nothrow_move_assignable<key_compare>::value); + +// This tests a conforming extension + +#include <map> +#include <cassert> + +#include "../../../MoveOnly.h" +#include "../../../test_allocator.h" + +template <class T> +struct some_comp +{ + typedef T value_type; + some_comp& operator=(const some_comp&); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::multimap<MoveOnly, MoveOnly> C; + static_assert(std::is_nothrow_move_assignable<C>::value, ""); + } + { + typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C; + static_assert(!std::is_nothrow_move_assignable<C>::value, ""); + } + { + typedef std::multimap<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C; + static_assert(std::is_nothrow_move_assignable<C>::value, ""); + } + { + typedef std::multimap<MoveOnly, MoveOnly, some_comp<MoveOnly>> C; + static_assert(!std::is_nothrow_move_assignable<C>::value, ""); + } +#endif +} diff --git a/libcxx/test/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp b/libcxx/test/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp new file mode 100644 index 00000000000..2f0b9ccc8cf --- /dev/null +++ b/libcxx/test/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp @@ -0,0 +1,51 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <map> + +// multimap(multimap&&) +// noexcept(is_nothrow_move_constructible<allocator_type>::value && +// is_nothrow_move_constructible<key_compare>::value); + +// This tests a conforming extension + +#include <map> +#include <cassert> + +#include "../../../MoveOnly.h" +#include "../../../test_allocator.h" + +template <class T> +struct some_comp +{ + typedef T value_type; + some_comp(const some_comp&); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::multimap<MoveOnly, MoveOnly> C; + static_assert(std::is_nothrow_move_constructible<C>::value, ""); + } + { + typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C; + static_assert(std::is_nothrow_move_constructible<C>::value, ""); + } + { + typedef std::multimap<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C; + static_assert(std::is_nothrow_move_constructible<C>::value, ""); + } + { + typedef std::multimap<MoveOnly, MoveOnly, some_comp<MoveOnly>> C; + static_assert(!std::is_nothrow_move_constructible<C>::value, ""); + } +#endif +} diff --git a/libcxx/test/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp b/libcxx/test/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp new file mode 100644 index 00000000000..2aa901a8ac2 --- /dev/null +++ b/libcxx/test/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp @@ -0,0 +1,60 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <map> + +// void swap(multimap& c) +// noexcept(!allocator_type::propagate_on_container_swap::value || +// __is_nothrow_swappable<allocator_type>::value); + +// This tests a conforming extension + +#include <map> +#include <cassert> + +#include "../../../MoveOnly.h" +#include "../../../test_allocator.h" + +template <class T> +struct some_comp +{ + typedef T value_type; + + some_comp() {} + some_comp(const some_comp&) {} + void deallocate(void*, unsigned) {} + + typedef std::true_type propagate_on_container_swap; +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::multimap<MoveOnly, MoveOnly> C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::multimap<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::multimap<MoveOnly, MoveOnly, some_comp<MoveOnly>> C; + C c1, c2; + static_assert(!noexcept(swap(c1, c2)), ""); + } +#endif +} |