From 2cd516e049e4fc1dd8e33c6990841f5b6300ef6c Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Mon, 25 Jul 2016 00:15:29 +0000 Subject: 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 --- .../string.special/swap_noexcept.pass.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'libcxx/test/std/strings/basic.string') 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 4ac13d10e67..757d5eeb2dc 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 } -- cgit v1.2.3