summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/strings/basic.string/string.nonmembers
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2016-07-25 00:15:29 +0000
committerEric Fiselier <eric@efcs.ca>2016-07-25 00:15:29 +0000
commit2cd516e049e4fc1dd8e33c6990841f5b6300ef6c (patch)
tree93a4ef9738c9e6d7e3b4a8b023cd20943a598c5c /libcxx/test/std/strings/basic.string/string.nonmembers
parentb8937d64541667809b84859b7315506e4f4c1df5 (diff)
downloadbcm5719-llvm-2cd516e049e4fc1dd8e33c6990841f5b6300ef6c.tar.gz
bcm5719-llvm-2cd516e049e4fc1dd8e33c6990841f5b6300ef6c.zip
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
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.cpp15
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
}
OpenPOWER on IntegriCloud