From 2cd516e049e4fc1dd8e33c6990841f5b6300ef6c Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Mon, 25 Jul 2016 00:15:29 +0000 Subject: [PATCH] Make swap_noexcept.pass.cpp tests more portable. Patch from STL@microsoft.com. See D21820 for more information (https://reviews.llvm.org/D21820). llvm-svn: 276590 --- .../map/map.special/swap_noexcept.pass.cpp | 28 +++++------- .../multimap.special/swap_noexcept.pass.cpp | 30 +++++-------- .../multiset.special/swap_noexcept.pass.cpp | 28 +++++------- .../set/set.special/swap_noexcept.pass.cpp | 28 +++++------- .../priqueue.special/swap_noexcept.pass.cpp | 4 +- .../queue.special/swap_noexcept.pass.cpp | 4 +- .../stack.special/swap_noexcept.pass.cpp | 4 +- .../deque.special/swap_noexcept.pass.cpp | 18 +++----- .../forwardlist.spec/swap_noexcept.pass.cpp | 18 +++----- .../list/list.special/swap_noexcept.pass.cpp | 18 +++----- .../vector.bool/swap_noexcept.pass.cpp | 18 +++----- .../vector.special/swap_noexcept.pass.cpp | 18 +++----- .../unord.map.swap/swap_noexcept.pass.cpp | 43 +++++++------------ .../swap_noexcept.pass.cpp | 43 +++++++------------ .../swap_noexcept.pass.cpp | 43 +++++++------------ .../unord.set.swap/swap_noexcept.pass.cpp | 43 +++++++------------ .../string.special/swap_noexcept.pass.cpp | 15 +++---- 17 files changed, 148 insertions(+), 255 deletions(-) diff --git a/libcxx/test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp b/libcxx/test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp index cbbf4577ce62..84907945a90e 100644 --- a/libcxx/test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp @@ -22,6 +22,7 @@ // This tests a conforming extension #include +#include #include #include "test_macros.h" @@ -96,51 +97,42 @@ int main() typedef std::pair V; { typedef std::map C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + static_assert(noexcept(swap(std::declval(), std::declval())), ""); } { typedef std::map, test_allocator> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval(), std::declval())), ""); } { typedef std::map, other_allocator> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval(), std::declval())), ""); } { typedef std::map> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); } #if TEST_STD_VER >= 14 { // POCS allocator, throwable swap for comp typedef std::map, some_alloc > C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); } { // always equal allocator, throwable swap for comp typedef std::map, some_alloc2> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); } { // POCS allocator, nothrow swap for comp typedef std::map, some_alloc > C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + static_assert( noexcept(swap(std::declval(), std::declval())), ""); } { // always equal allocator, nothrow swap for comp typedef std::map, some_alloc2> C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + static_assert( noexcept(swap(std::declval(), std::declval())), ""); } { // NOT always equal allocator, nothrow swap for comp typedef std::map, some_alloc3> C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval(), std::declval())), ""); } #endif diff --git a/libcxx/test/std/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp index ffc71b0eeb92..ecc9c7ef5fd4 100644 --- a/libcxx/test/std/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp +++ b/libcxx/test/std/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp @@ -22,6 +22,7 @@ // This tests a conforming extension #include +#include #include #include "test_macros.h" @@ -96,51 +97,42 @@ int main() typedef std::pair V; { typedef std::multimap C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + static_assert(noexcept(swap(std::declval(), std::declval())), ""); } { typedef std::multimap, test_allocator> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval(), std::declval())), ""); } { typedef std::multimap, other_allocator> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval(), std::declval())), ""); } { typedef std::multimap> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); } #if TEST_STD_VER >= 14 { // POCS allocator, throwable swap for comp typedef std::multimap, some_alloc > C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); } { // always equal allocator, throwable swap for comp typedef std::multimap, some_alloc2> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); } { // POCS allocator, nothrow swap for comp typedef std::multimap, some_alloc > C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + static_assert( noexcept(swap(std::declval(), std::declval())), ""); } { // always equal allocator, nothrow swap for comp typedef std::multimap, some_alloc2> C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + static_assert( noexcept(swap(std::declval(), std::declval())), ""); } { // NOT always equal allocator, nothrow swap for comp - typedef std::map, some_alloc3> C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + typedef std::multimap, some_alloc3> C; + LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval(), std::declval())), ""); } #endif } diff --git a/libcxx/test/std/containers/associative/multiset/multiset.special/swap_noexcept.pass.cpp b/libcxx/test/std/containers/associative/multiset/multiset.special/swap_noexcept.pass.cpp index 87639943a0b5..89fabef0a3a0 100644 --- a/libcxx/test/std/containers/associative/multiset/multiset.special/swap_noexcept.pass.cpp +++ b/libcxx/test/std/containers/associative/multiset/multiset.special/swap_noexcept.pass.cpp @@ -22,6 +22,7 @@ // This tests a conforming extension #include +#include #include #include "test_macros.h" @@ -95,51 +96,42 @@ int main() { { typedef std::multiset C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + static_assert(noexcept(swap(std::declval(), std::declval())), ""); } { typedef std::multiset, test_allocator> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval(), std::declval())), ""); } { typedef std::multiset, other_allocator> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval(), std::declval())), ""); } { typedef std::multiset> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); } #if TEST_STD_VER >= 14 { // POCS allocator, throwable swap for comp typedef std::multiset, some_alloc > C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); } { // always equal allocator, throwable swap for comp typedef std::multiset, some_alloc2> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); } { // POCS allocator, nothrow swap for comp typedef std::multiset, some_alloc > C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + static_assert( noexcept(swap(std::declval(), std::declval())), ""); } { // always equal allocator, nothrow swap for comp typedef std::multiset, some_alloc2> C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + static_assert( noexcept(swap(std::declval(), std::declval())), ""); } { // NOT always equal allocator, nothrow swap for comp typedef std::multiset, some_alloc3> C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval(), std::declval())), ""); } #endif } diff --git a/libcxx/test/std/containers/associative/set/set.special/swap_noexcept.pass.cpp b/libcxx/test/std/containers/associative/set/set.special/swap_noexcept.pass.cpp index 0eb7d871b8b4..b3edd31f749b 100644 --- a/libcxx/test/std/containers/associative/set/set.special/swap_noexcept.pass.cpp +++ b/libcxx/test/std/containers/associative/set/set.special/swap_noexcept.pass.cpp @@ -22,6 +22,7 @@ // This tests a conforming extension #include +#include #include #include "test_macros.h" @@ -95,51 +96,42 @@ int main() { { typedef std::set C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + static_assert(noexcept(swap(std::declval(), std::declval())), ""); } { typedef std::set, test_allocator> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval(), std::declval())), ""); } { typedef std::set, other_allocator> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval(), std::declval())), ""); } { typedef std::set> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); } #if TEST_STD_VER >= 14 { // POCS allocator, throwable swap for comp typedef std::set, some_alloc > C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); } { // always equal allocator, throwable swap for comp typedef std::set, some_alloc2> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); } { // POCS allocator, nothrow swap for comp typedef std::set, some_alloc > C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + static_assert( noexcept(swap(std::declval(), std::declval())), ""); } { // always equal allocator, nothrow swap for comp typedef std::set, some_alloc2> C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + static_assert( noexcept(swap(std::declval(), std::declval())), ""); } { // NOT always equal allocator, nothrow swap for comp typedef std::set, some_alloc3> C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval(), std::declval())), ""); } #endif diff --git a/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.special/swap_noexcept.pass.cpp b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.special/swap_noexcept.pass.cpp index bfff607590fe..845ca758769d 100644 --- a/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.special/swap_noexcept.pass.cpp +++ b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.special/swap_noexcept.pass.cpp @@ -18,6 +18,7 @@ // UNSUPPORTED: c++98, c++03 #include +#include #include #include "MoveOnly.h" @@ -26,7 +27,6 @@ int main() { { typedef std::priority_queue C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + static_assert(noexcept(swap(std::declval(), std::declval())), ""); } } diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.special/swap_noexcept.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.special/swap_noexcept.pass.cpp index e18f80a91198..542b4901173c 100644 --- a/libcxx/test/std/containers/container.adaptors/queue/queue.special/swap_noexcept.pass.cpp +++ b/libcxx/test/std/containers/container.adaptors/queue/queue.special/swap_noexcept.pass.cpp @@ -17,6 +17,7 @@ // UNSUPPORTED: c++98, c++03 #include +#include #include #include "MoveOnly.h" @@ -25,7 +26,6 @@ int main() { { typedef std::queue C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + static_assert(noexcept(swap(std::declval(), std::declval())), ""); } } diff --git a/libcxx/test/std/containers/container.adaptors/stack/stack.special/swap_noexcept.pass.cpp b/libcxx/test/std/containers/container.adaptors/stack/stack.special/swap_noexcept.pass.cpp index 976e362a0483..12150055394e 100644 --- a/libcxx/test/std/containers/container.adaptors/stack/stack.special/swap_noexcept.pass.cpp +++ b/libcxx/test/std/containers/container.adaptors/stack/stack.special/swap_noexcept.pass.cpp @@ -17,6 +17,7 @@ // UNSUPPORTED: c++98, c++03 #include +#include #include #include "MoveOnly.h" @@ -25,7 +26,6 @@ int main() { { typedef std::stack C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + static_assert(noexcept(swap(std::declval(), std::declval())), ""); } } diff --git a/libcxx/test/std/containers/sequences/deque/deque.special/swap_noexcept.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.special/swap_noexcept.pass.cpp index 2f999e9a7a5d..c0af762fb277 100644 --- a/libcxx/test/std/containers/sequences/deque/deque.special/swap_noexcept.pass.cpp +++ b/libcxx/test/std/containers/sequences/deque/deque.special/swap_noexcept.pass.cpp @@ -21,6 +21,7 @@ // This tests a conforming extension #include +#include #include #include "test_macros.h" @@ -56,35 +57,30 @@ int main() { { typedef std::deque C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + static_assert(noexcept(swap(std::declval(), std::declval())), ""); } { typedef std::deque> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval(), std::declval())), ""); } { typedef std::deque> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval(), std::declval())), ""); } { typedef std::deque> 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(), std::declval())), ""); #else - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); #endif } #if TEST_STD_VER >= 14 { typedef std::deque> 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(), std::declval())), ""); } #endif diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.spec/swap_noexcept.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.spec/swap_noexcept.pass.cpp index 5f8cf95aa737..c63194f7ee64 100644 --- a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.spec/swap_noexcept.pass.cpp +++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.spec/swap_noexcept.pass.cpp @@ -21,6 +21,7 @@ // This tests a conforming extension #include +#include #include #include "test_macros.h" @@ -56,35 +57,30 @@ int main() { { typedef std::forward_list C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + static_assert(noexcept(swap(std::declval(), std::declval())), ""); } { typedef std::forward_list> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval(), std::declval())), ""); } { typedef std::forward_list> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval(), std::declval())), ""); } { typedef std::forward_list> 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(), std::declval())), ""); #else - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); #endif } #if TEST_STD_VER >= 14 { typedef std::forward_list> 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(), std::declval())), ""); } #endif } diff --git a/libcxx/test/std/containers/sequences/list/list.special/swap_noexcept.pass.cpp b/libcxx/test/std/containers/sequences/list/list.special/swap_noexcept.pass.cpp index 820da4c78f81..512635359c5d 100644 --- a/libcxx/test/std/containers/sequences/list/list.special/swap_noexcept.pass.cpp +++ b/libcxx/test/std/containers/sequences/list/list.special/swap_noexcept.pass.cpp @@ -21,6 +21,7 @@ // This tests a conforming extension #include +#include #include #include "test_macros.h" @@ -56,35 +57,30 @@ int main() { { typedef std::list C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + static_assert(noexcept(swap(std::declval(), std::declval())), ""); } { typedef std::list> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval(), std::declval())), ""); } { typedef std::list> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval(), std::declval())), ""); } { typedef std::list> 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(), std::declval())), ""); #else - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); #endif } #if TEST_STD_VER >= 14 { typedef std::list> 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(), std::declval())), ""); } #endif diff --git a/libcxx/test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp index 7ba44453b371..1b68eda2757b 100644 --- a/libcxx/test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp @@ -22,6 +22,7 @@ // This tests a conforming extension #include +#include #include #include "test_macros.h" @@ -56,35 +57,30 @@ int main() { { typedef std::vector C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval(), std::declval())), ""); } { typedef std::vector> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval(), std::declval())), ""); } { typedef std::vector> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval(), std::declval())), ""); } { typedef std::vector> 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(), std::declval())), ""); #else - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); #endif } #if TEST_STD_VER >= 14 { typedef std::vector> 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(), std::declval())), ""); } #endif } diff --git a/libcxx/test/std/containers/sequences/vector/vector.special/swap_noexcept.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.special/swap_noexcept.pass.cpp index 89fa301ad9bd..214f9a577571 100644 --- a/libcxx/test/std/containers/sequences/vector/vector.special/swap_noexcept.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.special/swap_noexcept.pass.cpp @@ -22,6 +22,7 @@ // This tests a conforming extension #include +#include #include #include "test_macros.h" @@ -57,35 +58,30 @@ int main() { { typedef std::vector C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + static_assert(noexcept(swap(std::declval(), std::declval())), ""); } { typedef std::vector> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval(), std::declval())), ""); } { typedef std::vector> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + static_assert(noexcept(swap(std::declval(), std::declval())), ""); } { typedef std::vector> 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(), std::declval())), ""); #else - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); #endif } #if TEST_STD_VER >= 14 { typedef std::vector> 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(), std::declval())), ""); } #endif } diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.swap/swap_noexcept.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.swap/swap_noexcept.pass.cpp index f8f17ffec57a..fc286ceec8eb 100644 --- a/libcxx/test/std/containers/unord/unord.map/unord.map.swap/swap_noexcept.pass.cpp +++ b/libcxx/test/std/containers/unord/unord.map/unord.map.swap/swap_noexcept.pass.cpp @@ -26,6 +26,7 @@ // This tests a conforming extension #include +#include #include #include "test_macros.h" @@ -122,79 +123,65 @@ int main() typedef std::pair MapType; { typedef std::unordered_map C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + static_assert(noexcept(swap(std::declval(), std::declval())), ""); } { typedef std::unordered_map, std::equal_to, test_allocator> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval(), std::declval())), ""); } { typedef std::unordered_map, std::equal_to, other_allocator> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval(), std::declval())), ""); } { typedef std::unordered_map> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); } { typedef std::unordered_map, some_comp> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); } #if TEST_STD_VER >= 14 { // POCS allocator, throwable swap for hash, throwable swap for comp typedef std::unordered_map, some_comp , some_alloc > C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); } { // always equal allocator, throwable swap for hash, throwable swap for comp typedef std::unordered_map, some_comp , some_alloc2> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); } { // POCS allocator, throwable swap for hash, nothrow swap for comp typedef std::unordered_map, some_comp2, some_alloc > C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); } { // always equal allocator, throwable swap for hash, nothrow swap for comp typedef std::unordered_map, some_comp2, some_alloc2> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); } { // POCS allocator, nothrow swap for hash, throwable swap for comp typedef std::unordered_map, some_comp , some_alloc > C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); } { // always equal allocator, nothrow swap for hash, throwable swap for comp typedef std::unordered_map, some_comp , some_alloc2> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); } { // POCS allocator, nothrow swap for hash, nothrow swap for comp typedef std::unordered_map, some_comp2, some_alloc > C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + static_assert( noexcept(swap(std::declval(), std::declval())), ""); } { // always equal allocator, nothrow swap for hash, nothrow swap for comp typedef std::unordered_map, some_comp2, some_alloc2> C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + static_assert( noexcept(swap(std::declval(), std::declval())), ""); } { // NOT always equal allocator, nothrow swap for hash, nothrow swap for comp typedef std::unordered_map, some_comp2, some_alloc3> C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval(), std::declval())), ""); } #endif } diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_noexcept.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_noexcept.pass.cpp index 553131182315..7a58709c9fc9 100644 --- a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_noexcept.pass.cpp +++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_noexcept.pass.cpp @@ -26,6 +26,7 @@ // This tests a conforming extension #include +#include #include #include "test_macros.h" @@ -121,78 +122,64 @@ int main() typedef std::pair V; { typedef std::unordered_multimap C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + static_assert(noexcept(swap(std::declval(), std::declval())), ""); } { typedef std::unordered_multimap, std::equal_to, test_allocator> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval(), std::declval())), ""); } { typedef std::unordered_multimap, std::equal_to, other_allocator> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval(), std::declval())), ""); } { typedef std::unordered_multimap> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); } { typedef std::unordered_multimap, some_comp> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); } #if TEST_STD_VER >= 14 { // POCS allocator, throwable swap for hash, throwable swap for comp typedef std::unordered_multimap, some_comp , some_alloc > C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); } { // always equal allocator, throwable swap for hash, throwable swap for comp typedef std::unordered_multimap, some_comp , some_alloc2> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); } { // POCS allocator, throwable swap for hash, nothrow swap for comp typedef std::unordered_multimap, some_comp2, some_alloc > C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); } { // always equal allocator, throwable swap for hash, nothrow swap for comp typedef std::unordered_multimap, some_comp2, some_alloc2> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); } { // POCS allocator, nothrow swap for hash, throwable swap for comp typedef std::unordered_multimap, some_comp , some_alloc > C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); } { // always equal allocator, nothrow swap for hash, throwable swap for comp typedef std::unordered_multimap, some_comp , some_alloc2> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); } { // POCS allocator, nothrow swap for hash, nothrow swap for comp typedef std::unordered_multimap, some_comp2, some_alloc > C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + static_assert( noexcept(swap(std::declval(), std::declval())), ""); } { // always equal allocator, nothrow swap for hash, nothrow swap for comp typedef std::unordered_multimap, some_comp2, some_alloc2> C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + static_assert( noexcept(swap(std::declval(), std::declval())), ""); } { // NOT always equal allocator, nothrow swap for hash, nothrow swap for comp typedef std::unordered_multimap, some_comp2, some_alloc3> C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval(), std::declval())), ""); } #endif } diff --git a/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_noexcept.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_noexcept.pass.cpp index df9f18b147e3..c221b6f2edb0 100644 --- a/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_noexcept.pass.cpp +++ b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_noexcept.pass.cpp @@ -26,6 +26,7 @@ // This tests a conforming extension #include +#include #include #include "test_macros.h" @@ -122,79 +123,65 @@ int main() { { typedef std::unordered_multiset C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + static_assert(noexcept(swap(std::declval(), std::declval())), ""); } { typedef std::unordered_multiset, std::equal_to, test_allocator> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval(), std::declval())), ""); } { typedef std::unordered_multiset, std::equal_to, other_allocator> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval(), std::declval())), ""); } { typedef std::unordered_multiset> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); } { typedef std::unordered_multiset, some_comp> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); } #if TEST_STD_VER >= 14 { // POCS allocator, throwable swap for hash, throwable swap for comp typedef std::unordered_multiset, some_comp , some_alloc > C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); } { // always equal allocator, throwable swap for hash, throwable swap for comp typedef std::unordered_multiset, some_comp , some_alloc2> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); } { // POCS allocator, throwable swap for hash, nothrow swap for comp typedef std::unordered_multiset, some_comp2, some_alloc > C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); } { // always equal allocator, throwable swap for hash, nothrow swap for comp typedef std::unordered_multiset, some_comp2, some_alloc2> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); } { // POCS allocator, nothrow swap for hash, throwable swap for comp typedef std::unordered_multiset, some_comp , some_alloc > C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); } { // always equal allocator, nothrow swap for hash, throwable swap for comp typedef std::unordered_multiset, some_comp , some_alloc2> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); } { // POCS allocator, nothrow swap for hash, nothrow swap for comp typedef std::unordered_multiset, some_comp2, some_alloc > C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + static_assert( noexcept(swap(std::declval(), std::declval())), ""); } { // always equal allocator, nothrow swap for hash, nothrow swap for comp typedef std::unordered_multiset, some_comp2, some_alloc2> C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + static_assert( noexcept(swap(std::declval(), std::declval())), ""); } { // NOT always equal allocator, nothrow swap for hash, nothrow swap for comp typedef std::unordered_multiset, some_comp2, some_alloc3> C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval(), std::declval())), ""); } #endif } diff --git a/libcxx/test/std/containers/unord/unord.set/unord.set.swap/swap_noexcept.pass.cpp b/libcxx/test/std/containers/unord/unord.set/unord.set.swap/swap_noexcept.pass.cpp index d35d79b31266..4a16ddd3f4ce 100644 --- a/libcxx/test/std/containers/unord/unord.set/unord.set.swap/swap_noexcept.pass.cpp +++ b/libcxx/test/std/containers/unord/unord.set/unord.set.swap/swap_noexcept.pass.cpp @@ -26,6 +26,7 @@ // This tests a conforming extension #include +#include #include #include "test_macros.h" @@ -122,79 +123,65 @@ int main() { { typedef std::unordered_set C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + static_assert(noexcept(swap(std::declval(), std::declval())), ""); } { typedef std::unordered_set, std::equal_to, test_allocator> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval(), std::declval())), ""); } { typedef std::unordered_set, std::equal_to, other_allocator> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval(), std::declval())), ""); } { typedef std::unordered_set> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); } { typedef std::unordered_set, some_comp> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); } #if TEST_STD_VER >= 14 { // POCS allocator, throwable swap for hash, throwable swap for comp typedef std::unordered_set, some_comp , some_alloc > C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); } { // always equal allocator, throwable swap for hash, throwable swap for comp typedef std::unordered_set, some_comp , some_alloc2> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); } { // POCS allocator, throwable swap for hash, nothrow swap for comp typedef std::unordered_set, some_comp2, some_alloc > C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); } { // always equal allocator, throwable swap for hash, nothrow swap for comp typedef std::unordered_set, some_comp2, some_alloc2> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); } { // POCS allocator, nothrow swap for hash, throwable swap for comp typedef std::unordered_set, some_comp , some_alloc > C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); } { // always equal allocator, nothrow swap for hash, throwable swap for comp typedef std::unordered_set, some_comp , some_alloc2> C; - C c1, c2; - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); } { // POCS allocator, nothrow swap for hash, nothrow swap for comp typedef std::unordered_set, some_comp2, some_alloc > C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + static_assert( noexcept(swap(std::declval(), std::declval())), ""); } { // always equal allocator, nothrow swap for hash, nothrow swap for comp typedef std::unordered_set, some_comp2, some_alloc2> C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + static_assert( noexcept(swap(std::declval(), std::declval())), ""); } { // NOT always equal allocator, nothrow swap for hash, nothrow swap for comp typedef std::unordered_set, some_comp2, some_alloc3> C; - C c1, c2; - static_assert( noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval(), std::declval())), ""); } #endif } diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string.special/swap_noexcept.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string.special/swap_noexcept.pass.cpp index 4ac13d10e670..757d5eeb2dc3 100644 --- a/libcxx/test/std/strings/basic.string/string.nonmembers/string.special/swap_noexcept.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string.special/swap_noexcept.pass.cpp @@ -22,6 +22,7 @@ // This tests a conforming extension #include +#include #include #include "test_macros.h" @@ -56,30 +57,26 @@ int main() { { typedef std::string C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + static_assert(noexcept(swap(std::declval(), std::declval())), ""); } { typedef std::basic_string, test_allocator> C; - C c1, c2; - static_assert(noexcept(swap(c1, c2)), ""); + LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval(), std::declval())), ""); } { typedef std::basic_string, some_alloc> 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(), std::declval())), ""); #else - static_assert(!noexcept(swap(c1, c2)), ""); + static_assert(!noexcept(swap(std::declval(), std::declval())), ""); #endif } #if TEST_STD_VER >= 14 { typedef std::basic_string, some_alloc2> 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(), std::declval())), ""); } #endif }