diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 0f45d80d9680f2a345ff12567ef31873b9f603ba..93a9adb575f631f6674b018dda0d8b9c700fac97 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,75 @@ +2015-07-13 Jonathan Wakely <jwakely@redhat.com> + + * include/bits/c++config (_GLIBCXX_NOEXCEPT_IF): Define. + * include/bits/forward_list.h (forward_list::swap): Make noexcept + unconditional. + * include/bits/hashtable.h (_Hashtable::swap): Do not use + _S_nothrow_swap(). + * include/bits/stl_bvector.h (vector<bool>::swap): Make noexcept + unconditional. + * include/bits/stl_deque.h (deque::swap): Likewise. + (swap(deque&, deque&)): Use _GLIBCXX_NOEXCEPT_IF. + * include/bits/stl_list.h (list::swap): Make noexcept unconditional. + (swap(list&, list&)): Use _GLIBCXX_NOEXCEPT_IF. + * include/bits/stl_map.h (map::swap, swap(map&, map&)): Use + _GLIBCXX_NOEXCEPT_IF, do not depend on _S_nothrow_swap. + * include/bits/stl_multimap.h (multimap::swap, + swap(multimap&, multimap&)): Likewise. + * include/bits/stl_multiset.h (multiset::swap, + swap(multiset&, multiset&)): Likewise. + * include/bits/stl_set.h (set::swap, swap(set&, set&)): Likewise. + * include/bits/stl_tree.h (_Rb_tree::swap, + swap(_Rb_tree&, _Rb_tree&)): Likewise. + * include/bits/stl_vector.h (vector::swap): Make noexcept + unconditional. + (swap(vector&, vector&)): Use _GLIBCXX_NOEXCEPT_IF. + * include/debug/deque (deque::swap, swap): Likewise. + * include/debug/forward_list (swap): Add noexcept. + * include/debug/list (list::swap, swap): Use _GLIBCXX_NOEXCEPT_IF. + * include/debug/map.h (map::swap, swap): Likewise. + * include/debug/multimap.h (multimap::swap, swap): Likewise. + * include/debug/multiset.h (multiset::Swap, swap): Likewise. + * include/debug/set.h (set::swap, swap): Likewise. + * include/debug/unordered_map (unordered_map::swap, + unordered_multimap::swap, swap): Likewise. + * include/debug/unordered_set (unordered_set::swap, + unordered_multiset::swap, swap): Likewise. + * include/debug/vector (vector::swap, swap): Likewise. + * include/ext/alloc_traits.h (__alloc_traits::_S_nothrow_swap()): + Remove. + * include/profile/deque (deque::swap, swap): Use _GLIBCXX_NOEXCEPT_IF. + * include/profile/forward_list (swap): Add noexcept. + * include/profile/list (list::swap, swap) : Use _GLIBCXX_NOEXCEPT_IF. + * include/profile/map.h (map::swap, swap): Likewise. + * include/profile/multimap.h (multimap::swap, swap): Likewise. + * include/profile/multiset.h (multiset::swap, swap): Likewise. + * include/profile/set.h (set::swap, swap): Likewise. + * include/profile/unordered_map (swap): Likewise. + * include/profile/unordered_set (swap): Likewise. + * include/profile/vector (vector::swap, swap): Likewise. Remove + overloads for swapping rvalues. + * testsuite/23_containers/deque/allocator/noexcept.cc: Update tests + for noexcept on swap. + * testsuite/23_containers/forward_list/allocator/noexcept.cc: + Likewise. + * testsuite/23_containers/list/allocator/noexcept.cc: Likewise. + * testsuite/23_containers/map/allocator/noexcept.cc: Likewise. + * testsuite/23_containers/multimap/allocator/noexcept.cc: Likewise. + * testsuite/23_containers/multiset/allocator/noexcept.cc: Likewise. + * testsuite/23_containers/set/allocator/noexcept.cc: Likewise. + * testsuite/23_containers/unordered_map/allocator/noexcept.cc: + Likewise. + * testsuite/23_containers/unordered_multimap/allocator/noexcept.cc: + Likewise. + * testsuite/23_containers/unordered_multiset/allocator/noexcept.cc: + Likewise. + * testsuite/23_containers/unordered_set/allocator/noexcept.cc: + Likewise. + * testsuite/23_containers/vector/allocator/noexcept.cc: Likewise. + * testsuite/23_containers/vector/bool/allocator/noexcept.cc: Likewise. + * testsuite/ext/profile/mutex_extensions_neg.cc: Adjust dg-error line + number. + 2015-07-13 John Marino <gnugcc@marino.st> * config/os/bsd/dragonfly/os_defines.h (_GLIBCXX_USE_C99_CHECK, diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config index ae3065feaae5fba510374806d05b66cb7ae8237e..34acca36f38cd1932b837d31087895953203d260 100644 --- a/libstdc++-v3/include/bits/c++config +++ b/libstdc++-v3/include/bits/c++config @@ -115,10 +115,12 @@ #ifndef _GLIBCXX_NOEXCEPT # if __cplusplus >= 201103L # define _GLIBCXX_NOEXCEPT noexcept +# define _GLIBCXX_NOEXCEPT_IF(_COND) noexcept(_COND) # define _GLIBCXX_USE_NOEXCEPT noexcept # define _GLIBCXX_THROW(_EXC) # else # define _GLIBCXX_NOEXCEPT +# define _GLIBCXX_NOEXCEPT_IF(_COND) # define _GLIBCXX_USE_NOEXCEPT throw() # define _GLIBCXX_THROW(_EXC) throw(_EXC) # endif diff --git a/libstdc++-v3/include/bits/forward_list.h b/libstdc++-v3/include/bits/forward_list.h index db02661d3a0ea8cc103a30407a1fb67b748b4a0a..d87f1754ed3b02b4f2f527d2b112a48285672a2c 100644 --- a/libstdc++-v3/include/bits/forward_list.h +++ b/libstdc++-v3/include/bits/forward_list.h @@ -992,8 +992,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * function. */ void - swap(forward_list& __list) - noexcept(_Node_alloc_traits::_S_nothrow_swap()) + swap(forward_list& __list) noexcept { std::swap(this->_M_impl._M_head._M_next, __list._M_impl._M_head._M_next); diff --git a/libstdc++-v3/include/bits/hashtable.h b/libstdc++-v3/include/bits/hashtable.h index 0495f4bdd2fe8c778444b1572b1bf03fe245e422..fcecdc46b441f5e399ec612afb663ee38257b6a8 100644 --- a/libstdc++-v3/include/bits/hashtable.h +++ b/libstdc++-v3/include/bits/hashtable.h @@ -475,8 +475,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION void swap(_Hashtable&) - noexcept(__node_alloc_traits::_S_nothrow_swap() - && __is_nothrow_swappable<_H1>::value + noexcept(__is_nothrow_swappable<_H1>::value && __is_nothrow_swappable<_Equal>::value); // Basic container operations @@ -1237,8 +1236,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _H1, _H2, _Hash, _RehashPolicy, _Traits>:: swap(_Hashtable& __x) - noexcept(__node_alloc_traits::_S_nothrow_swap() - && __is_nothrow_swappable<_H1>::value + noexcept(__is_nothrow_swappable<_H1>::value && __is_nothrow_swappable<_Equal>::value) { // The only base class with member variables is hash_code_base. diff --git a/libstdc++-v3/include/bits/stl_bvector.h b/libstdc++-v3/include/bits/stl_bvector.h index 71bee213a867a380bb1c3a107a314115f0d7e949..800b4740d6362364d8ceed02d1d22fa196cd2c89 100644 --- a/libstdc++-v3/include/bits/stl_bvector.h +++ b/libstdc++-v3/include/bits/stl_bvector.h @@ -927,10 +927,7 @@ template<typename _Alloc> } void - swap(vector& __x) -#if __cplusplus >= 201103L - noexcept(_Bit_alloc_traits::_S_nothrow_swap()) -#endif + swap(vector& __x) _GLIBCXX_NOEXCEPT { std::swap(this->_M_impl._M_start, __x._M_impl._M_start); std::swap(this->_M_impl._M_finish, __x._M_impl._M_finish); diff --git a/libstdc++-v3/include/bits/stl_deque.h b/libstdc++-v3/include/bits/stl_deque.h index 9b996684ef999c3f63db8aa0ca0a8d106f29972a..50570efbfa70a5e02bee58dd64a07b7ffc12bbca 100644 --- a/libstdc++-v3/include/bits/stl_deque.h +++ b/libstdc++-v3/include/bits/stl_deque.h @@ -1777,10 +1777,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * std::swap(d1,d2) will feed to this function. */ void - swap(deque& __x) -#if __cplusplus >= 201103L - noexcept(_Alloc_traits::_S_nothrow_swap()) -#endif + swap(deque& __x) _GLIBCXX_NOEXCEPT { _M_impl._M_swap_data(__x._M_impl); _Alloc_traits::_S_on_swap(_M_get_Tp_allocator(), @@ -2271,9 +2268,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER template<typename _Tp, typename _Alloc> inline void swap(deque<_Tp,_Alloc>& __x, deque<_Tp,_Alloc>& __y) -#if __cplusplus >= 201103L - noexcept(noexcept(__x.swap(__y))) -#endif + _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y))) { __x.swap(__y); } #undef _GLIBCXX_DEQUE_BUF_SIZE diff --git a/libstdc++-v3/include/bits/stl_list.h b/libstdc++-v3/include/bits/stl_list.h index 409f1fc0262b22c0e9ec02e0027bb460cfc3712a..0509164828e7b38e250d2b4d5a8724fb612ec9a1 100644 --- a/libstdc++-v3/include/bits/stl_list.h +++ b/libstdc++-v3/include/bits/stl_list.h @@ -1350,10 +1350,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * function. */ void - swap(list& __x) -#if __cplusplus >= 201103L - noexcept(_Node_alloc_traits::_S_nothrow_swap()) -#endif + swap(list& __x) _GLIBCXX_NOEXCEPT { __detail::_List_node_base::swap(this->_M_impl._M_node, __x._M_impl._M_node); @@ -1919,9 +1916,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 template<typename _Tp, typename _Alloc> inline void swap(list<_Tp, _Alloc>& __x, list<_Tp, _Alloc>& __y) -#if __cplusplus >= 201103L - noexcept(noexcept(__x.swap(__y))) -#endif + _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y))) { __x.swap(__y); } _GLIBCXX_END_NAMESPACE_CONTAINER diff --git a/libstdc++-v3/include/bits/stl_map.h b/libstdc++-v3/include/bits/stl_map.h index d6ad16a195016fd5dff8dcc71689d6cad4c73b25..6e9fdcc2a4a0afe4b81ff0b6017d3973e86820e4 100644 --- a/libstdc++-v3/include/bits/stl_map.h +++ b/libstdc++-v3/include/bits/stl_map.h @@ -794,10 +794,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER */ void swap(map& __x) -#if __cplusplus >= 201103L - noexcept(_Alloc_traits::_S_nothrow_swap() - && __is_nothrow_swappable<_Compare>::value) -#endif + _GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Compare>::value) { _M_t.swap(__x._M_t); } /** @@ -1125,9 +1122,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER inline void swap(map<_Key, _Tp, _Compare, _Alloc>& __x, map<_Key, _Tp, _Compare, _Alloc>& __y) -#if __cplusplus >= 201103L - noexcept(noexcept(__x.swap(__y))) -#endif + _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y))) { __x.swap(__y); } _GLIBCXX_END_NAMESPACE_CONTAINER diff --git a/libstdc++-v3/include/bits/stl_multimap.h b/libstdc++-v3/include/bits/stl_multimap.h index 725dea38aaf8997aa81dfff052794d7e5d8b0b28..12ff6e6a74cb25333a62864bbec9fc5bb300ffe5 100644 --- a/libstdc++-v3/include/bits/stl_multimap.h +++ b/libstdc++-v3/include/bits/stl_multimap.h @@ -704,10 +704,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER */ void swap(multimap& __x) -#if __cplusplus >= 201103L - noexcept(_Alloc_traits::_S_nothrow_swap() - && __is_nothrow_swappable<_Compare>::value) -#endif + _GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Compare>::value) { _M_t.swap(__x._M_t); } /** @@ -1026,9 +1023,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER inline void swap(multimap<_Key, _Tp, _Compare, _Alloc>& __x, multimap<_Key, _Tp, _Compare, _Alloc>& __y) -#if __cplusplus >= 201103L - noexcept(noexcept(__x.swap(__y))) -#endif + _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y))) { __x.swap(__y); } _GLIBCXX_END_NAMESPACE_CONTAINER diff --git a/libstdc++-v3/include/bits/stl_multiset.h b/libstdc++-v3/include/bits/stl_multiset.h index 578b6793878839430fcc1ef08ae4a4f71c4864c6..5ccc6dd61f72fd2cd4e8bb7dcfc4d640716a733c 100644 --- a/libstdc++-v3/include/bits/stl_multiset.h +++ b/libstdc++-v3/include/bits/stl_multiset.h @@ -406,10 +406,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER */ void swap(multiset& __x) -#if __cplusplus >= 201103L - noexcept(_Alloc_traits::_S_nothrow_swap() - && __is_nothrow_swappable<_Compare>::value) -#endif + _GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Compare>::value) { _M_t.swap(__x._M_t); } // insert/erase @@ -875,9 +872,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER inline void swap(multiset<_Key, _Compare, _Alloc>& __x, multiset<_Key, _Compare, _Alloc>& __y) -#if __cplusplus >= 201103L - noexcept(noexcept(__x.swap(__y))) -#endif + _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y))) { __x.swap(__y); } _GLIBCXX_END_NAMESPACE_CONTAINER diff --git a/libstdc++-v3/include/bits/stl_set.h b/libstdc++-v3/include/bits/stl_set.h index 21c7db971cdb2614630e8bd7d1142ff135700879..cf74368fa0e145e6a51bd81b0b7ec40e38e9f10b 100644 --- a/libstdc++-v3/include/bits/stl_set.h +++ b/libstdc++-v3/include/bits/stl_set.h @@ -410,10 +410,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER */ void swap(set& __x) -#if __cplusplus >= 201103L - noexcept(_Alloc_traits::_S_nothrow_swap() - && __is_nothrow_swappable<_Compare>::value) -#endif + _GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Compare>::value) { _M_t.swap(__x._M_t); } // insert/erase @@ -891,9 +888,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER template<typename _Key, typename _Compare, typename _Alloc> inline void swap(set<_Key, _Compare, _Alloc>& __x, set<_Key, _Compare, _Alloc>& __y) -#if __cplusplus >= 201103L - noexcept(noexcept(__x.swap(__y))) -#endif + _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y))) { __x.swap(__y); } _GLIBCXX_END_NAMESPACE_CONTAINER diff --git a/libstdc++-v3/include/bits/stl_tree.h b/libstdc++-v3/include/bits/stl_tree.h index 58c6b43fac0a37979e5cb4d1e2e6fa06342d1039..3030e1ed0241d7ce63e2f28e793a37023aea7905 100644 --- a/libstdc++-v3/include/bits/stl_tree.h +++ b/libstdc++-v3/include/bits/stl_tree.h @@ -920,11 +920,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return _Alloc_traits::max_size(_M_get_Node_allocator()); } void -#if __cplusplus >= 201103L - swap(_Rb_tree& __t) noexcept(_Alloc_traits::_S_nothrow_swap()); -#else - swap(_Rb_tree& __t); -#endif + swap(_Rb_tree& __t) + _GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Compare>::value); // Insert/erase. #if __cplusplus >= 201103L @@ -1747,10 +1744,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION typename _Compare, typename _Alloc> void _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: - swap(_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __t) -#if __cplusplus >= 201103L - noexcept(_Alloc_traits::_S_nothrow_swap()) -#endif + swap(_Rb_tree& __t) + _GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Compare>::value) { if (_M_root() == 0) { diff --git a/libstdc++-v3/include/bits/stl_vector.h b/libstdc++-v3/include/bits/stl_vector.h index 1f3269b1c0a59b7e0ff44ddb3fa4b06c13f6676a..8407a153f069887a8442cf01c8b71eb881d22d9f 100644 --- a/libstdc++-v3/include/bits/stl_vector.h +++ b/libstdc++-v3/include/bits/stl_vector.h @@ -1190,10 +1190,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * std::swap(v1,v2) will feed to this function. */ void - swap(vector& __x) -#if __cplusplus >= 201103L - noexcept(_Alloc_traits::_S_nothrow_swap()) -#endif + swap(vector& __x) _GLIBCXX_NOEXCEPT { this->_M_impl._M_swap_data(__x._M_impl); _Alloc_traits::_S_on_swap(_M_get_Tp_allocator(), @@ -1556,9 +1553,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER template<typename _Tp, typename _Alloc> inline void swap(vector<_Tp, _Alloc>& __x, vector<_Tp, _Alloc>& __y) -#if __cplusplus >= 201103L - noexcept(noexcept(__x.swap(__y))) -#endif + _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y))) { __x.swap(__y); } _GLIBCXX_END_NAMESPACE_CONTAINER diff --git a/libstdc++-v3/include/debug/deque b/libstdc++-v3/include/debug/deque index 7d15e33606b3bca70da8bfc3b2981301439bf876..fe8b3ac4a9519222be1abfb8a30a901974b8aefb 100644 --- a/libstdc++-v3/include/debug/deque +++ b/libstdc++-v3/include/debug/deque @@ -588,9 +588,7 @@ namespace __debug void swap(deque& __x) -#if __cplusplus >= 201103L - noexcept( noexcept(declval<_Base>().swap(__x)) ) -#endif + _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) ) { _Safe::_M_swap(__x); _Base::swap(__x); @@ -649,6 +647,7 @@ namespace __debug template<typename _Tp, typename _Alloc> inline void swap(deque<_Tp, _Alloc>& __lhs, deque<_Tp, _Alloc>& __rhs) + _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs))) { __lhs.swap(__rhs); } } // namespace __debug diff --git a/libstdc++-v3/include/debug/forward_list b/libstdc++-v3/include/debug/forward_list index df35bc29cf57bedaa16e6d971b2517baec398cc0..ad2d2652003821afe5a8801c5c1af93d9674b8cc 100644 --- a/libstdc++-v3/include/debug/forward_list +++ b/libstdc++-v3/include/debug/forward_list @@ -473,7 +473,7 @@ namespace __debug void swap(forward_list& __list) - noexcept( noexcept(declval<_Base>().swap(__list)) ) + noexcept( noexcept(declval<_Base&>().swap(__list)) ) { _Safe::_M_swap(__list); _Base::swap(__list); @@ -814,8 +814,8 @@ namespace __debug /// See std::forward_list::swap(). template<typename _Tp, typename _Alloc> inline void - swap(forward_list<_Tp, _Alloc>& __lx, - forward_list<_Tp, _Alloc>& __ly) + swap(forward_list<_Tp, _Alloc>& __lx, forward_list<_Tp, _Alloc>& __ly) + noexcept(noexcept(__lx.swap(__ly))) { __lx.swap(__ly); } } // namespace __debug diff --git a/libstdc++-v3/include/debug/list b/libstdc++-v3/include/debug/list index 0f3f1a0e2416b97620ca2a41f2c5c14af2e71ea6..bd9f5a3f8efeff40541a248f0f54f1339d601669 100644 --- a/libstdc++-v3/include/debug/list +++ b/libstdc++-v3/include/debug/list @@ -525,9 +525,7 @@ namespace __debug void swap(list& __x) -#if __cplusplus >= 201103L - noexcept( noexcept(declval<_Base>().swap(__x)) ) -#endif + _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) ) { _Safe::_M_swap(__x); _Base::swap(__x); @@ -808,6 +806,7 @@ namespace __debug template<typename _Tp, typename _Alloc> inline void swap(list<_Tp, _Alloc>& __lhs, list<_Tp, _Alloc>& __rhs) + _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs))) { __lhs.swap(__rhs); } } // namespace __debug diff --git a/libstdc++-v3/include/debug/map.h b/libstdc++-v3/include/debug/map.h index 9bda8eba1da02925c87486c172ca5100e38cd70f..d45cf793e9d033806d17224e4781dd0d83335344 100644 --- a/libstdc++-v3/include/debug/map.h +++ b/libstdc++-v3/include/debug/map.h @@ -393,9 +393,7 @@ namespace __debug void swap(map& __x) -#if __cplusplus >= 201103L - noexcept( noexcept(declval<_Base>().swap(__x)) ) -#endif + _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) ) { _Safe::_M_swap(__x); _Base::swap(__x); @@ -589,6 +587,7 @@ namespace __debug inline void swap(map<_Key, _Tp, _Compare, _Allocator>& __lhs, map<_Key, _Tp, _Compare, _Allocator>& __rhs) + _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs))) { __lhs.swap(__rhs); } } // namespace __debug diff --git a/libstdc++-v3/include/debug/multimap.h b/libstdc++-v3/include/debug/multimap.h index b9b0a74c94e59c87b0bfee2553ecda100aff9bbe..710cd4614bf73e599ef813ba0f050e324fa7d4ee 100644 --- a/libstdc++-v3/include/debug/multimap.h +++ b/libstdc++-v3/include/debug/multimap.h @@ -374,9 +374,7 @@ namespace __debug void swap(multimap& __x) -#if __cplusplus >= 201103L - noexcept( noexcept(declval<_Base>().swap(__x)) ) -#endif + _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) ) { _Safe::_M_swap(__x); _Base::swap(__x); @@ -570,6 +568,7 @@ namespace __debug inline void swap(multimap<_Key, _Tp, _Compare, _Allocator>& __lhs, multimap<_Key, _Tp, _Compare, _Allocator>& __rhs) + _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs))) { __lhs.swap(__rhs); } } // namespace __debug diff --git a/libstdc++-v3/include/debug/multiset.h b/libstdc++-v3/include/debug/multiset.h index f1f6e2c576a000492a6cf6e48b33d73f7d3a2f1a..94fa3594b5f9bad4c44b50240bf79519b58f01a2 100644 --- a/libstdc++-v3/include/debug/multiset.h +++ b/libstdc++-v3/include/debug/multiset.h @@ -361,9 +361,7 @@ namespace __debug void swap(multiset& __x) -#if __cplusplus >= 201103L - noexcept( noexcept(declval<_Base>().swap(__x)) ) -#endif + _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) ) { _Safe::_M_swap(__x); _Base::swap(__x); @@ -550,6 +548,7 @@ namespace __debug void swap(multiset<_Key, _Compare, _Allocator>& __x, multiset<_Key, _Compare, _Allocator>& __y) + _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y))) { return __x.swap(__y); } } // namespace __debug diff --git a/libstdc++-v3/include/debug/set.h b/libstdc++-v3/include/debug/set.h index 1ca6dda9c0e1ff52a51e2487312a731174fcc79a..ad2c76e2f40aeead68cc9e65929b5f8f27e02a7e 100644 --- a/libstdc++-v3/include/debug/set.h +++ b/libstdc++-v3/include/debug/set.h @@ -368,9 +368,7 @@ namespace __debug void swap(set& __x) -#if __cplusplus >= 201103L - noexcept( noexcept(declval<_Base>().swap(__x)) ) -#endif + _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) ) { _Safe::_M_swap(__x); _Base::swap(__x); @@ -557,6 +555,7 @@ namespace __debug void swap(set<_Key, _Compare, _Allocator>& __x, set<_Key, _Compare, _Allocator>& __y) + _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y))) { return __x.swap(__y); } } // namespace __debug diff --git a/libstdc++-v3/include/debug/unordered_map b/libstdc++-v3/include/debug/unordered_map index 41e20d7f2033aa86fcf66ebf86f60bdb0d3763ad..cc3bc3fb7bcbc487d2216b153b90c65628a3a7ce 100644 --- a/libstdc++-v3/include/debug/unordered_map +++ b/libstdc++-v3/include/debug/unordered_map @@ -185,7 +185,7 @@ namespace __debug void swap(unordered_map& __x) - noexcept( noexcept(declval<_Base>().swap(__x)) ) + noexcept( noexcept(declval<_Base&>().swap(__x)) ) { _Safe::_M_swap(__x); _Base::swap(__x); @@ -486,6 +486,7 @@ namespace __debug inline void swap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) + noexcept(noexcept(__x.swap(__y))) { __x.swap(__y); } template<typename _Key, typename _Tp, typename _Hash, @@ -641,7 +642,7 @@ namespace __debug void swap(unordered_multimap& __x) - noexcept( noexcept(declval<_Base>().swap(__x)) ) + noexcept( noexcept(declval<_Base&>().swap(__x)) ) { _Safe::_M_swap(__x); _Base::swap(__x); @@ -938,6 +939,7 @@ namespace __debug inline void swap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) + noexcept(noexcept(__x.swap(__y))) { __x.swap(__y); } template<typename _Key, typename _Tp, typename _Hash, diff --git a/libstdc++-v3/include/debug/unordered_set b/libstdc++-v3/include/debug/unordered_set index 1e6846140ab3db826df1615daf52d6cca8f35209..a45d3b54d387f8aa2e02d40e1dd386e0326a8951 100644 --- a/libstdc++-v3/include/debug/unordered_set +++ b/libstdc++-v3/include/debug/unordered_set @@ -182,7 +182,7 @@ namespace __debug void swap(unordered_set& __x) - noexcept( noexcept(declval<_Base>().swap(__x)) ) + noexcept( noexcept(declval<_Base&>().swap(__x)) ) { _Safe::_M_swap(__x); _Base::swap(__x); @@ -480,6 +480,7 @@ namespace __debug inline void swap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x, unordered_set<_Value, _Hash, _Pred, _Alloc>& __y) + noexcept(noexcept(__x.swap(__y))) { __x.swap(__y); } template<typename _Value, typename _Hash, typename _Pred, typename _Alloc> @@ -634,7 +635,7 @@ namespace __debug void swap(unordered_multiset& __x) - noexcept( noexcept(declval<_Base>().swap(__x)) ) + noexcept( noexcept(declval<_Base&>().swap(__x)) ) { _Safe::_M_swap(__x); _Base::swap(__x); @@ -920,6 +921,7 @@ namespace __debug inline void swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x, unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y) + noexcept(noexcept(__x.swap(__y))) { __x.swap(__y); } template<typename _Value, typename _Hash, typename _Pred, typename _Alloc> diff --git a/libstdc++-v3/include/debug/vector b/libstdc++-v3/include/debug/vector index 310009756c0bf696344630ffd1a11fdb51186b8d..fede4f0917cc2eb54905d82165b6d117061b9163 100644 --- a/libstdc++-v3/include/debug/vector +++ b/libstdc++-v3/include/debug/vector @@ -674,9 +674,7 @@ namespace __debug void swap(vector& __x) -#if __cplusplus >= 201103L - noexcept( noexcept(declval<_Base>().swap(__x)) ) -#endif + _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) ) { _Safe::_M_swap(__x); _Base::swap(__x); @@ -744,6 +742,7 @@ namespace __debug template<typename _Tp, typename _Alloc> inline void swap(vector<_Tp, _Alloc>& __lhs, vector<_Tp, _Alloc>& __rhs) + _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs))) { __lhs.swap(__rhs); } } // namespace __debug diff --git a/libstdc++-v3/include/ext/alloc_traits.h b/libstdc++-v3/include/ext/alloc_traits.h index 5da32c5b0ecbbe046401f86df1c3f531322bbc0d..4d322fb6b9d439628f4985db27c259e184e40303 100644 --- a/libstdc++-v3/include/ext/alloc_traits.h +++ b/libstdc++-v3/include/ext/alloc_traits.h @@ -112,12 +112,6 @@ template<typename _Alloc> static constexpr bool _S_nothrow_move() { return _S_propagate_on_move_assign() || _S_always_equal(); } - static constexpr bool _S_nothrow_swap() - { - return !_S_propagate_on_swap() - || std::__is_nothrow_swappable<_Alloc>::value; - } - template<typename _Tp> struct rebind { typedef typename _Base_type::template rebind_alloc<_Tp> other; }; diff --git a/libstdc++-v3/include/profile/deque b/libstdc++-v3/include/profile/deque index c0c6db2bb124113df352701800e217639acfe0c2..724bc43b5f466fe93ead83c367eb3bb761227474 100644 --- a/libstdc++-v3/include/profile/deque +++ b/libstdc++-v3/include/profile/deque @@ -130,9 +130,7 @@ namespace __profile void swap(deque& __x) -#if __cplusplus >= 201103L - noexcept( noexcept(declval<_Base>().swap(__x)) ) -#endif + _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) ) { _Base::swap(__x); } _Base& @@ -181,6 +179,7 @@ namespace __profile template<typename _Tp, typename _Alloc> inline void swap(deque<_Tp, _Alloc>& __lhs, deque<_Tp, _Alloc>& __rhs) + _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs))) { __lhs.swap(__rhs); } } // namespace __profile diff --git a/libstdc++-v3/include/profile/forward_list b/libstdc++-v3/include/profile/forward_list index ab7ed04b75a5e1ed068f0d4de5eda8c1af4ea9b2..081b202982cf651b2afc8e0951cef61d8bc116f8 100644 --- a/libstdc++-v3/include/profile/forward_list +++ b/libstdc++-v3/include/profile/forward_list @@ -108,7 +108,7 @@ namespace __profile void swap(forward_list& __fl) - noexcept( noexcept(declval<_Base>().swap(__fl)) ) + noexcept( noexcept(declval<_Base&>().swap(__fl)) ) { _Base::swap(__fl); } void @@ -208,6 +208,7 @@ namespace __profile inline void swap(forward_list<_Tp, _Alloc>& __lx, forward_list<_Tp, _Alloc>& __ly) + noexcept(noexcept(__lx.swap(__ly))) { __lx.swap(__ly); } } // namespace __profile diff --git a/libstdc++-v3/include/profile/list b/libstdc++-v3/include/profile/list index b5943ee6dfc5dc025b448d2bcd0cc88380f3b9ca..edc321e8302c19f54a0a454b772479b815c93731 100644 --- a/libstdc++-v3/include/profile/list +++ b/libstdc++-v3/include/profile/list @@ -411,9 +411,7 @@ namespace __profile void swap(list& __x) -#if __cplusplus >= 201103L - noexcept( noexcept(declval<_Base>().swap(__x)) ) -#endif + _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) ) { _Base::swap(__x); this->_M_swap(__x); @@ -643,6 +641,7 @@ namespace __profile template<typename _Tp, typename _Alloc> inline void swap(list<_Tp, _Alloc>& __lhs, list<_Tp, _Alloc>& __rhs) + _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs))) { __lhs.swap(__rhs); } } // namespace __profile diff --git a/libstdc++-v3/include/profile/map.h b/libstdc++-v3/include/profile/map.h index 210b9b478c64b70433f044ba98bc98c298c9434d..8a19592386c8c948ffce735872b082fffe86586e 100644 --- a/libstdc++-v3/include/profile/map.h +++ b/libstdc++-v3/include/profile/map.h @@ -405,9 +405,7 @@ namespace __profile void swap(map& __x) -#if __cplusplus >= 201103L - noexcept( noexcept(declval<_Base>().swap(__x)) ) -#endif + _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) ) { _Base::swap(__x); this->_M_swap(__x); @@ -698,6 +696,7 @@ namespace __profile inline void swap(map<_Key, _Tp, _Compare, _Allocator>& __lhs, map<_Key, _Tp, _Compare, _Allocator>& __rhs) + _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs))) { __lhs.swap(__rhs); } } // namespace __profile diff --git a/libstdc++-v3/include/profile/multimap.h b/libstdc++-v3/include/profile/multimap.h index 4ec77d79ac6bbc38cfa1dc2ca8ad72273cd20173..1055e9e9dd7e2640ef0e8661ef6b19aba0d34da4 100644 --- a/libstdc++-v3/include/profile/multimap.h +++ b/libstdc++-v3/include/profile/multimap.h @@ -364,9 +364,7 @@ namespace __profile void swap(multimap& __x) -#if __cplusplus >= 201103L - noexcept( noexcept(declval<_Base>().swap(__x)) ) -#endif + _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) ) { std::swap(this->_M_map2umap_info, __x._M_map2umap_info); _Base::swap(__x); @@ -656,6 +654,7 @@ namespace __profile inline void swap(multimap<_Key, _Tp, _Compare, _Allocator>& __lhs, multimap<_Key, _Tp, _Compare, _Allocator>& __rhs) + _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs))) { __lhs.swap(__rhs); } } // namespace __profile diff --git a/libstdc++-v3/include/profile/multiset.h b/libstdc++-v3/include/profile/multiset.h index b304e5c5194ed4c563284f8a882e8a4bf09f67de..55090e3936cf177841bbe63857c12bafba401255 100644 --- a/libstdc++-v3/include/profile/multiset.h +++ b/libstdc++-v3/include/profile/multiset.h @@ -226,9 +226,7 @@ namespace __profile void swap(multiset& __x) -#if __cplusplus >= 201103L - noexcept( noexcept(declval<_Base>().swap(__x)) ) -#endif + _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) ) { _Base::swap(__x); this->_M_swap(__x); @@ -640,6 +638,7 @@ namespace __profile void swap(multiset<_Key, _Compare, _Allocator>& __x, multiset<_Key, _Compare, _Allocator>& __y) + _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y))) { return __x.swap(__y); } } // namespace __profile diff --git a/libstdc++-v3/include/profile/set.h b/libstdc++-v3/include/profile/set.h index 3717fde5261038693305c78951227692ef5ddb5f..24d2ed55a5903dd3fd6542d500caecc7cef7c416 100644 --- a/libstdc++-v3/include/profile/set.h +++ b/libstdc++-v3/include/profile/set.h @@ -223,9 +223,7 @@ namespace __profile void swap(set& __x) -#if __cplusplus >= 201103L - noexcept( noexcept(declval<_Base>().swap(__x)) ) -#endif + _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) ) { _Base::swap(__x); this->_M_swap(__x); @@ -621,6 +619,7 @@ namespace __profile void swap(set<_Key, _Compare, _Allocator>& __x, set<_Key, _Compare, _Allocator>& __y) + _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y))) { return __x.swap(__y); } } // namespace __profile diff --git a/libstdc++-v3/include/profile/unordered_map b/libstdc++-v3/include/profile/unordered_map index 480fabad172671ee14416e64755940374f0b3762..619486e7394003ad3c9e71a714b87cdfbc3d3bf1 100644 --- a/libstdc++-v3/include/profile/unordered_map +++ b/libstdc++-v3/include/profile/unordered_map @@ -299,6 +299,7 @@ namespace __profile inline void swap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) + noexcept(noexcept(__x.swap(__y))) { __x.swap(__y); } template<typename _Key, typename _Tp, typename _Hash, @@ -557,6 +558,7 @@ namespace __profile inline void swap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) + noexcept(noexcept(__x.swap(__y))) { __x.swap(__y); } template<typename _Key, typename _Tp, typename _Hash, diff --git a/libstdc++-v3/include/profile/unordered_set b/libstdc++-v3/include/profile/unordered_set index 15950b9f4715a3727e56fe63c685fff9e85ee46d..4c2a7ff19679c199e1e536bd2c84f95d2eaa5431 100644 --- a/libstdc++-v3/include/profile/unordered_set +++ b/libstdc++-v3/include/profile/unordered_set @@ -279,6 +279,7 @@ namespace __profile inline void swap(unordered_set<_Key, _Hash, _Pred, _Alloc>& __x, unordered_set<_Key, _Hash, _Pred, _Alloc>& __y) + noexcept(noexcept(__x.swap(__y))) { __x.swap(__y); } template<typename _Key, typename _Hash, typename _Pred, typename _Alloc> @@ -534,6 +535,7 @@ namespace __profile inline void swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x, unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y) + noexcept(noexcept(__x.swap(__y))) { __x.swap(__y); } template<typename _Value, typename _Hash, typename _Pred, typename _Alloc> diff --git a/libstdc++-v3/include/profile/vector b/libstdc++-v3/include/profile/vector index fdc73ef582a9724ed4f23e168ba000c216d0184a..dc015f2f2a9335fe2db7f1e759100ae5dec0e600 100644 --- a/libstdc++-v3/include/profile/vector +++ b/libstdc++-v3/include/profile/vector @@ -547,20 +547,9 @@ namespace __profile template<typename _Tp, typename _Alloc> inline void swap(vector<_Tp, _Alloc>& __lhs, vector<_Tp, _Alloc>& __rhs) + _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs))) { __lhs.swap(__rhs); } -#if __cplusplus >= 201103L - template<typename _Tp, typename _Alloc> - inline void - swap(vector<_Tp, _Alloc>&& __lhs, vector<_Tp, _Alloc>& __rhs) - { __lhs.swap(__rhs); } - - template<typename _Tp, typename _Alloc> - inline void - swap(vector<_Tp, _Alloc>& __lhs, vector<_Tp, _Alloc>&& __rhs) - { __lhs.swap(__rhs); } -#endif - } // namespace __profile #if __cplusplus >= 201103L diff --git a/libstdc++-v3/testsuite/23_containers/deque/allocator/noexcept.cc b/libstdc++-v3/testsuite/23_containers/deque/allocator/noexcept.cc index bf4b7de40bb7a2fc0d56d061575f2edf07895d8c..c6f82666a901b6082a34ecc5ecdb3eb22d3cf90a 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/allocator/noexcept.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/allocator/noexcept.cc @@ -23,15 +23,6 @@ struct T { int i; }; -namespace __gnu_test -{ - template<typename U> - inline void - swap(propagating_allocator<U, true>& l, propagating_allocator<U, true>& r) - noexcept(false) - { } -} - using __gnu_test::propagating_allocator; void test01() @@ -62,6 +53,5 @@ void test03() test_type v1(alloc_type(1)); test_type v2(alloc_type(2)); // static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); - // noexcept spec of deque::swap depends on swap overload at top of this file - static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); + static_assert( noexcept( v1.swap(v2) ), "Swap cannot throw" ); } diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/allocator/noexcept.cc b/libstdc++-v3/testsuite/23_containers/forward_list/allocator/noexcept.cc index 9b096c949720f0ce57d17958a2ba4b52018c254d..51af42d2c3dbd79162a3ab947ee9528713fab37d 100644 --- a/libstdc++-v3/testsuite/23_containers/forward_list/allocator/noexcept.cc +++ b/libstdc++-v3/testsuite/23_containers/forward_list/allocator/noexcept.cc @@ -23,15 +23,6 @@ struct T { int i; }; -namespace __gnu_test -{ - template<typename U> - inline void - swap(propagating_allocator<U, true>& l, propagating_allocator<U, true>& r) - noexcept(false) - { } -} - using __gnu_test::propagating_allocator; void test01() @@ -62,5 +53,5 @@ void test03() test_type v1(alloc_type(1)); test_type v2(alloc_type(2)); static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); - static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); + static_assert( noexcept( v1.swap(v2) ), "Swap cannot throw" ); } diff --git a/libstdc++-v3/testsuite/23_containers/list/allocator/noexcept.cc b/libstdc++-v3/testsuite/23_containers/list/allocator/noexcept.cc index 4a84fceb5408be6ea58dc8c688cc6c05485920b5..bc80d37941e78e5da17a6982ba4ae028fe303bd6 100644 --- a/libstdc++-v3/testsuite/23_containers/list/allocator/noexcept.cc +++ b/libstdc++-v3/testsuite/23_containers/list/allocator/noexcept.cc @@ -23,15 +23,6 @@ struct T { int i; }; -namespace __gnu_test -{ - template<typename U> - inline void - swap(propagating_allocator<U, true>& l, propagating_allocator<U, true>& r) - noexcept(false) - { } -} - using __gnu_test::propagating_allocator; void test01() @@ -62,5 +53,5 @@ void test03() test_type v1(alloc_type(1)); test_type v2(alloc_type(2)); static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); - static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); + static_assert( noexcept( v1.swap(v2) ), "Swap cannot throw" ); } diff --git a/libstdc++-v3/testsuite/23_containers/map/allocator/noexcept.cc b/libstdc++-v3/testsuite/23_containers/map/allocator/noexcept.cc index 44119cc4d4bf0fea179d6048418c7a3e9a5c9e19..47a8a144b9f4c64d9d605ff23b7ccf30730cc4d1 100644 --- a/libstdc++-v3/testsuite/23_containers/map/allocator/noexcept.cc +++ b/libstdc++-v3/testsuite/23_containers/map/allocator/noexcept.cc @@ -27,16 +27,10 @@ bool operator<(T l, T r) { return l.i < r.i; } using Cmp = std::less<T>; -struct U { }; +struct CmpThrow : Cmp { }; +void swap(CmpThrow&, CmpThrow&) noexcept(false) { } -namespace __gnu_test -{ - template<typename U> - inline void - swap(propagating_allocator<U, true>& l, propagating_allocator<U, true>& r) - noexcept(false) - { } -} +struct U { }; using __gnu_test::propagating_allocator; @@ -52,6 +46,16 @@ void test01() } void test02() +{ + typedef std::allocator<std::pair<const T, U>> alloc_type; + typedef std::map<T, U, CmpThrow, alloc_type> test_type; + test_type v1; + test_type v2; + static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); + static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); +} + +void test03() { typedef propagating_allocator<std::pair<const T, U>, false> alloc_type; typedef std::map<T, U, Cmp, alloc_type> test_type; @@ -61,12 +65,12 @@ void test02() static_assert( noexcept( v1.swap(v2) ), "Swap cannot throw" ); } -void test03() +void test04() { typedef propagating_allocator<std::pair<const T, U>, true> alloc_type; typedef std::map<T, U, Cmp, alloc_type> test_type; test_type v1(alloc_type(1)); test_type v2(alloc_type(2)); static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); - static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); + static_assert( noexcept( v1.swap(v2) ), "Swap cannot throw" ); } diff --git a/libstdc++-v3/testsuite/23_containers/multimap/allocator/noexcept.cc b/libstdc++-v3/testsuite/23_containers/multimap/allocator/noexcept.cc index eb1c27b2d8c0a683012d4314d773a2e6b3ebad10..2f27fd76170978bf5e0f0ed36f80915e42ce18c9 100644 --- a/libstdc++-v3/testsuite/23_containers/multimap/allocator/noexcept.cc +++ b/libstdc++-v3/testsuite/23_containers/multimap/allocator/noexcept.cc @@ -27,16 +27,10 @@ bool operator<(T l, T r) { return l.i < r.i; } using Cmp = std::less<T>; -struct U { }; +struct CmpThrow : Cmp { }; +void swap(CmpThrow&, CmpThrow&) noexcept(false) { } -namespace __gnu_test -{ - template<typename U> - inline void - swap(propagating_allocator<U, true>& l, propagating_allocator<U, true>& r) - noexcept(false) - { } -} +struct U { }; using __gnu_test::propagating_allocator; @@ -53,20 +47,20 @@ void test01() void test02() { - typedef propagating_allocator<std::pair<const T, U>, false> alloc_type; - typedef std::multimap<T, U, Cmp, alloc_type> test_type; - test_type v1(alloc_type(1)); - test_type v2(alloc_type(2)); - static_assert( !noexcept( v1 = std::move(v2) ), "Move assign can throw" ); - static_assert( noexcept( v1.swap(v2) ), "Swap cannot throw" ); + typedef std::allocator<std::pair<const T, U>> alloc_type; + typedef std::multimap<T, U, CmpThrow, alloc_type> test_type; + test_type v1; + test_type v2; + static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); + static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); } void test03() { - typedef propagating_allocator<std::pair<const T, U>, true> alloc_type; + typedef propagating_allocator<std::pair<const T, U>, false> alloc_type; typedef std::multimap<T, U, Cmp, alloc_type> test_type; test_type v1(alloc_type(1)); test_type v2(alloc_type(2)); - static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); - static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); + static_assert( !noexcept( v1 = std::move(v2) ), "Move assign can throw" ); + static_assert( noexcept( v1.swap(v2) ), "Swap cannot throw" ); } diff --git a/libstdc++-v3/testsuite/23_containers/multiset/allocator/noexcept.cc b/libstdc++-v3/testsuite/23_containers/multiset/allocator/noexcept.cc index 5d50601edc175e8ba94de66d88b9ed0e1e22744f..665a8d2950ed023dda4e78c26a1f7f127e1f4244 100644 --- a/libstdc++-v3/testsuite/23_containers/multiset/allocator/noexcept.cc +++ b/libstdc++-v3/testsuite/23_containers/multiset/allocator/noexcept.cc @@ -28,14 +28,8 @@ bool operator<(T l, T r) { return l.i < r.i; } using Cmp = std::less<T>; -namespace __gnu_test -{ - template<typename U> - inline void - swap(propagating_allocator<U, true>& l, propagating_allocator<U, true>& r) - noexcept(false) - { } -} +struct CmpThrow : Cmp { }; +void swap(CmpThrow&, CmpThrow&) noexcept(false) { } using __gnu_test::propagating_allocator; @@ -51,6 +45,16 @@ void test01() } void test02() +{ + typedef std::allocator<T> alloc_type; + typedef std::multiset<T, CmpThrow, alloc_type> test_type; + test_type v1; + test_type v2; + static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); + static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); +} + +void test03() { typedef propagating_allocator<T, false> alloc_type; typedef std::multiset<T, Cmp, alloc_type> test_type; @@ -60,12 +64,12 @@ void test02() static_assert( noexcept( v1.swap(v2) ), "Swap cannot throw" ); } -void test03() +void test04() { typedef propagating_allocator<T, true> alloc_type; typedef std::multiset<T, Cmp, alloc_type> test_type; test_type v1(alloc_type(1)); test_type v2(alloc_type(2)); static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); - static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); + static_assert( noexcept( v1.swap(v2) ), "Swap cannot throw" ); } diff --git a/libstdc++-v3/testsuite/23_containers/set/allocator/noexcept.cc b/libstdc++-v3/testsuite/23_containers/set/allocator/noexcept.cc index 2645eddef39d33b5206dd647db6cf20ebd4488b1..325264580367484cd05f9c995612c8ee23df3d06 100644 --- a/libstdc++-v3/testsuite/23_containers/set/allocator/noexcept.cc +++ b/libstdc++-v3/testsuite/23_containers/set/allocator/noexcept.cc @@ -27,14 +27,8 @@ bool operator<(T l, T r) { return l.i < r.i; } using Cmp = std::less<T>; -namespace __gnu_test -{ - template<typename U> - inline void - swap(propagating_allocator<U, true>& l, propagating_allocator<U, true>& r) - noexcept(false) - { } -} +struct CmpThrow : Cmp { }; +void swap(CmpThrow&, CmpThrow&) noexcept(false) { } using __gnu_test::propagating_allocator; @@ -50,6 +44,16 @@ void test01() } void test02() +{ + typedef std::allocator<T> alloc_type; + typedef std::set<T, CmpThrow, alloc_type> test_type; + test_type v1; + test_type v2; + static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); + static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); +} + +void test03() { typedef propagating_allocator<T, false> alloc_type; typedef std::set<T, Cmp, alloc_type> test_type; @@ -59,12 +63,12 @@ void test02() static_assert( noexcept( v1.swap(v2) ), "Swap cannot throw" ); } -void test03() +void test04() { typedef propagating_allocator<T, true> alloc_type; typedef std::set<T, Cmp, alloc_type> test_type; test_type v1(alloc_type(1)); test_type v2(alloc_type(2)); static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); - static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); + static_assert( noexcept( v1.swap(v2) ), "Swap cannot throw" ); } diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/allocator/noexcept.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/allocator/noexcept.cc index 621e02e9bd6b0be5fb15ccc97116ca12602145f8..dca473d2c7cdfcc0caeb61adbfa6e647da146b42 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_map/allocator/noexcept.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_map/allocator/noexcept.cc @@ -35,14 +35,11 @@ struct equal_to { return lhs.i == rhs.i; } }; -namespace __gnu_test -{ - template<typename U> - inline void - swap(propagating_allocator<U, true>& l, propagating_allocator<U, true>& r) - noexcept(false) - { } -} +// Versions of the function objects without nothrow swap. +struct hash_t : hash { }; +void swap(hash_t&, hash_t&) noexcept(false) { } +struct equal_to_t : equal_to { }; +void swap(equal_to_t&, equal_to_t&) noexcept(false) { } using __gnu_test::propagating_allocator; @@ -58,6 +55,26 @@ void test01() } void test02() +{ + typedef std::allocator<T> alloc_type; + typedef std::unordered_map<T, T, hash_t, equal_to, alloc_type> test_type; + test_type v1; + test_type v2; + static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); + static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); +} + +void test03() +{ + typedef std::allocator<T> alloc_type; + typedef std::unordered_map<T, T, hash, equal_to_t, alloc_type> test_type; + test_type v1; + test_type v2; + static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); + static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); +} + +void test04() { typedef propagating_allocator<T, false> alloc_type; typedef std::unordered_map<T, T, hash, equal_to, alloc_type> test_type; @@ -67,19 +84,19 @@ void test02() static_assert( noexcept( v1.swap(v2) ), "Swap cannot throw" ); } -void test03() +void test05() { typedef propagating_allocator<T, true> alloc_type; typedef std::unordered_map<T, T, hash, equal_to, alloc_type> test_type; test_type v1(alloc_type(1)); test_type v2(alloc_type(2)); static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); - static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); + static_assert( noexcept( v1.swap(v2) ), "Swap cannot throw" ); } -void test04() +void test06() { typedef std::unordered_map<int, int> test_type; - static_assert( noexcept( test_type() ), "Default constructor do not throw" ); - static_assert( noexcept( test_type(test_type()) ), "Move constructor do not throw" ); + static_assert( noexcept( test_type() ), "Default constructor does not throw" ); + static_assert( noexcept( test_type(test_type()) ), "Move constructor does not throw" ); } diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/allocator/noexcept.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/allocator/noexcept.cc index a3b3c81d2a5a9e6ee06238ed14abfd7335046825..3c67d238be121ea52170d8c9417d2971094b8fc2 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multimap/allocator/noexcept.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/allocator/noexcept.cc @@ -35,14 +35,11 @@ struct equal_to { return lhs.i == rhs.i; } }; -namespace __gnu_test -{ - template<typename U> - inline void - swap(propagating_allocator<U, true>& l, propagating_allocator<U, true>& r) - noexcept(false) - { } -} +// Versions of the function objects without nothrow swap. +struct hash_t : hash { }; +void swap(hash_t&, hash_t&) noexcept(false) { } +struct equal_to_t : equal_to { }; +void swap(equal_to_t&, equal_to_t&) noexcept(false) { } using __gnu_test::propagating_allocator; @@ -58,6 +55,27 @@ void test01() } void test02() +{ + typedef std::allocator<T> alloc_type; + typedef std::unordered_multimap<T, T, hash_t, equal_to, alloc_type> test_type; + test_type v1; + test_type v2; + static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); + static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); +} + +void test03() +{ + typedef std::allocator<T> alloc_type; + typedef std::unordered_multimap<T, T, hash, equal_to_t, alloc_type> + test_type; + test_type v1; + test_type v2; + static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); + static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); +} + +void test04() { typedef propagating_allocator<T, false> alloc_type; typedef std::unordered_multimap<T, T, hash, equal_to, alloc_type> test_type; @@ -67,19 +85,19 @@ void test02() static_assert( noexcept( v1.swap(v2) ), "Swap cannot throw" ); } -void test03() +void test05() { typedef propagating_allocator<T, true> alloc_type; typedef std::unordered_multimap<T, T, hash, equal_to, alloc_type> test_type; test_type v1(alloc_type(1)); test_type v2(alloc_type(2)); static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); - static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); + static_assert( noexcept( v1.swap(v2) ), "Swap cannot throw" ); } -void test04() +void test06() { typedef std::unordered_multimap<int, int> test_type; - static_assert( noexcept( test_type() ), "Default constructor do not throw" ); - static_assert( noexcept( test_type(test_type()) ), "Move constructor do not throw" ); + static_assert( noexcept( test_type() ), "Default constructor does not throw" ); + static_assert( noexcept( test_type(test_type()) ), "Move constructor does not throw" ); } diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/allocator/noexcept.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/allocator/noexcept.cc index 1152ab9d7280d7d015ae71a038c3ca39e8d3915d..37c3eb15abd72f8b38e5edd979d5c92976c94071 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multiset/allocator/noexcept.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multiset/allocator/noexcept.cc @@ -35,14 +35,11 @@ struct equal_to { return lhs.i == rhs.i; } }; -namespace __gnu_test -{ - template<typename U> - inline void - swap(propagating_allocator<U, true>& l, propagating_allocator<U, true>& r) - noexcept(false) - { } -} +// Versions of the function objects without nothrow swap. +struct hash_t : hash { }; +void swap(hash_t&, hash_t&) noexcept(false) { } +struct equal_to_t : equal_to { }; +void swap(equal_to_t&, equal_to_t&) noexcept(false) { } using __gnu_test::propagating_allocator; @@ -58,6 +55,26 @@ void test01() } void test02() +{ + typedef std::allocator<T> alloc_type; + typedef std::unordered_multiset<T, hash_t, equal_to, alloc_type> test_type; + test_type v1; + test_type v2; + static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); + static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); +} + +void test03() +{ + typedef std::allocator<T> alloc_type; + typedef std::unordered_multiset<T, hash, equal_to_t, alloc_type> test_type; + test_type v1; + test_type v2; + static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); + static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); +} + +void test04() { typedef propagating_allocator<T, false> alloc_type; typedef std::unordered_multiset<T, hash, equal_to, alloc_type> test_type; @@ -67,19 +84,19 @@ void test02() static_assert( noexcept( v1.swap(v2) ), "Swap cannot throw" ); } -void test03() +void test05() { typedef propagating_allocator<T, true> alloc_type; typedef std::unordered_multiset<T, hash, equal_to, alloc_type> test_type; test_type v1(alloc_type(1)); test_type v2(alloc_type(2)); static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); - static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); + static_assert( noexcept( v1.swap(v2) ), "Swap cannot throw" ); } -void test04() +void test06() { typedef std::unordered_multiset<int> test_type; - static_assert( noexcept( test_type() ), "Default constructor do not throw" ); - static_assert( noexcept( test_type(test_type()) ), "Move constructor do not throw" ); + static_assert( noexcept( test_type() ), "Default constructor does not throw" ); + static_assert( noexcept( test_type(test_type()) ), "Move constructor does not throw" ); } diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/noexcept.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/noexcept.cc index b9f5d52dfda6c2c9481bb984ae25f9f1fb71ccf7..a844c35716eb14637ebf66efa8eef4f7c1c12c91 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/noexcept.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/noexcept.cc @@ -35,14 +35,11 @@ struct equal_to { return lhs.i == rhs.i; } }; -namespace __gnu_test -{ - template<typename U> - inline void - swap(propagating_allocator<U, true>& l, propagating_allocator<U, true>& r) - noexcept(false) - { } -} +// Versions of the function objects without nothrow swap. +struct hash_t : hash { }; +void swap(hash_t&, hash_t&) noexcept(false) { } +struct equal_to_t : equal_to { }; +void swap(equal_to_t&, equal_to_t&) noexcept(false) { } using __gnu_test::propagating_allocator; @@ -58,6 +55,26 @@ void test01() } void test02() +{ + typedef std::allocator<T> alloc_type; + typedef std::unordered_set<T, hash_t, equal_to, alloc_type> test_type; + test_type v1; + test_type v2; + static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); + static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); +} + +void test03() +{ + typedef std::allocator<T> alloc_type; + typedef std::unordered_set<T, hash, equal_to_t, alloc_type> test_type; + test_type v1; + test_type v2; + static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); + static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); +} + +void test04() { typedef propagating_allocator<T, false> alloc_type; typedef std::unordered_set<T, hash, equal_to, alloc_type> test_type; @@ -67,19 +84,19 @@ void test02() static_assert( noexcept( v1.swap(v2) ), "Swap cannot throw" ); } -void test03() +void test05() { typedef propagating_allocator<T, true> alloc_type; typedef std::unordered_set<T, hash, equal_to, alloc_type> test_type; test_type v1(alloc_type(1)); test_type v2(alloc_type(2)); static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); - static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); + static_assert( noexcept( v1.swap(v2) ), "Swap cannot throw" ); } -void test04() +void test06() { typedef std::unordered_set<int> test_type; - static_assert( noexcept( test_type() ), "Default constructor do not throw" ); - static_assert( noexcept( test_type(test_type()) ), "Move constructor do not throw" ); + static_assert( noexcept( test_type() ), "Default constructor does not throw" ); + static_assert( noexcept( test_type(test_type()) ), "Move constructor does not throw" ); } diff --git a/libstdc++-v3/testsuite/23_containers/vector/allocator/noexcept.cc b/libstdc++-v3/testsuite/23_containers/vector/allocator/noexcept.cc index 38f69d61e78e969ff14dd41f5338425d28c1cb43..0cb120576ff6106852037265500bbfddfc6358e1 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/allocator/noexcept.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/allocator/noexcept.cc @@ -23,15 +23,6 @@ struct T { int i; }; -namespace __gnu_test -{ - template<typename U> - inline void - swap(propagating_allocator<U, true>& l, propagating_allocator<U, true>& r) - noexcept(false) - { } -} - using __gnu_test::propagating_allocator; void test01() @@ -62,5 +53,5 @@ void test03() test_type v1(alloc_type(1)); test_type v2(alloc_type(2)); static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); - static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); + static_assert( noexcept( v1.swap(v2) ), "Swap cannot throw" ); } diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/allocator/noexcept.cc b/libstdc++-v3/testsuite/23_containers/vector/bool/allocator/noexcept.cc index 250362d63e9ce77757bac57c511896ca63eb6e83..1e2b9547f65280de4ef2bcb094100bc649336fe7 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/bool/allocator/noexcept.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/bool/allocator/noexcept.cc @@ -23,15 +23,6 @@ using T = bool; -namespace __gnu_test -{ - template<typename U> - inline void - swap(propagating_allocator<U, true>& l, propagating_allocator<U, true>& r) - noexcept(false) - { } -} - using __gnu_test::propagating_allocator; void test01() @@ -62,5 +53,5 @@ void test03() test_type v1(alloc_type(1)); test_type v2(alloc_type(2)); static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); - static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); + static_assert( noexcept( v1.swap(v2) ), "Swap cannot throw" ); } diff --git a/libstdc++-v3/testsuite/ext/profile/mutex_extensions_neg.cc b/libstdc++-v3/testsuite/ext/profile/mutex_extensions_neg.cc index 78365e74cca4670b005cbb59ca3834391d4b91c7..8ed54ea291b4543c2262ef365626366485852d92 100644 --- a/libstdc++-v3/testsuite/ext/profile/mutex_extensions_neg.cc +++ b/libstdc++-v3/testsuite/ext/profile/mutex_extensions_neg.cc @@ -25,7 +25,7 @@ #include <vector> -// { dg-error "multiple inlined namespaces" "" { target *-*-* } 322 } +// { dg-error "multiple inlined namespaces" "" { target *-*-* } 324 } // "template argument 1 is invalid" // { dg-prune-output "tuple:993" }