diff options
Diffstat (limited to 'libcxx/test/std/strings/basic.string/string.nonmembers')
-rw-r--r-- | libcxx/test/std/strings/basic.string/string.nonmembers/string.special/swap_noexcept.pass.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
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 <string> +#include <utility> #include <cassert> #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<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 } |