From b2e2a8f6f3a1c47ea942bac99dd75c53be967954 Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Sat, 4 Jun 2011 15:22:34 +0000 Subject: [PATCH] noexcept for . Plus a few fixes to noexcept for . git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@132640 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/map | 72 +++--- include/set | 219 +++++++++++------- .../map/map.cons/default_noexcept.pass.cpp | 2 +- .../map/map.cons/dtor_noexcept.pass.cpp | 2 +- .../map.cons/move_assign_noexcept.pass.cpp | 2 +- .../map/map.cons/move_noexcept.pass.cpp | 2 +- .../map/map.special/swap_noexcept.pass.cpp | 2 +- .../multimap.cons/default_noexcept.pass.cpp | 2 +- .../multimap.cons/dtor_noexcept.pass.cpp | 2 +- .../move_assign_noexcept.pass.cpp | 2 +- .../multimap.cons/move_noexcept.pass.cpp | 2 +- .../multimap.special/swap_noexcept.pass.cpp | 2 +- .../multiset.cons/default_noexcept.pass.cpp | 53 +++++ .../multiset.cons/dtor_noexcept.pass.cpp | 51 ++++ .../move_assign_noexcept.pass.cpp | 53 +++++ .../multiset.cons/move_noexcept.pass.cpp | 51 ++++ .../multiset.special/swap_noexcept.pass.cpp | 60 +++++ .../set/set.cons/default_noexcept.pass.cpp | 53 +++++ .../set/set.cons/dtor_noexcept.pass.cpp | 51 ++++ .../set.cons/move_assign_noexcept.pass.cpp | 53 +++++ .../set/set.cons/move_noexcept.pass.cpp | 51 ++++ .../set/set.special/non_member_swap.pass.cpp | 4 +- .../set/set.special/swap_noexcept.pass.cpp | 60 +++++ 23 files changed, 723 insertions(+), 128 deletions(-) create mode 100644 test/containers/associative/multiset/multiset.cons/default_noexcept.pass.cpp create mode 100644 test/containers/associative/multiset/multiset.cons/dtor_noexcept.pass.cpp create mode 100644 test/containers/associative/multiset/multiset.cons/move_assign_noexcept.pass.cpp create mode 100644 test/containers/associative/multiset/multiset.cons/move_noexcept.pass.cpp create mode 100644 test/containers/associative/multiset/multiset.special/swap_noexcept.pass.cpp create mode 100644 test/containers/associative/set/set.cons/default_noexcept.pass.cpp create mode 100644 test/containers/associative/set/set.cons/dtor_noexcept.pass.cpp create mode 100644 test/containers/associative/set/set.cons/move_assign_noexcept.pass.cpp create mode 100644 test/containers/associative/set/set.cons/move_noexcept.pass.cpp create mode 100644 test/containers/associative/set/set.special/swap_noexcept.pass.cpp diff --git a/include/map b/include/map index 9f1c8a7e..c0bc7841 100644 --- a/include/map +++ b/include/map @@ -84,29 +84,29 @@ public: noexcept( allocator_type::propagate_on_container_move_assignment::value && is_nothrow_move_assignable::value && - is_nothrow_move_assignable::value); + is_nothrow_move_assignable::value); map& operator=(initializer_list il); // iterators: - iterator begin(); - const_iterator begin() const; - iterator end(); - const_iterator end() const; + iterator begin() noexcept; + const_iterator begin() const noexcept; + iterator end() noexcept; + const_iterator end() const noexcept; - reverse_iterator rbegin(); - const_reverse_iterator rbegin() const; - reverse_iterator rend(); - const_reverse_iterator rend() const; + reverse_iterator rbegin() noexcept; + const_reverse_iterator rbegin() const noexcept; + reverse_iterator rend() noexcept; + const_reverse_iterator rend() const noexcept; - const_iterator cbegin() const; - const_iterator cend() const; - const_reverse_iterator crbegin() const; - const_reverse_iterator crend() const; + const_iterator cbegin() const noexcept; + const_iterator cend() const noexcept; + const_reverse_iterator crbegin() const noexcept; + const_reverse_iterator crend() const noexcept; // capacity: - bool empty() const; - size_type size() const; - size_type max_size() const; + bool empty() const noexcept; + size_type size() const noexcept; + size_type max_size() const noexcept; // element access: mapped_type& operator[](const key_type& k); @@ -133,7 +133,7 @@ public: iterator erase(const_iterator position); size_type erase(const key_type& k); iterator erase(const_iterator first, const_iterator last); - void clear(); + void clear() noexcept; void swap(map& m) noexcept( @@ -142,7 +142,7 @@ public: __is_nothrow_swappable::value)); // observers: - allocator_type get_allocator() const; + allocator_type get_allocator() const noexcept; key_compare key_comp() const; value_compare value_comp() const; @@ -259,29 +259,29 @@ public: noexcept( allocator_type::propagate_on_container_move_assignment::value && is_nothrow_move_assignable::value && - is_nothrow_move_assignable::value); + is_nothrow_move_assignable::value); multimap& operator=(initializer_list il); // iterators: - iterator begin(); - const_iterator begin() const; - iterator end(); - const_iterator end() const; + iterator begin() noexcept; + const_iterator begin() const noexcept; + iterator end() noexcept; + const_iterator end() const noexcept; - reverse_iterator rbegin(); - const_reverse_iterator rbegin() const; - reverse_iterator rend(); - const_reverse_iterator rend() const; + reverse_iterator rbegin() noexcept; + const_reverse_iterator rbegin() const noexcept; + reverse_iterator rend() noexcept; + const_reverse_iterator rend() const noexcept; - const_iterator cbegin() const; - const_iterator cend() const; - const_reverse_iterator crbegin() const; - const_reverse_iterator crend() const; + const_iterator cbegin() const noexcept; + const_iterator cend() const noexcept; + const_reverse_iterator crbegin() const noexcept; + const_reverse_iterator crend() const noexcept; // capacity: - bool empty() const; - size_type size() const; - size_type max_size() const; + bool empty() const noexcept; + size_type size() const noexcept; + size_type max_size() const noexcept; // modifiers: template @@ -301,7 +301,7 @@ public: iterator erase(const_iterator position); size_type erase(const key_type& k); iterator erase(const_iterator first, const_iterator last); - void clear(); + void clear() noexcept; void swap(multimap& m) noexcept( @@ -310,7 +310,7 @@ public: __is_nothrow_swappable::value)); // observers: - allocator_type get_allocator() const; + allocator_type get_allocator() const noexcept; key_compare key_comp() const; value_compare value_comp() const; diff --git a/include/set b/include/set index 7e2cdc0d..0f8a19ad 100644 --- a/include/set +++ b/include/set @@ -42,7 +42,12 @@ public: typedef std::reverse_iterator const_reverse_iterator; // construct/copy/destroy: - explicit set(const value_compare& comp = value_compare()); + set() + noexcept( + is_nothrow_default_constructible::value && + is_nothrow_default_constructible::value && + is_nothrow_copy_constructible::value); + explicit set(const value_compare& comp); set(const value_compare& comp, const allocator_type& a); template set(InputIterator first, InputIterator last, @@ -51,7 +56,10 @@ public: set(InputIterator first, InputIterator last, const value_compare& comp, const allocator_type& a); set(const set& s); - set(set&& s); + set(set&& s) + noexcept( + is_nothrow_move_constructible::value && + is_nothrow_move_constructible::value); explicit set(const allocator_type& a); set(const set& s, const allocator_type& a); set(set&& s, const allocator_type& a); @@ -61,29 +69,33 @@ public: ~set(); set& operator=(const set& s); - set& operator=(set&& s); + set& operator=(set&& s) + noexcept( + allocator_type::propagate_on_container_move_assignment::value && + is_nothrow_move_assignable::value && + is_nothrow_move_assignable::value); set& operator=(initializer_list il); // iterators: - iterator begin(); - const_iterator begin() const; - iterator end(); - const_iterator end() const; + iterator begin() noexcept; + const_iterator begin() const noexcept; + iterator end() noexcept; + const_iterator end() const noexcept; - reverse_iterator rbegin(); - const_reverse_iterator rbegin() const; - reverse_iterator rend(); - const_reverse_iterator rend() const; + reverse_iterator rbegin() noexcept; + const_reverse_iterator rbegin() const noexcept; + reverse_iterator rend() noexcept; + const_reverse_iterator rend() const noexcept; - const_iterator cbegin() const; - const_iterator cend() const; - const_reverse_iterator crbegin() const; - const_reverse_iterator crend() const; + const_iterator cbegin() const noexcept; + const_iterator cend() const noexcept; + const_reverse_iterator crbegin() const noexcept; + const_reverse_iterator crend() const noexcept; // capacity: - bool empty() const; - size_type size() const; - size_type max_size() const; + bool empty() const noexcept; + size_type size() const noexcept; + size_type max_size() const noexcept; // modifiers: template @@ -101,12 +113,16 @@ public: iterator erase(const_iterator position); size_type erase(const key_type& k); iterator erase(const_iterator first, const_iterator last); - void clear(); + void clear() noexcept; - void swap(set& s); + void swap(set& s) + noexcept( + __is_nothrow_swappable::value && + (!allocator_type::propagate_on_container_swap::value || + __is_nothrow_swappable::value)); // observers: - allocator_type get_allocator() const; + allocator_type get_allocator() const noexcept; key_compare key_comp() const; value_compare value_comp() const; @@ -155,7 +171,8 @@ operator<=(const set& x, // specialized algorithms: template void -swap(set& x, set& y); +swap(set& x, set& y) + noexcept(noexcept(x.swap(y))); template , class Allocator = allocator> @@ -181,7 +198,12 @@ public: typedef std::reverse_iterator const_reverse_iterator; // construct/copy/destroy: - explicit multiset(const value_compare& comp = value_compare()); + multiset() + noexcept( + is_nothrow_default_constructible::value && + is_nothrow_default_constructible::value && + is_nothrow_copy_constructible::value); + explicit multiset(const value_compare& comp); multiset(const value_compare& comp, const allocator_type& a); template multiset(InputIterator first, InputIterator last, @@ -190,7 +212,10 @@ public: multiset(InputIterator first, InputIterator last, const value_compare& comp, const allocator_type& a); multiset(const multiset& s); - multiset(multiset&& s); + multiset(multiset&& s) + noexcept( + is_nothrow_move_constructible::value && + is_nothrow_move_constructible::value); explicit multiset(const allocator_type& a); multiset(const multiset& s, const allocator_type& a); multiset(multiset&& s, const allocator_type& a); @@ -200,29 +225,33 @@ public: ~multiset(); multiset& operator=(const multiset& s); - multiset& operator=(multiset&& s); + multiset& operator=(multiset&& s) + noexcept( + allocator_type::propagate_on_container_move_assignment::value && + is_nothrow_move_assignable::value && + is_nothrow_move_assignable::value); multiset& operator=(initializer_list il); // iterators: - iterator begin(); - const_iterator begin() const; - iterator end(); - const_iterator end() const; + iterator begin() noexcept; + const_iterator begin() const noexcept; + iterator end() noexcept; + const_iterator end() const noexcept; - reverse_iterator rbegin(); - const_reverse_iterator rbegin() const; - reverse_iterator rend(); - const_reverse_iterator rend() const; + reverse_iterator rbegin() noexcept; + const_reverse_iterator rbegin() const noexcept; + reverse_iterator rend() noexcept; + const_reverse_iterator rend() const noexcept; - const_iterator cbegin() const; - const_iterator cend() const; - const_reverse_iterator crbegin() const; - const_reverse_iterator crend() const; + const_iterator cbegin() const noexcept; + const_iterator cend() const noexcept; + const_reverse_iterator crbegin() const noexcept; + const_reverse_iterator crend() const noexcept; // capacity: - bool empty() const; - size_type size() const; - size_type max_size() const; + bool empty() const noexcept; + size_type size() const noexcept; + size_type max_size() const noexcept; // modifiers: template @@ -240,12 +269,16 @@ public: iterator erase(const_iterator position); size_type erase(const key_type& k); iterator erase(const_iterator first, const_iterator last); - void clear(); + void clear() noexcept; - void swap(multiset& s); + void swap(multiset& s) + noexcept( + __is_nothrow_swappable::value && + (!allocator_type::propagate_on_container_swap::value || + __is_nothrow_swappable::value)); // observers: - allocator_type get_allocator() const; + allocator_type get_allocator() const noexcept; key_compare key_comp() const; value_compare value_comp() const; @@ -294,7 +327,8 @@ operator<=(const multiset& x, // specialized algorithms: template void -swap(multiset& x, multiset& y); +swap(multiset& x, multiset& y) + noexcept(noexcept(x.swap(y))); } // std @@ -341,6 +375,10 @@ public: _LIBCPP_INLINE_VISIBILITY explicit set(const value_compare& __comp = value_compare()) + _NOEXCEPT_( + is_nothrow_default_constructible::value && + is_nothrow_default_constructible::value && + is_nothrow_copy_constructible::value) : __tree_(__comp) {} _LIBCPP_INLINE_VISIBILITY set(const value_compare& __comp, const allocator_type& __a) @@ -373,6 +411,7 @@ public: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY set(set&& __s) + _NOEXCEPT_(is_nothrow_move_constructible<__base>::value) : __tree_(_STD::move(__s.__tree_)) {} #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -416,6 +455,7 @@ public: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY set& operator=(set&& __s) + _NOEXCEPT_(is_nothrow_move_assignable<__base>::value) { __tree_ = _STD::move(__s.__tree_); return *this; @@ -423,38 +463,42 @@ public: #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES _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();} // modifiers: #if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) @@ -504,13 +548,14 @@ public: iterator erase(const_iterator __f, const_iterator __l) {return __tree_.erase(__f, __l);} _LIBCPP_INLINE_VISIBILITY - void clear() {__tree_.clear();} + void clear() _NOEXCEPT {__tree_.clear();} _LIBCPP_INLINE_VISIBILITY - void swap(set& __s) {__tree_.swap(__s.__tree_);} + void swap(set& __s) _NOEXCEPT_(__is_nothrow_swappable<__base>::value) + {__tree_.swap(__s.__tree_);} _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();} _LIBCPP_INLINE_VISIBILITY @@ -620,6 +665,7 @@ inline _LIBCPP_INLINE_VISIBILITY void swap(set<_Key, _Compare, _Allocator>& __x, set<_Key, _Compare, _Allocator>& __y) + _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) { __x.swap(__y); } @@ -658,6 +704,10 @@ public: // construct/copy/destroy: _LIBCPP_INLINE_VISIBILITY explicit multiset(const value_compare& __comp = value_compare()) + _NOEXCEPT_( + is_nothrow_default_constructible::value && + is_nothrow_default_constructible::value && + is_nothrow_copy_constructible::value) : __tree_(__comp) {} _LIBCPP_INLINE_VISIBILITY multiset(const value_compare& __comp, const allocator_type& __a) @@ -691,6 +741,7 @@ public: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY multiset(multiset&& __s) + _NOEXCEPT_(is_nothrow_move_constructible<__base>::value) : __tree_(_STD::move(__s.__tree_)) {} #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY @@ -731,6 +782,7 @@ public: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY multiset& operator=(multiset&& __s) + _NOEXCEPT_(is_nothrow_move_assignable<__base>::value) { __tree_ = _STD::move(__s.__tree_); return *this; @@ -738,38 +790,42 @@ public: #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES _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();} // modifiers: #if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) @@ -818,13 +874,15 @@ public: iterator erase(const_iterator __f, const_iterator __l) {return __tree_.erase(__f, __l);} _LIBCPP_INLINE_VISIBILITY - void clear() {__tree_.clear();} + void clear() _NOEXCEPT {__tree_.clear();} _LIBCPP_INLINE_VISIBILITY - void swap(multiset& __s) {__tree_.swap(__s.__tree_);} + void swap(multiset& __s) + _NOEXCEPT_(__is_nothrow_swappable<__base>::value) + {__tree_.swap(__s.__tree_);} _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();} _LIBCPP_INLINE_VISIBILITY @@ -933,6 +991,7 @@ inline _LIBCPP_INLINE_VISIBILITY void swap(multiset<_Key, _Compare, _Allocator>& __x, multiset<_Key, _Compare, _Allocator>& __y) + _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) { __x.swap(__y); } diff --git a/test/containers/associative/map/map.cons/default_noexcept.pass.cpp b/test/containers/associative/map/map.cons/default_noexcept.pass.cpp index 4e497b92..d673c6d6 100644 --- a/test/containers/associative/map/map.cons/default_noexcept.pass.cpp +++ b/test/containers/associative/map/map.cons/default_noexcept.pass.cpp @@ -42,7 +42,7 @@ int main() static_assert(std::is_nothrow_default_constructible::value, ""); } { - typedef std::map, other_allocator> C; + typedef std::map, other_allocator> C; static_assert(!std::is_nothrow_default_constructible::value, ""); } { diff --git a/test/containers/associative/map/map.cons/dtor_noexcept.pass.cpp b/test/containers/associative/map/map.cons/dtor_noexcept.pass.cpp index c3b99707..a563371a 100644 --- a/test/containers/associative/map/map.cons/dtor_noexcept.pass.cpp +++ b/test/containers/associative/map/map.cons/dtor_noexcept.pass.cpp @@ -40,7 +40,7 @@ int main() static_assert(std::is_nothrow_destructible::value, ""); } { - typedef std::map, other_allocator> C; + typedef std::map, other_allocator> C; static_assert(std::is_nothrow_destructible::value, ""); } { diff --git a/test/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp b/test/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp index 4a35a922..3bc1e685 100644 --- a/test/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp +++ b/test/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp @@ -42,7 +42,7 @@ int main() static_assert(!std::is_nothrow_move_assignable::value, ""); } { - typedef std::map, other_allocator> C; + typedef std::map, other_allocator> C; static_assert(std::is_nothrow_move_assignable::value, ""); } { diff --git a/test/containers/associative/map/map.cons/move_noexcept.pass.cpp b/test/containers/associative/map/map.cons/move_noexcept.pass.cpp index 18b595fd..e9ec1202 100644 --- a/test/containers/associative/map/map.cons/move_noexcept.pass.cpp +++ b/test/containers/associative/map/map.cons/move_noexcept.pass.cpp @@ -40,7 +40,7 @@ int main() static_assert(std::is_nothrow_move_constructible::value, ""); } { - typedef std::map, other_allocator> C; + typedef std::map, other_allocator> C; static_assert(std::is_nothrow_move_constructible::value, ""); } { diff --git a/test/containers/associative/map/map.special/swap_noexcept.pass.cpp b/test/containers/associative/map/map.special/swap_noexcept.pass.cpp index 5f75032e..ef2ef040 100644 --- a/test/containers/associative/map/map.special/swap_noexcept.pass.cpp +++ b/test/containers/associative/map/map.special/swap_noexcept.pass.cpp @@ -47,7 +47,7 @@ int main() static_assert(noexcept(swap(c1, c2)), ""); } { - typedef std::map, other_allocator> C; + typedef std::map, other_allocator> C; C c1, c2; static_assert(noexcept(swap(c1, c2)), ""); } diff --git a/test/containers/associative/multimap/multimap.cons/default_noexcept.pass.cpp b/test/containers/associative/multimap/multimap.cons/default_noexcept.pass.cpp index 56f119a2..a144ba94 100644 --- a/test/containers/associative/multimap/multimap.cons/default_noexcept.pass.cpp +++ b/test/containers/associative/multimap/multimap.cons/default_noexcept.pass.cpp @@ -42,7 +42,7 @@ int main() static_assert(std::is_nothrow_default_constructible::value, ""); } { - typedef std::multimap, other_allocator> C; + typedef std::multimap, other_allocator> C; static_assert(!std::is_nothrow_default_constructible::value, ""); } { diff --git a/test/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp b/test/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp index f1d8afdc..14e3f640 100644 --- a/test/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp +++ b/test/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp @@ -40,7 +40,7 @@ int main() static_assert(std::is_nothrow_destructible::value, ""); } { - typedef std::multimap, other_allocator> C; + typedef std::multimap, other_allocator> C; static_assert(std::is_nothrow_destructible::value, ""); } { diff --git a/test/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp b/test/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp index cada1b1d..ddb4e484 100644 --- a/test/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp +++ b/test/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp @@ -42,7 +42,7 @@ int main() static_assert(!std::is_nothrow_move_assignable::value, ""); } { - typedef std::multimap, other_allocator> C; + typedef std::multimap, other_allocator> C; static_assert(std::is_nothrow_move_assignable::value, ""); } { diff --git a/test/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp b/test/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp index 2f0b9ccc..6ea06994 100644 --- a/test/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp +++ b/test/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp @@ -40,7 +40,7 @@ int main() static_assert(std::is_nothrow_move_constructible::value, ""); } { - typedef std::multimap, other_allocator> C; + typedef std::multimap, other_allocator> C; static_assert(std::is_nothrow_move_constructible::value, ""); } { diff --git a/test/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp b/test/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp index 2aa901a8..b07d56a2 100644 --- a/test/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp +++ b/test/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp @@ -47,7 +47,7 @@ int main() static_assert(noexcept(swap(c1, c2)), ""); } { - typedef std::multimap, other_allocator> C; + typedef std::multimap, other_allocator> C; C c1, c2; static_assert(noexcept(swap(c1, c2)), ""); } diff --git a/test/containers/associative/multiset/multiset.cons/default_noexcept.pass.cpp b/test/containers/associative/multiset/multiset.cons/default_noexcept.pass.cpp new file mode 100644 index 00000000..2e3e56ef --- /dev/null +++ b/test/containers/associative/multiset/multiset.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. +// +//===----------------------------------------------------------------------===// + +// + +// multiset() +// noexcept( +// is_nothrow_default_constructible::value && +// is_nothrow_default_constructible::value && +// is_nothrow_copy_constructible::value); + +// This tests a conforming extension + +#include +#include + +#include "../../../MoveOnly.h" +#include "../../../test_allocator.h" + +template +struct some_comp +{ + typedef T value_type; + some_comp(); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::multiset C; + static_assert(std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::multiset, test_allocator> C; + static_assert(std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::multiset, other_allocator> C; + static_assert(!std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::multiset> C; + static_assert(!std::is_nothrow_default_constructible::value, ""); + } +#endif +} diff --git a/test/containers/associative/multiset/multiset.cons/dtor_noexcept.pass.cpp b/test/containers/associative/multiset/multiset.cons/dtor_noexcept.pass.cpp new file mode 100644 index 00000000..f04ae945 --- /dev/null +++ b/test/containers/associative/multiset/multiset.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. +// +//===----------------------------------------------------------------------===// + +// + +// ~multiset() // implied noexcept; + +#include +#include + +#include "../../../MoveOnly.h" +#include "../../../test_allocator.h" + +#if __has_feature(cxx_noexcept) + +template +struct some_comp +{ + typedef T value_type; + ~some_comp() noexcept(false); +}; + +#endif + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::multiset C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::multiset, test_allocator> C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::multiset, other_allocator> C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::multiset> C; + static_assert(!std::is_nothrow_destructible::value, ""); + } +#endif +} diff --git a/test/containers/associative/multiset/multiset.cons/move_assign_noexcept.pass.cpp b/test/containers/associative/multiset/multiset.cons/move_assign_noexcept.pass.cpp new file mode 100644 index 00000000..e5ce3498 --- /dev/null +++ b/test/containers/associative/multiset/multiset.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. +// +//===----------------------------------------------------------------------===// + +// + +// multiset& operator=(multiset&& c) +// noexcept( +// allocator_type::propagate_on_container_move_assignment::value && +// is_nothrow_move_assignable::value && +// is_nothrow_move_assignable::value); + +// This tests a conforming extension + +#include +#include + +#include "../../../MoveOnly.h" +#include "../../../test_allocator.h" + +template +struct some_comp +{ + typedef T value_type; + some_comp& operator=(const some_comp&); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::multiset C; + static_assert(std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::multiset, test_allocator> C; + static_assert(!std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::multiset, other_allocator> C; + static_assert(std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::multiset> C; + static_assert(!std::is_nothrow_move_assignable::value, ""); + } +#endif +} diff --git a/test/containers/associative/multiset/multiset.cons/move_noexcept.pass.cpp b/test/containers/associative/multiset/multiset.cons/move_noexcept.pass.cpp new file mode 100644 index 00000000..8f2b4960 --- /dev/null +++ b/test/containers/associative/multiset/multiset.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. +// +//===----------------------------------------------------------------------===// + +// + +// multiset(multiset&&) +// noexcept(is_nothrow_move_constructible::value && +// is_nothrow_move_constructible::value); + +// This tests a conforming extension + +#include +#include + +#include "../../../MoveOnly.h" +#include "../../../test_allocator.h" + +template +struct some_comp +{ + typedef T value_type; + some_comp(const some_comp&); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::multiset C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::multiset, test_allocator> C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::multiset, other_allocator> C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::multiset> C; + static_assert(!std::is_nothrow_move_constructible::value, ""); + } +#endif +} diff --git a/test/containers/associative/multiset/multiset.special/swap_noexcept.pass.cpp b/test/containers/associative/multiset/multiset.special/swap_noexcept.pass.cpp new file mode 100644 index 00000000..dd287870 --- /dev/null +++ b/test/containers/associative/multiset/multiset.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. +// +//===----------------------------------------------------------------------===// + +// + +// void swap(multiset& c) +// noexcept(!allocator_type::propagate_on_container_swap::value || +// __is_nothrow_swappable::value); + +// This tests a conforming extension + +#include +#include + +#include "../../../MoveOnly.h" +#include "../../../test_allocator.h" + +template +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::multiset C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::multiset, test_allocator> C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::multiset, other_allocator> C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::multiset> C; + C c1, c2; + static_assert(!noexcept(swap(c1, c2)), ""); + } +#endif +} diff --git a/test/containers/associative/set/set.cons/default_noexcept.pass.cpp b/test/containers/associative/set/set.cons/default_noexcept.pass.cpp new file mode 100644 index 00000000..6cf394e6 --- /dev/null +++ b/test/containers/associative/set/set.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. +// +//===----------------------------------------------------------------------===// + +// + +// set() +// noexcept( +// is_nothrow_default_constructible::value && +// is_nothrow_default_constructible::value && +// is_nothrow_copy_constructible::value); + +// This tests a conforming extension + +#include +#include + +#include "../../../MoveOnly.h" +#include "../../../test_allocator.h" + +template +struct some_comp +{ + typedef T value_type; + some_comp(); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::set C; + static_assert(std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::set, test_allocator> C; + static_assert(std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::set, other_allocator> C; + static_assert(!std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::set> C; + static_assert(!std::is_nothrow_default_constructible::value, ""); + } +#endif +} diff --git a/test/containers/associative/set/set.cons/dtor_noexcept.pass.cpp b/test/containers/associative/set/set.cons/dtor_noexcept.pass.cpp new file mode 100644 index 00000000..66adff0a --- /dev/null +++ b/test/containers/associative/set/set.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. +// +//===----------------------------------------------------------------------===// + +// + +// ~set() // implied noexcept; + +#include +#include + +#include "../../../MoveOnly.h" +#include "../../../test_allocator.h" + +#if __has_feature(cxx_noexcept) + +template +struct some_comp +{ + typedef T value_type; + ~some_comp() noexcept(false); +}; + +#endif + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::set C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::set, test_allocator> C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::set, other_allocator> C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::set> C; + static_assert(!std::is_nothrow_destructible::value, ""); + } +#endif +} diff --git a/test/containers/associative/set/set.cons/move_assign_noexcept.pass.cpp b/test/containers/associative/set/set.cons/move_assign_noexcept.pass.cpp new file mode 100644 index 00000000..35683b1b --- /dev/null +++ b/test/containers/associative/set/set.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. +// +//===----------------------------------------------------------------------===// + +// + +// set& operator=(set&& c) +// noexcept( +// allocator_type::propagate_on_container_move_assignment::value && +// is_nothrow_move_assignable::value && +// is_nothrow_move_assignable::value); + +// This tests a conforming extension + +#include +#include + +#include "../../../MoveOnly.h" +#include "../../../test_allocator.h" + +template +struct some_comp +{ + typedef T value_type; + some_comp& operator=(const some_comp&); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::set C; + static_assert(std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::set, test_allocator> C; + static_assert(!std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::set, other_allocator> C; + static_assert(std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::set> C; + static_assert(!std::is_nothrow_move_assignable::value, ""); + } +#endif +} diff --git a/test/containers/associative/set/set.cons/move_noexcept.pass.cpp b/test/containers/associative/set/set.cons/move_noexcept.pass.cpp new file mode 100644 index 00000000..c3df4cac --- /dev/null +++ b/test/containers/associative/set/set.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. +// +//===----------------------------------------------------------------------===// + +// + +// set(set&&) +// noexcept(is_nothrow_move_constructible::value && +// is_nothrow_move_constructible::value); + +// This tests a conforming extension + +#include +#include + +#include "../../../MoveOnly.h" +#include "../../../test_allocator.h" + +template +struct some_comp +{ + typedef T value_type; + some_comp(const some_comp&); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::set C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::set, test_allocator> C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::set, other_allocator> C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::set> C; + static_assert(!std::is_nothrow_move_constructible::value, ""); + } +#endif +} diff --git a/test/containers/associative/set/set.special/non_member_swap.pass.cpp b/test/containers/associative/set/set.special/non_member_swap.pass.cpp index 00e19a7d..6f7d0bf5 100644 --- a/test/containers/associative/set/set.special/non_member_swap.pass.cpp +++ b/test/containers/associative/set/set.special/non_member_swap.pass.cpp @@ -109,7 +109,7 @@ int main() { typedef test_allocator A; typedef test_compare > C; - typedef std::multiset M; + typedef std::set M; V ar1[] = { 1, @@ -143,7 +143,7 @@ int main() { typedef other_allocator A; typedef test_compare > C; - typedef std::multiset M; + typedef std::set M; V ar1[] = { 1, diff --git a/test/containers/associative/set/set.special/swap_noexcept.pass.cpp b/test/containers/associative/set/set.special/swap_noexcept.pass.cpp new file mode 100644 index 00000000..2ce1d8c5 --- /dev/null +++ b/test/containers/associative/set/set.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. +// +//===----------------------------------------------------------------------===// + +// + +// void swap(set& c) +// noexcept(!allocator_type::propagate_on_container_swap::value || +// __is_nothrow_swappable::value); + +// This tests a conforming extension + +#include +#include + +#include "../../../MoveOnly.h" +#include "../../../test_allocator.h" + +template +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::set C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::set, test_allocator> C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::set, other_allocator> C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::set> C; + C c1, c2; + static_assert(!noexcept(swap(c1, c2)), ""); + } +#endif +}