mirror of
https://github.com/llvm-mirror/libcxx.git
synced 2025-10-23 18:38:30 +08:00
Make swap_noexcept.pass.cpp tests more portable. Patch from STL@microsoft.com.
See D21820 for more information (https://reviews.llvm.org/D21820). git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@276590 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user