diff --git a/include/unordered_set b/include/unordered_set index e50e0b6f..913cd70d 100644 --- a/include/unordered_set +++ b/include/unordered_set @@ -43,7 +43,12 @@ public: typedef /unspecified/ local_iterator; typedef /unspecified/ const_local_iterator; - explicit unordered_set(size_type n = 0, const hasher& hf = hasher(), + unordered_set() + noexcept( + is_nothrow_default_constructible::value && + is_nothrow_default_constructible::value && + is_nothrow_default_constructible::value); + explicit unordered_set(size_type n, const hasher& hf = hasher(), const key_equal& eql = key_equal(), const allocator_type& a = allocator_type()); template @@ -54,28 +59,37 @@ public: explicit unordered_set(const allocator_type&); unordered_set(const unordered_set&); unordered_set(const unordered_set&, const Allocator&); - unordered_set(unordered_set&&); + unordered_set(unordered_set&&) + noexcept( + is_nothrow_move_constructible::value && + is_nothrow_move_constructible::value && + is_nothrow_move_constructible::value); unordered_set(unordered_set&&, const Allocator&); unordered_set(initializer_list, size_type n = 0, const hasher& hf = hasher(), const key_equal& eql = key_equal(), const allocator_type& a = allocator_type()); ~unordered_set(); unordered_set& operator=(const unordered_set&); - unordered_set& operator=(unordered_set&&); + unordered_set& operator=(unordered_set&&) + noexcept( + allocator_type::propagate_on_container_move_assignment::value && + is_nothrow_move_assignable::value && + is_nothrow_move_assignable::value && + is_nothrow_move_assignable::value); unordered_set& operator=(initializer_list); - allocator_type get_allocator() const; + allocator_type get_allocator() const noexcept; - 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; - iterator begin(); - iterator end(); - const_iterator begin() const; - const_iterator end() const; - const_iterator cbegin() const; - const_iterator cend() const; + iterator begin() noexcept; + iterator end() noexcept; + const_iterator begin() const noexcept; + const_iterator end() const noexcept; + const_iterator cbegin() const noexcept; + const_iterator cend() const noexcept; template pair emplace(Args&&... args); @@ -92,9 +106,14 @@ 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(unordered_set&); + void swap(unordered_set&) + noexcept( + (!allocator_type::propagate_on_container_swap::value || + __is_nothrow_swappable::value) && + __is_nothrow_swappable::value && + __is_nothrow_swappable::value); hasher hash_function() const; key_equal key_eq() const; @@ -105,8 +124,8 @@ public: pair equal_range(const key_type& k); pair equal_range(const key_type& k) const; - size_type bucket_count() const; - size_type max_bucket_count() const; + size_type bucket_count() const noexcept; + size_type max_bucket_count() const noexcept; size_type bucket_size(size_type n) const; size_type bucket(const key_type& k) const; @@ -118,8 +137,8 @@ public: const_local_iterator cbegin(size_type n) const; const_local_iterator cend(size_type n) const; - float load_factor() const; - float max_load_factor() const; + float load_factor() const noexcept; + float max_load_factor() const noexcept; void max_load_factor(float z); void rehash(size_type n); void reserve(size_type n); @@ -127,7 +146,8 @@ public: template void swap(unordered_set& x, - unordered_set& y); + unordered_set& y) + noexcept(noexcept(x.swap(y))); template bool @@ -162,7 +182,12 @@ public: typedef /unspecified/ local_iterator; typedef /unspecified/ const_local_iterator; - explicit unordered_multiset(size_type n = 0, const hasher& hf = hasher(), + unordered_multiset() + noexcept( + is_nothrow_default_constructible::value && + is_nothrow_default_constructible::value && + is_nothrow_default_constructible::value); + explicit unordered_multiset(size_type n, const hasher& hf = hasher(), const key_equal& eql = key_equal(), const allocator_type& a = allocator_type()); template @@ -173,28 +198,37 @@ public: explicit unordered_multiset(const allocator_type&); unordered_multiset(const unordered_multiset&); unordered_multiset(const unordered_multiset&, const Allocator&); - unordered_multiset(unordered_multiset&&); + unordered_multiset(unordered_multiset&&) + noexcept( + is_nothrow_move_constructible::value && + is_nothrow_move_constructible::value && + is_nothrow_move_constructible::value); unordered_multiset(unordered_multiset&&, const Allocator&); unordered_multiset(initializer_list, size_type n = /see below/, const hasher& hf = hasher(), const key_equal& eql = key_equal(), const allocator_type& a = allocator_type()); ~unordered_multiset(); unordered_multiset& operator=(const unordered_multiset&); - unordered_multiset& operator=(unordered_multiset&&); + unordered_multiset& operator=(unordered_multiset&&) + noexcept( + allocator_type::propagate_on_container_move_assignment::value && + is_nothrow_move_assignable::value && + is_nothrow_move_assignable::value && + is_nothrow_move_assignable::value); unordered_multiset& operator=(initializer_list); - allocator_type get_allocator() const; + allocator_type get_allocator() const noexcept; - 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; - iterator begin(); - iterator end(); - const_iterator begin() const; - const_iterator end() const; - const_iterator cbegin() const; - const_iterator cend() const; + iterator begin() noexcept; + iterator end() noexcept; + const_iterator begin() const noexcept; + const_iterator end() const noexcept; + const_iterator cbegin() const noexcept; + const_iterator cend() const noexcept; template iterator emplace(Args&&... args); @@ -211,9 +245,14 @@ 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(unordered_multiset&); + void swap(unordered_multiset&) + noexcept( + (!allocator_type::propagate_on_container_swap::value || + __is_nothrow_swappable::value) && + __is_nothrow_swappable::value && + __is_nothrow_swappable::value); hasher hash_function() const; key_equal key_eq() const; @@ -224,8 +263,8 @@ public: pair equal_range(const key_type& k); pair equal_range(const key_type& k) const; - size_type bucket_count() const; - size_type max_bucket_count() const; + size_type bucket_count() const noexcept; + size_type max_bucket_count() const noexcept; size_type bucket_size(size_type n) const; size_type bucket(const key_type& k) const; @@ -237,8 +276,8 @@ public: const_local_iterator cbegin(size_type n) const; const_local_iterator cend(size_type n) const; - float load_factor() const; - float max_load_factor() const; + float load_factor() const noexcept; + float max_load_factor() const noexcept; void max_load_factor(float z); void rehash(size_type n); void reserve(size_type n); @@ -246,7 +285,8 @@ public: template void swap(unordered_multiset& x, - unordered_multiset& y); + unordered_multiset& y) + noexcept(noexcept(x.swap(y))); template bool @@ -300,7 +340,9 @@ public: typedef typename __table::const_local_iterator const_local_iterator; _LIBCPP_INLINE_VISIBILITY - unordered_set() {} // = default; + unordered_set() + _NOEXCEPT_(is_nothrow_default_constructible<__table>::value) + {} // = default; explicit unordered_set(size_type __n, const hasher& __hf = hasher(), const key_equal& __eql = key_equal()); unordered_set(size_type __n, const hasher& __hf, const key_equal& __eql, @@ -319,7 +361,8 @@ public: unordered_set(const unordered_set& __u); unordered_set(const unordered_set& __u, const allocator_type& __a); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - unordered_set(unordered_set&& __u); + unordered_set(unordered_set&& __u) + _NOEXCEPT_(is_nothrow_move_constructible<__table>::value); unordered_set(unordered_set&& __u, const allocator_type& __a); #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES unordered_set(initializer_list __il); @@ -332,33 +375,34 @@ public: // ~unordered_set() = default; // unordered_set& operator=(const unordered_set& __u) = default; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - unordered_set& operator=(unordered_set&& __u); + unordered_set& operator=(unordered_set&& __u) + _NOEXCEPT_(is_nothrow_move_assignable<__table>::value); #endif unordered_set& operator=(initializer_list __il); _LIBCPP_INLINE_VISIBILITY - allocator_type get_allocator() const + allocator_type get_allocator() const _NOEXCEPT {return allocator_type(__table_.__node_alloc());} _LIBCPP_INLINE_VISIBILITY - bool empty() const {return __table_.size() == 0;} + bool empty() const _NOEXCEPT {return __table_.size() == 0;} _LIBCPP_INLINE_VISIBILITY - size_type size() const {return __table_.size();} + size_type size() const _NOEXCEPT {return __table_.size();} _LIBCPP_INLINE_VISIBILITY - size_type max_size() const {return __table_.max_size();} + size_type max_size() const _NOEXCEPT {return __table_.max_size();} _LIBCPP_INLINE_VISIBILITY - iterator begin() {return __table_.begin();} + iterator begin() _NOEXCEPT {return __table_.begin();} _LIBCPP_INLINE_VISIBILITY - iterator end() {return __table_.end();} + iterator end() _NOEXCEPT {return __table_.end();} _LIBCPP_INLINE_VISIBILITY - const_iterator begin() const {return __table_.begin();} + const_iterator begin() const _NOEXCEPT {return __table_.begin();} _LIBCPP_INLINE_VISIBILITY - const_iterator end() const {return __table_.end();} + const_iterator end() const _NOEXCEPT {return __table_.end();} _LIBCPP_INLINE_VISIBILITY - const_iterator cbegin() const {return __table_.begin();} + const_iterator cbegin() const _NOEXCEPT {return __table_.begin();} _LIBCPP_INLINE_VISIBILITY - const_iterator cend() const {return __table_.end();} + const_iterator cend() const _NOEXCEPT {return __table_.end();} #if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) template @@ -400,10 +444,12 @@ public: iterator erase(const_iterator __first, const_iterator __last) {return __table_.erase(__first, __last);} _LIBCPP_INLINE_VISIBILITY - void clear() {__table_.clear();} + void clear() _NOEXCEPT {__table_.clear();} _LIBCPP_INLINE_VISIBILITY - void swap(unordered_set& __u) {__table_.swap(__u.__table_);} + void swap(unordered_set& __u) + _NOEXCEPT_(__is_nothrow_swappable<__table>::value) + {__table_.swap(__u.__table_);} _LIBCPP_INLINE_VISIBILITY hasher hash_function() const {return __table_.hash_function();} @@ -424,9 +470,9 @@ public: {return __table_.__equal_range_unique(__k);} _LIBCPP_INLINE_VISIBILITY - size_type bucket_count() const {return __table_.bucket_count();} + size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();} _LIBCPP_INLINE_VISIBILITY - size_type max_bucket_count() const {return __table_.max_bucket_count();} + size_type max_bucket_count() const _NOEXCEPT {return __table_.max_bucket_count();} _LIBCPP_INLINE_VISIBILITY size_type bucket_size(size_type __n) const {return __table_.bucket_size(__n);} @@ -447,9 +493,9 @@ public: const_local_iterator cend(size_type __n) const {return __table_.cend(__n);} _LIBCPP_INLINE_VISIBILITY - float load_factor() const {return __table_.load_factor();} + float load_factor() const _NOEXCEPT {return __table_.load_factor();} _LIBCPP_INLINE_VISIBILITY - float max_load_factor() const {return __table_.max_load_factor();} + float max_load_factor() const _NOEXCEPT {return __table_.max_load_factor();} _LIBCPP_INLINE_VISIBILITY void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);} _LIBCPP_INLINE_VISIBILITY @@ -536,6 +582,7 @@ template inline _LIBCPP_INLINE_VISIBILITY unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( unordered_set&& __u) + _NOEXCEPT_(is_nothrow_move_constructible<__table>::value) : __table_(_STD::move(__u.__table_)) { } @@ -588,6 +635,7 @@ template inline _LIBCPP_INLINE_VISIBILITY unordered_set<_Value, _Hash, _Pred, _Alloc>& unordered_set<_Value, _Hash, _Pred, _Alloc>::operator=(unordered_set&& __u) + _NOEXCEPT_(is_nothrow_move_assignable<__table>::value) { __table_ = _STD::move(__u.__table_); return *this; @@ -621,6 +669,7 @@ inline _LIBCPP_INLINE_VISIBILITY void swap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x, unordered_set<_Value, _Hash, _Pred, _Alloc>& __y) + _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) { __x.swap(__y); } @@ -684,7 +733,9 @@ public: typedef typename __table::const_local_iterator const_local_iterator; _LIBCPP_INLINE_VISIBILITY - unordered_multiset() {} // = default + unordered_multiset() + _NOEXCEPT_(is_nothrow_default_constructible<__table>::value) + {} // = default explicit unordered_multiset(size_type __n, const hasher& __hf = hasher(), const key_equal& __eql = key_equal()); unordered_multiset(size_type __n, const hasher& __hf, @@ -703,7 +754,8 @@ public: unordered_multiset(const unordered_multiset& __u); unordered_multiset(const unordered_multiset& __u, const allocator_type& __a); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - unordered_multiset(unordered_multiset&& __u); + unordered_multiset(unordered_multiset&& __u) + _NOEXCEPT_(is_nothrow_move_constructible<__table>::value); unordered_multiset(unordered_multiset&& __u, const allocator_type& __a); #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES unordered_multiset(initializer_list __il); @@ -716,33 +768,34 @@ public: // ~unordered_multiset() = default; // unordered_multiset& operator=(const unordered_multiset& __u) = default; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - unordered_multiset& operator=(unordered_multiset&& __u); + unordered_multiset& operator=(unordered_multiset&& __u) + _NOEXCEPT_(is_nothrow_move_assignable<__table>::value); #endif unordered_multiset& operator=(initializer_list __il); _LIBCPP_INLINE_VISIBILITY - allocator_type get_allocator() const + allocator_type get_allocator() const _NOEXCEPT {return allocator_type(__table_.__node_alloc());} _LIBCPP_INLINE_VISIBILITY - bool empty() const {return __table_.size() == 0;} + bool empty() const _NOEXCEPT {return __table_.size() == 0;} _LIBCPP_INLINE_VISIBILITY - size_type size() const {return __table_.size();} + size_type size() const _NOEXCEPT {return __table_.size();} _LIBCPP_INLINE_VISIBILITY - size_type max_size() const {return __table_.max_size();} + size_type max_size() const _NOEXCEPT {return __table_.max_size();} _LIBCPP_INLINE_VISIBILITY - iterator begin() {return __table_.begin();} + iterator begin() _NOEXCEPT {return __table_.begin();} _LIBCPP_INLINE_VISIBILITY - iterator end() {return __table_.end();} + iterator end() _NOEXCEPT {return __table_.end();} _LIBCPP_INLINE_VISIBILITY - const_iterator begin() const {return __table_.begin();} + const_iterator begin() const _NOEXCEPT {return __table_.begin();} _LIBCPP_INLINE_VISIBILITY - const_iterator end() const {return __table_.end();} + const_iterator end() const _NOEXCEPT {return __table_.end();} _LIBCPP_INLINE_VISIBILITY - const_iterator cbegin() const {return __table_.begin();} + const_iterator cbegin() const _NOEXCEPT {return __table_.begin();} _LIBCPP_INLINE_VISIBILITY - const_iterator cend() const {return __table_.end();} + const_iterator cend() const _NOEXCEPT {return __table_.end();} #if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) template @@ -782,10 +835,12 @@ public: iterator erase(const_iterator __first, const_iterator __last) {return __table_.erase(__first, __last);} _LIBCPP_INLINE_VISIBILITY - void clear() {__table_.clear();} + void clear() _NOEXCEPT {__table_.clear();} _LIBCPP_INLINE_VISIBILITY - void swap(unordered_multiset& __u) {__table_.swap(__u.__table_);} + void swap(unordered_multiset& __u) + _NOEXCEPT_(__is_nothrow_swappable<__table>::value) + {__table_.swap(__u.__table_);} _LIBCPP_INLINE_VISIBILITY hasher hash_function() const {return __table_.hash_function();} @@ -806,9 +861,9 @@ public: {return __table_.__equal_range_multi(__k);} _LIBCPP_INLINE_VISIBILITY - size_type bucket_count() const {return __table_.bucket_count();} + size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();} _LIBCPP_INLINE_VISIBILITY - size_type max_bucket_count() const {return __table_.max_bucket_count();} + size_type max_bucket_count() const _NOEXCEPT {return __table_.max_bucket_count();} _LIBCPP_INLINE_VISIBILITY size_type bucket_size(size_type __n) const {return __table_.bucket_size(__n);} @@ -829,9 +884,9 @@ public: const_local_iterator cend(size_type __n) const {return __table_.cend(__n);} _LIBCPP_INLINE_VISIBILITY - float load_factor() const {return __table_.load_factor();} + float load_factor() const _NOEXCEPT {return __table_.load_factor();} _LIBCPP_INLINE_VISIBILITY - float max_load_factor() const {return __table_.max_load_factor();} + float max_load_factor() const _NOEXCEPT {return __table_.max_load_factor();} _LIBCPP_INLINE_VISIBILITY void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);} _LIBCPP_INLINE_VISIBILITY @@ -919,6 +974,7 @@ template inline _LIBCPP_INLINE_VISIBILITY unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( unordered_multiset&& __u) + _NOEXCEPT_(is_nothrow_move_constructible<__table>::value) : __table_(_STD::move(__u.__table_)) { } @@ -972,6 +1028,7 @@ inline _LIBCPP_INLINE_VISIBILITY unordered_multiset<_Value, _Hash, _Pred, _Alloc>& unordered_multiset<_Value, _Hash, _Pred, _Alloc>::operator=( unordered_multiset&& __u) + _NOEXCEPT_(is_nothrow_move_assignable<__table>::value) { __table_ = _STD::move(__u.__table_); return *this; @@ -1005,6 +1062,7 @@ inline _LIBCPP_INLINE_VISIBILITY void swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x, unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y) + _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) { __x.swap(__y); } diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/default_noexcept.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/default_noexcept.pass.cpp new file mode 100644 index 00000000..84bd140e --- /dev/null +++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/default_noexcept.pass.cpp @@ -0,0 +1,70 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// unordered_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" +#include "../../../test_hash.h" + +template +struct some_comp +{ + typedef T value_type; + some_comp(); + some_comp(const some_comp&); +}; + +template +struct some_hash +{ + typedef T value_type; + some_hash(); + some_hash(const some_hash&); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::unordered_multiset C; + static_assert(std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::unordered_multiset, + std::equal_to, test_allocator> C; + static_assert(std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::unordered_multiset, + std::equal_to, other_allocator> C; + static_assert(!std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::unordered_multiset> C; + static_assert(!std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::unordered_multiset, + some_comp> C; + static_assert(!std::is_nothrow_default_constructible::value, ""); + } +#endif +} diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/dtor_noexcept.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/dtor_noexcept.pass.cpp new file mode 100644 index 00000000..03b33fff --- /dev/null +++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/dtor_noexcept.pass.cpp @@ -0,0 +1,67 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// ~unordered_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); +}; + +template +struct some_hash +{ + typedef T value_type; + some_hash(); + some_hash(const some_hash&); + ~some_hash() noexcept(false); +}; + +#endif + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::unordered_multiset C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::unordered_multiset, + std::equal_to, test_allocator> C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::unordered_multiset, + std::equal_to, other_allocator> C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::unordered_multiset> C; + static_assert(!std::is_nothrow_destructible::value, ""); + } + { + typedef std::unordered_multiset, + some_comp> C; + static_assert(!std::is_nothrow_destructible::value, ""); + } +#endif +} diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/move_assign_noexcept.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/move_assign_noexcept.pass.cpp new file mode 100644 index 00000000..8d601533 --- /dev/null +++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/move_assign_noexcept.pass.cpp @@ -0,0 +1,69 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// unordered_multiset& operator=(unordered_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&); +}; + +template +struct some_hash +{ + typedef T value_type; + some_hash(); + some_hash(const some_hash&); + some_hash& operator=(const some_hash&); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::unordered_multiset C; + static_assert(std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::unordered_multiset, + std::equal_to, test_allocator> C; + static_assert(!std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::unordered_multiset, + std::equal_to, other_allocator> C; + static_assert(std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::unordered_multiset> C; + static_assert(!std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::unordered_multiset, + some_comp> C; + static_assert(!std::is_nothrow_move_assignable::value, ""); + } +#endif +} diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/move_noexcept.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/move_noexcept.pass.cpp new file mode 100644 index 00000000..7ef3ca6d --- /dev/null +++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/move_noexcept.pass.cpp @@ -0,0 +1,66 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// unordered_multiset(unordered_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&); +}; + +template +struct some_hash +{ + typedef T value_type; + some_hash(); + some_hash(const some_hash&); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::unordered_multiset C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::unordered_multiset, + std::equal_to, test_allocator> C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::unordered_multiset, + std::equal_to, other_allocator> C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::unordered_multiset> C; + static_assert(!std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::unordered_multiset, + some_comp> C; + static_assert(!std::is_nothrow_move_constructible::value, ""); + } +#endif +} diff --git a/test/containers/unord/unord.multiset/unord.multiset.swap/swap_noexcept.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.swap/swap_noexcept.pass.cpp new file mode 100644 index 00000000..95c84f48 --- /dev/null +++ b/test/containers/unord/unord.multiset/unord.multiset.swap/swap_noexcept.pass.cpp @@ -0,0 +1,73 @@ +//===----------------------------------------------------------------------===// +// +// 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(unordered_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&) {} +}; + +template +struct some_hash +{ + typedef T value_type; + some_hash() {} + some_hash(const some_hash&); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::unordered_multiset C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::unordered_multiset, + std::equal_to, test_allocator> C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::unordered_multiset, + std::equal_to, other_allocator> C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::unordered_multiset> C; + C c1, c2; + static_assert(!noexcept(swap(c1, c2)), ""); + } + { + typedef std::unordered_multiset, + some_comp> C; + C c1, c2; + static_assert(!noexcept(swap(c1, c2)), ""); + } +#endif +} diff --git a/test/containers/unord/unord.set/unord.set.cnstr/default_noexcept.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/default_noexcept.pass.cpp new file mode 100644 index 00000000..5063d51e --- /dev/null +++ b/test/containers/unord/unord.set/unord.set.cnstr/default_noexcept.pass.cpp @@ -0,0 +1,70 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// unordered_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" +#include "../../../test_hash.h" + +template +struct some_comp +{ + typedef T value_type; + some_comp(); + some_comp(const some_comp&); +}; + +template +struct some_hash +{ + typedef T value_type; + some_hash(); + some_hash(const some_hash&); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::unordered_set C; + static_assert(std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::unordered_set, + std::equal_to, test_allocator> C; + static_assert(std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::unordered_set, + std::equal_to, other_allocator> C; + static_assert(!std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::unordered_set> C; + static_assert(!std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::unordered_set, + some_comp> C; + static_assert(!std::is_nothrow_default_constructible::value, ""); + } +#endif +} diff --git a/test/containers/unord/unord.set/unord.set.cnstr/dtor_noexcept.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/dtor_noexcept.pass.cpp new file mode 100644 index 00000000..3e468e9d --- /dev/null +++ b/test/containers/unord/unord.set/unord.set.cnstr/dtor_noexcept.pass.cpp @@ -0,0 +1,67 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// ~unordered_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); +}; + +template +struct some_hash +{ + typedef T value_type; + some_hash(); + some_hash(const some_hash&); + ~some_hash() noexcept(false); +}; + +#endif + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::unordered_set C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::unordered_set, + std::equal_to, test_allocator> C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::unordered_set, + std::equal_to, other_allocator> C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::unordered_set> C; + static_assert(!std::is_nothrow_destructible::value, ""); + } + { + typedef std::unordered_set, + some_comp> C; + static_assert(!std::is_nothrow_destructible::value, ""); + } +#endif +} diff --git a/test/containers/unord/unord.set/unord.set.cnstr/move_assign_noexcept.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/move_assign_noexcept.pass.cpp new file mode 100644 index 00000000..176e9c5b --- /dev/null +++ b/test/containers/unord/unord.set/unord.set.cnstr/move_assign_noexcept.pass.cpp @@ -0,0 +1,69 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// unordered_set& operator=(unordered_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&); +}; + +template +struct some_hash +{ + typedef T value_type; + some_hash(); + some_hash(const some_hash&); + some_hash& operator=(const some_hash&); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::unordered_set C; + static_assert(std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::unordered_set, + std::equal_to, test_allocator> C; + static_assert(!std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::unordered_set, + std::equal_to, other_allocator> C; + static_assert(std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::unordered_set> C; + static_assert(!std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::unordered_set, + some_comp> C; + static_assert(!std::is_nothrow_move_assignable::value, ""); + } +#endif +} diff --git a/test/containers/unord/unord.set/unord.set.cnstr/move_noexcept.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/move_noexcept.pass.cpp new file mode 100644 index 00000000..67f16c3c --- /dev/null +++ b/test/containers/unord/unord.set/unord.set.cnstr/move_noexcept.pass.cpp @@ -0,0 +1,66 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// unordered_set(unordered_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&); +}; + +template +struct some_hash +{ + typedef T value_type; + some_hash(); + some_hash(const some_hash&); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::unordered_set C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::unordered_set, + std::equal_to, test_allocator> C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::unordered_set, + std::equal_to, other_allocator> C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::unordered_set> C; + static_assert(!std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::unordered_set, + some_comp> C; + static_assert(!std::is_nothrow_move_constructible::value, ""); + } +#endif +} diff --git a/test/containers/unord/unord.set/unord.set.swap/swap_noexcept.pass.cpp b/test/containers/unord/unord.set/unord.set.swap/swap_noexcept.pass.cpp new file mode 100644 index 00000000..508d567b --- /dev/null +++ b/test/containers/unord/unord.set/unord.set.swap/swap_noexcept.pass.cpp @@ -0,0 +1,73 @@ +//===----------------------------------------------------------------------===// +// +// 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(unordered_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&) {} +}; + +template +struct some_hash +{ + typedef T value_type; + some_hash() {} + some_hash(const some_hash&); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::unordered_set C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::unordered_set, + std::equal_to, test_allocator> C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::unordered_set, + std::equal_to, other_allocator> C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::unordered_set> C; + C c1, c2; + static_assert(!noexcept(swap(c1, c2)), ""); + } + { + typedef std::unordered_set, + some_comp> C; + C c1, c2; + static_assert(!noexcept(swap(c1, c2)), ""); + } +#endif +}