STL_MSFT created this revision. STL_MSFT added reviewers: EricWF, mclow.lists. STL_MSFT added a subscriber: cfe-commits.
Make swap_noexcept.pass.cpp tests more portable. These tests define types like some_alloc, which dramatically fail to meet the allocator requirements. They don't even have allocate() member functions. Then, they actually default-construct containers with these not-allocators. MSVC's STL can't tolerate this, because we need to dynamically allocate sentinel nodes and debugging machinery. A true fix would involve centralizing these allocators, allowing POCS/is_always_equal/etc. to be customized as desired, while actually providing conformant allocators. But in the meantime, I have incremental improvements. The bulk of these changes involves including <utility> for declval(), then replacing C c1, c2; static_assert(noexcept(swap(c1, c2)), ""); with static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); This avoids instantiating the containers' default constructors. The other part of these changes involves replacing static_assert with LIBCPP_STATIC_ASSERT for certain things that aren't guaranteed by the Standard. (We're already including "test_macros.h" explicitly.) test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp test/std/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp test/std/containers/associative/multiset/multiset.special/swap_noexcept.pass.cpp test/std/containers/associative/set/set.special/swap_noexcept.pass.cpp For the ordered associative containers, the Working Paper inspects is_always_equal && is_nothrow_swappable_v<Compare>. The updated lines are using std::less or some_comp2, which are nothrow-swappable, so that's okay. However, they're using test_allocator (stateful), other_allocator (stateful), or some_alloc3 (with is_always_equal being false_type). Therefore, these assertions aren't guaranteed by the WP. BONUS CHANGE: In multimap.special/swap_noexcept.pass.cpp, there was one occurrence of std::map that's being changed to std::multimap. test/std/containers/unord/unord.map/unord.map.swap/swap_noexcept.pass.cpp test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_noexcept.pass.cpp test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_noexcept.pass.cpp test/std/containers/unord/unord.set/unord.set.swap/swap_noexcept.pass.cpp Same for the unordered associative containers. They inspect is_always_equal && is_nothrow_swappable_v<Hash> && is_nothrow_swappable_v<Pred>. std::hash/std::equal_to and some_hash2/some_comp2 are nothrow-swappable, but test_allocator/other_allocator/some_alloc3 aren't always-equal. test/std/containers/sequences/deque/deque.special/swap_noexcept.pass.cpp test/std/containers/sequences/forwardlist/forwardlist.spec/swap_noexcept.pass.cpp test/std/containers/sequences/list/list.special/swap_noexcept.pass.cpp For these sequences, the WP inspects is_always_equal. test_allocator/other_allocator aren't always-equal. test/std/containers/sequences/vector/vector.special/swap_noexcept.pass.cpp test/std/strings/basic.string/string.nonmembers/string.special/swap_noexcept.pass.cpp For vector and basic_string, the WP inspects POCS || is_always_equal. test_allocator is stateful and doesn't set POCS, which defaults to false. test/std/containers/container.adaptors/priority.queue/priqueue.special/swap_noexcept.pass.cpp test/std/containers/container.adaptors/queue/queue.special/swap_noexcept.pass.cpp test/std/containers/container.adaptors/stack/stack.special/swap_noexcept.pass.cpp No LIBCPP_STATIC_ASSERT changes, just declval. test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp vector<bool>::swap() is depicted without noexcept in the WP. http://reviews.llvm.org/D21820 Files: test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp test/std/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp test/std/containers/associative/multiset/multiset.special/swap_noexcept.pass.cpp test/std/containers/associative/set/set.special/swap_noexcept.pass.cpp test/std/containers/container.adaptors/priority.queue/priqueue.special/swap_noexcept.pass.cpp test/std/containers/container.adaptors/queue/queue.special/swap_noexcept.pass.cpp test/std/containers/container.adaptors/stack/stack.special/swap_noexcept.pass.cpp test/std/containers/sequences/deque/deque.special/swap_noexcept.pass.cpp test/std/containers/sequences/forwardlist/forwardlist.spec/swap_noexcept.pass.cpp test/std/containers/sequences/list/list.special/swap_noexcept.pass.cpp test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp test/std/containers/sequences/vector/vector.special/swap_noexcept.pass.cpp test/std/containers/unord/unord.map/unord.map.swap/swap_noexcept.pass.cpp test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_noexcept.pass.cpp test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_noexcept.pass.cpp test/std/containers/unord/unord.set/unord.set.swap/swap_noexcept.pass.cpp test/std/strings/basic.string/string.nonmembers/string.special/swap_noexcept.pass.cpp
Index: test/std/strings/basic.string/string.nonmembers/string.special/swap_noexcept.pass.cpp =================================================================== --- test/std/strings/basic.string/string.nonmembers/string.special/swap_noexcept.pass.cpp +++ test/std/strings/basic.string/string.nonmembers/string.special/swap_noexcept.pass.cpp @@ -22,6 +22,7 @@ // This tests a conforming extension #include <string> +#include <utility> #include <cassert> #include "test_macros.h" @@ -56,30 +57,26 @@ { { typedef std::string C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::basic_string<char, std::char_traits<char>, test_allocator<char>> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::basic_string<char, std::char_traits<char>, some_alloc<char>> C; - C c1, c2; #if TEST_STD_VER >= 14 // In c++14, if POCS is set, swapping the allocator is required not to throw - static_assert( noexcept(swap(c1, c2)), ""); + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); #else - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); #endif } #if TEST_STD_VER >= 14 { typedef std::basic_string<char, std::char_traits<char>, some_alloc2<char>> C; - C c1, c2; // if the allocators are always equal, then the swap can be noexcept - static_assert( noexcept(swap(c1, c2)), ""); + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } #endif } Index: test/std/containers/unord/unord.set/unord.set.swap/swap_noexcept.pass.cpp =================================================================== --- test/std/containers/unord/unord.set/unord.set.swap/swap_noexcept.pass.cpp +++ test/std/containers/unord/unord.set/unord.set.swap/swap_noexcept.pass.cpp @@ -26,6 +26,7 @@ // This tests a conforming extension #include <unordered_set> +#include <utility> #include <cassert> #include "test_macros.h" @@ -122,79 +123,65 @@ { { typedef std::unordered_set<MoveOnly> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::unordered_set<MoveOnly, some_hash<MoveOnly>> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>, some_comp<MoveOnly>> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } #if TEST_STD_VER >= 14 { // POCS allocator, throwable swap for hash, throwable swap for comp typedef std::unordered_set<MoveOnly, some_hash<MoveOnly>, some_comp <MoveOnly>, some_alloc <MoveOnly>> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // always equal allocator, throwable swap for hash, throwable swap for comp typedef std::unordered_set<MoveOnly, some_hash<MoveOnly>, some_comp <MoveOnly>, some_alloc2<MoveOnly>> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // POCS allocator, throwable swap for hash, nothrow swap for comp typedef std::unordered_set<MoveOnly, some_hash<MoveOnly>, some_comp2<MoveOnly>, some_alloc <MoveOnly>> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // always equal allocator, throwable swap for hash, nothrow swap for comp typedef std::unordered_set<MoveOnly, some_hash<MoveOnly>, some_comp2<MoveOnly>, some_alloc2<MoveOnly>> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // POCS allocator, nothrow swap for hash, throwable swap for comp typedef std::unordered_set<MoveOnly, some_hash2<MoveOnly>, some_comp <MoveOnly>, some_alloc <MoveOnly>> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // always equal allocator, nothrow swap for hash, throwable swap for comp typedef std::unordered_set<MoveOnly, some_hash2<MoveOnly>, some_comp <MoveOnly>, some_alloc2<MoveOnly>> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // POCS allocator, nothrow swap for hash, nothrow swap for comp typedef std::unordered_set<MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc <MoveOnly>> C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // always equal allocator, nothrow swap for hash, nothrow swap for comp typedef std::unordered_set<MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc2<MoveOnly>> C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // NOT always equal allocator, nothrow swap for hash, nothrow swap for comp typedef std::unordered_set<MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc3<MoveOnly>> C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } #endif } Index: test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_noexcept.pass.cpp =================================================================== --- test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_noexcept.pass.cpp +++ test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_noexcept.pass.cpp @@ -26,6 +26,7 @@ // This tests a conforming extension #include <unordered_set> +#include <utility> #include <cassert> #include "test_macros.h" @@ -122,79 +123,65 @@ { { typedef std::unordered_multiset<MoveOnly> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::unordered_multiset<MoveOnly, some_hash<MoveOnly>> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>, some_comp<MoveOnly>> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } #if TEST_STD_VER >= 14 { // POCS allocator, throwable swap for hash, throwable swap for comp typedef std::unordered_multiset<MoveOnly, some_hash<MoveOnly>, some_comp <MoveOnly>, some_alloc <MoveOnly>> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // always equal allocator, throwable swap for hash, throwable swap for comp typedef std::unordered_multiset<MoveOnly, some_hash<MoveOnly>, some_comp <MoveOnly>, some_alloc2<MoveOnly>> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // POCS allocator, throwable swap for hash, nothrow swap for comp typedef std::unordered_multiset<MoveOnly, some_hash<MoveOnly>, some_comp2<MoveOnly>, some_alloc <MoveOnly>> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // always equal allocator, throwable swap for hash, nothrow swap for comp typedef std::unordered_multiset<MoveOnly, some_hash<MoveOnly>, some_comp2<MoveOnly>, some_alloc2<MoveOnly>> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // POCS allocator, nothrow swap for hash, throwable swap for comp typedef std::unordered_multiset<MoveOnly, some_hash2<MoveOnly>, some_comp <MoveOnly>, some_alloc <MoveOnly>> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // always equal allocator, nothrow swap for hash, throwable swap for comp typedef std::unordered_multiset<MoveOnly, some_hash2<MoveOnly>, some_comp <MoveOnly>, some_alloc2<MoveOnly>> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // POCS allocator, nothrow swap for hash, nothrow swap for comp typedef std::unordered_multiset<MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc <MoveOnly>> C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // always equal allocator, nothrow swap for hash, nothrow swap for comp typedef std::unordered_multiset<MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc2<MoveOnly>> C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // NOT always equal allocator, nothrow swap for hash, nothrow swap for comp typedef std::unordered_multiset<MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc3<MoveOnly>> C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } #endif } Index: test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_noexcept.pass.cpp =================================================================== --- test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_noexcept.pass.cpp +++ test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_noexcept.pass.cpp @@ -26,6 +26,7 @@ // This tests a conforming extension #include <unordered_map> +#include <utility> #include <cassert> #include "test_macros.h" @@ -121,78 +122,64 @@ typedef std::pair<const MoveOnly, MoveOnly> V; { typedef std::unordered_multimap<MoveOnly, MoveOnly> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, test_allocator<V>> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, other_allocator<V>> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>, some_comp<MoveOnly>> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } #if TEST_STD_VER >= 14 { // POCS allocator, throwable swap for hash, throwable swap for comp typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>, some_comp <MoveOnly>, some_alloc <V>> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // always equal allocator, throwable swap for hash, throwable swap for comp typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>, some_comp <MoveOnly>, some_alloc2<V>> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // POCS allocator, throwable swap for hash, nothrow swap for comp typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>, some_comp2<MoveOnly>, some_alloc <V>> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // always equal allocator, throwable swap for hash, nothrow swap for comp typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>, some_comp2<MoveOnly>, some_alloc2<V>> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // POCS allocator, nothrow swap for hash, throwable swap for comp typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash2<MoveOnly>, some_comp <MoveOnly>, some_alloc <V>> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // always equal allocator, nothrow swap for hash, throwable swap for comp typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash2<MoveOnly>, some_comp <MoveOnly>, some_alloc2<V>> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // POCS allocator, nothrow swap for hash, nothrow swap for comp typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc <V>> C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // always equal allocator, nothrow swap for hash, nothrow swap for comp typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc2<V>> C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // NOT always equal allocator, nothrow swap for hash, nothrow swap for comp typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc3<V>> C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } #endif } Index: test/std/containers/unord/unord.map/unord.map.swap/swap_noexcept.pass.cpp =================================================================== --- test/std/containers/unord/unord.map/unord.map.swap/swap_noexcept.pass.cpp +++ test/std/containers/unord/unord.map/unord.map.swap/swap_noexcept.pass.cpp @@ -26,6 +26,7 @@ // This tests a conforming extension #include <unordered_map> +#include <utility> #include <cassert> #include "test_macros.h" @@ -122,79 +123,65 @@ typedef std::pair<const MoveOnly, MoveOnly> MapType; { typedef std::unordered_map<MoveOnly, MoveOnly> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, test_allocator<MapType>> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, other_allocator<MapType>> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>, some_comp<MoveOnly>> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } #if TEST_STD_VER >= 14 { // POCS allocator, throwable swap for hash, throwable swap for comp typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>, some_comp <MoveOnly>, some_alloc <MapType>> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // always equal allocator, throwable swap for hash, throwable swap for comp typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>, some_comp <MoveOnly>, some_alloc2<MapType>> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // POCS allocator, throwable swap for hash, nothrow swap for comp typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>, some_comp2<MoveOnly>, some_alloc <MapType>> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // always equal allocator, throwable swap for hash, nothrow swap for comp typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>, some_comp2<MoveOnly>, some_alloc2<MapType>> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // POCS allocator, nothrow swap for hash, throwable swap for comp typedef std::unordered_map<MoveOnly, MoveOnly, some_hash2<MoveOnly>, some_comp <MoveOnly>, some_alloc <MapType>> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // always equal allocator, nothrow swap for hash, throwable swap for comp typedef std::unordered_map<MoveOnly, MoveOnly, some_hash2<MoveOnly>, some_comp <MoveOnly>, some_alloc2<MapType>> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // POCS allocator, nothrow swap for hash, nothrow swap for comp typedef std::unordered_map<MoveOnly, MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc <MapType>> C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // always equal allocator, nothrow swap for hash, nothrow swap for comp typedef std::unordered_map<MoveOnly, MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc2<MapType>> C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // NOT always equal allocator, nothrow swap for hash, nothrow swap for comp typedef std::unordered_map<MoveOnly, MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc3<MapType>> C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } #endif } Index: test/std/containers/sequences/vector/vector.special/swap_noexcept.pass.cpp =================================================================== --- test/std/containers/sequences/vector/vector.special/swap_noexcept.pass.cpp +++ test/std/containers/sequences/vector/vector.special/swap_noexcept.pass.cpp @@ -22,6 +22,7 @@ // This tests a conforming extension #include <vector> +#include <utility> #include <cassert> #include "test_macros.h" @@ -57,35 +58,30 @@ { { typedef std::vector<MoveOnly> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::vector<MoveOnly, test_allocator<MoveOnly>> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::vector<MoveOnly, other_allocator<MoveOnly>> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::vector<MoveOnly, some_alloc<MoveOnly>> C; - C c1, c2; #if TEST_STD_VER >= 14 // In c++14, if POCS is set, swapping the allocator is required not to throw - static_assert( noexcept(swap(c1, c2)), ""); + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); #else - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); #endif } #if TEST_STD_VER >= 14 { typedef std::vector<MoveOnly, some_alloc2<MoveOnly>> C; - C c1, c2; // if the allocators are always equal, then the swap can be noexcept - static_assert( noexcept(swap(c1, c2)), ""); + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } #endif } Index: test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp =================================================================== --- test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp +++ test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp @@ -22,6 +22,7 @@ // This tests a conforming extension #include <vector> +#include <utility> #include <cassert> #include "test_macros.h" @@ -56,35 +57,30 @@ { { typedef std::vector<bool> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::vector<bool, test_allocator<bool>> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::vector<bool, other_allocator<bool>> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::vector<bool, some_alloc<bool>> C; - C c1, c2; #if TEST_STD_VER >= 14 // In c++14, if POCS is set, swapping the allocator is required not to throw - static_assert( noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); #else - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); #endif } #if TEST_STD_VER >= 14 { typedef std::vector<bool, some_alloc2<bool>> C; - C c1, c2; // if the allocators are always equal, then the swap can be noexcept - static_assert( noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } #endif } Index: test/std/containers/sequences/list/list.special/swap_noexcept.pass.cpp =================================================================== --- test/std/containers/sequences/list/list.special/swap_noexcept.pass.cpp +++ test/std/containers/sequences/list/list.special/swap_noexcept.pass.cpp @@ -21,6 +21,7 @@ // This tests a conforming extension #include <list> +#include <utility> #include <cassert> #include "test_macros.h" @@ -56,35 +57,30 @@ { { typedef std::list<MoveOnly> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::list<MoveOnly, test_allocator<MoveOnly>> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::list<MoveOnly, other_allocator<MoveOnly>> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::list<MoveOnly, some_alloc<MoveOnly>> C; - C c1, c2; #if TEST_STD_VER >= 14 // In c++14, if POCS is set, swapping the allocator is required not to throw - static_assert( noexcept(swap(c1, c2)), ""); + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); #else - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); #endif } #if TEST_STD_VER >= 14 { typedef std::list<MoveOnly, some_alloc2<MoveOnly>> C; - C c1, c2; // if the allocators are always equal, then the swap can be noexcept - static_assert( noexcept(swap(c1, c2)), ""); + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } #endif Index: test/std/containers/sequences/forwardlist/forwardlist.spec/swap_noexcept.pass.cpp =================================================================== --- test/std/containers/sequences/forwardlist/forwardlist.spec/swap_noexcept.pass.cpp +++ test/std/containers/sequences/forwardlist/forwardlist.spec/swap_noexcept.pass.cpp @@ -21,6 +21,7 @@ // This tests a conforming extension #include <forward_list> +#include <utility> #include <cassert> #include "test_macros.h" @@ -56,35 +57,30 @@ { { typedef std::forward_list<MoveOnly> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::forward_list<MoveOnly, test_allocator<MoveOnly>> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::forward_list<MoveOnly, other_allocator<MoveOnly>> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::forward_list<MoveOnly, some_alloc<MoveOnly>> C; - C c1, c2; #if TEST_STD_VER >= 14 // In c++14, if POCS is set, swapping the allocator is required not to throw - static_assert( noexcept(swap(c1, c2)), ""); + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); #else - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); #endif } #if TEST_STD_VER >= 14 { typedef std::forward_list<MoveOnly, some_alloc2<MoveOnly>> C; - C c1, c2; // if the allocators are always equal, then the swap can be noexcept - static_assert( noexcept(swap(c1, c2)), ""); + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } #endif } Index: test/std/containers/sequences/deque/deque.special/swap_noexcept.pass.cpp =================================================================== --- test/std/containers/sequences/deque/deque.special/swap_noexcept.pass.cpp +++ test/std/containers/sequences/deque/deque.special/swap_noexcept.pass.cpp @@ -21,6 +21,7 @@ // This tests a conforming extension #include <deque> +#include <utility> #include <cassert> #include "test_macros.h" @@ -56,35 +57,30 @@ { { typedef std::deque<MoveOnly> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::deque<MoveOnly, test_allocator<MoveOnly>> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::deque<MoveOnly, other_allocator<MoveOnly>> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::deque<MoveOnly, some_alloc<MoveOnly>> C; - C c1, c2; #if TEST_STD_VER >= 14 // In c++14, if POCS is set, swapping the allocator is required not to throw - static_assert( noexcept(swap(c1, c2)), ""); + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); #else - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); #endif } #if TEST_STD_VER >= 14 { typedef std::deque<MoveOnly, some_alloc2<MoveOnly>> C; - C c1, c2; // if the allocators are always equal, then the swap can be noexcept - static_assert( noexcept(swap(c1, c2)), ""); + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } #endif Index: test/std/containers/container.adaptors/stack/stack.special/swap_noexcept.pass.cpp =================================================================== --- test/std/containers/container.adaptors/stack/stack.special/swap_noexcept.pass.cpp +++ test/std/containers/container.adaptors/stack/stack.special/swap_noexcept.pass.cpp @@ -17,15 +17,15 @@ // UNSUPPORTED: c++98, c++03 #include <stack> +#include <utility> #include <cassert> #include "MoveOnly.h" int main() { { typedef std::stack<MoveOnly> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } } Index: test/std/containers/container.adaptors/queue/queue.special/swap_noexcept.pass.cpp =================================================================== --- test/std/containers/container.adaptors/queue/queue.special/swap_noexcept.pass.cpp +++ test/std/containers/container.adaptors/queue/queue.special/swap_noexcept.pass.cpp @@ -17,15 +17,15 @@ // UNSUPPORTED: c++98, c++03 #include <queue> +#include <utility> #include <cassert> #include "MoveOnly.h" int main() { { typedef std::queue<MoveOnly> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } } Index: test/std/containers/container.adaptors/priority.queue/priqueue.special/swap_noexcept.pass.cpp =================================================================== --- test/std/containers/container.adaptors/priority.queue/priqueue.special/swap_noexcept.pass.cpp +++ test/std/containers/container.adaptors/priority.queue/priqueue.special/swap_noexcept.pass.cpp @@ -18,15 +18,15 @@ // UNSUPPORTED: c++98, c++03 #include <queue> +#include <utility> #include <cassert> #include "MoveOnly.h" int main() { { typedef std::priority_queue<MoveOnly> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } } Index: test/std/containers/associative/set/set.special/swap_noexcept.pass.cpp =================================================================== --- test/std/containers/associative/set/set.special/swap_noexcept.pass.cpp +++ test/std/containers/associative/set/set.special/swap_noexcept.pass.cpp @@ -22,6 +22,7 @@ // This tests a conforming extension #include <set> +#include <utility> #include <cassert> #include "test_macros.h" @@ -95,51 +96,42 @@ { { typedef std::set<MoveOnly> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::set<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::set<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::set<MoveOnly, some_comp<MoveOnly>> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } #if TEST_STD_VER >= 14 { // POCS allocator, throwable swap for comp typedef std::set<MoveOnly, some_comp <MoveOnly>, some_alloc <MoveOnly>> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // always equal allocator, throwable swap for comp typedef std::set<MoveOnly, some_comp <MoveOnly>, some_alloc2<MoveOnly>> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // POCS allocator, nothrow swap for comp typedef std::set<MoveOnly, some_comp2<MoveOnly>, some_alloc <MoveOnly>> C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // always equal allocator, nothrow swap for comp typedef std::set<MoveOnly, some_comp2<MoveOnly>, some_alloc2<MoveOnly>> C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // NOT always equal allocator, nothrow swap for comp typedef std::set<MoveOnly, some_comp2<MoveOnly>, some_alloc3<MoveOnly>> C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } #endif Index: test/std/containers/associative/multiset/multiset.special/swap_noexcept.pass.cpp =================================================================== --- test/std/containers/associative/multiset/multiset.special/swap_noexcept.pass.cpp +++ test/std/containers/associative/multiset/multiset.special/swap_noexcept.pass.cpp @@ -22,6 +22,7 @@ // This tests a conforming extension #include <set> +#include <utility> #include <cassert> #include "test_macros.h" @@ -95,51 +96,42 @@ { { typedef std::multiset<MoveOnly> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::multiset<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::multiset<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::multiset<MoveOnly, some_comp<MoveOnly>> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } #if TEST_STD_VER >= 14 { // POCS allocator, throwable swap for comp typedef std::multiset<MoveOnly, some_comp <MoveOnly>, some_alloc <MoveOnly>> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // always equal allocator, throwable swap for comp typedef std::multiset<MoveOnly, some_comp <MoveOnly>, some_alloc2<MoveOnly>> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // POCS allocator, nothrow swap for comp typedef std::multiset<MoveOnly, some_comp2<MoveOnly>, some_alloc <MoveOnly>> C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // always equal allocator, nothrow swap for comp typedef std::multiset<MoveOnly, some_comp2<MoveOnly>, some_alloc2<MoveOnly>> C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // NOT always equal allocator, nothrow swap for comp typedef std::multiset<MoveOnly, some_comp2<MoveOnly>, some_alloc3<MoveOnly>> C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } #endif } Index: test/std/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp =================================================================== --- test/std/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp +++ test/std/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp @@ -22,6 +22,7 @@ // This tests a conforming extension #include <map> +#include <utility> #include <cassert> #include "test_macros.h" @@ -96,51 +97,42 @@ typedef std::pair<const MoveOnly, MoveOnly> V; { typedef std::multimap<MoveOnly, MoveOnly> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<V>> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<V>> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::multimap<MoveOnly, MoveOnly, some_comp<MoveOnly>> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } #if TEST_STD_VER >= 14 { // POCS allocator, throwable swap for comp typedef std::multimap<MoveOnly, MoveOnly, some_comp <MoveOnly>, some_alloc <V>> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // always equal allocator, throwable swap for comp typedef std::multimap<MoveOnly, MoveOnly, some_comp <MoveOnly>, some_alloc2<V>> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // POCS allocator, nothrow swap for comp typedef std::multimap<MoveOnly, MoveOnly, some_comp2<MoveOnly>, some_alloc <V>> C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // always equal allocator, nothrow swap for comp typedef std::multimap<MoveOnly, MoveOnly, some_comp2<MoveOnly>, some_alloc2<V>> C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // NOT always equal allocator, nothrow swap for comp - typedef std::map<MoveOnly, MoveOnly, some_comp2<MoveOnly>, some_alloc3<V>> C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + typedef std::multimap<MoveOnly, MoveOnly, some_comp2<MoveOnly>, some_alloc3<V>> C; + LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } #endif } Index: test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp =================================================================== --- test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp +++ test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp @@ -22,6 +22,7 @@ // This tests a conforming extension #include <map> +#include <utility> #include <cassert> #include "test_macros.h" @@ -96,51 +97,42 @@ typedef std::pair<const MoveOnly, MoveOnly> V; { typedef std::map<MoveOnly, MoveOnly> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<V>> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<V>> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::map<MoveOnly, MoveOnly, some_comp<MoveOnly>> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } #if TEST_STD_VER >= 14 { // POCS allocator, throwable swap for comp typedef std::map<MoveOnly, MoveOnly, some_comp <MoveOnly>, some_alloc <V>> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // always equal allocator, throwable swap for comp typedef std::map<MoveOnly, MoveOnly, some_comp <MoveOnly>, some_alloc2<V>> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // POCS allocator, nothrow swap for comp typedef std::map<MoveOnly, MoveOnly, some_comp2<MoveOnly>, some_alloc <V>> C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // always equal allocator, nothrow swap for comp typedef std::map<MoveOnly, MoveOnly, some_comp2<MoveOnly>, some_alloc2<V>> C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { // NOT always equal allocator, nothrow swap for comp typedef std::map<MoveOnly, MoveOnly, some_comp2<MoveOnly>, some_alloc3<V>> C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } #endif
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits