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
This commit is contained in:
Eric Fiselier 2016-07-25 00:15:29 +00:00
parent b8937d6454
commit 2cd516e049
17 changed files with 148 additions and 255 deletions

View File

@ -22,6 +22,7 @@
// This tests a conforming extension
#include <map>
#include <utility>
#include <cassert>
#include "test_macros.h"
@ -96,51 +97,42 @@ int main()
typedef std::pair<const MoveOnly, MoveOnly> V;
{
typedef std::map<MoveOnly, MoveOnly> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{
typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<V>> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{
typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<V>> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{
typedef std::map<MoveOnly, MoveOnly, some_comp<MoveOnly>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
#if TEST_STD_VER >= 14
{ // POCS allocator, throwable swap for comp
typedef std::map<MoveOnly, MoveOnly, some_comp <MoveOnly>, some_alloc <V>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // always equal allocator, throwable swap for comp
typedef std::map<MoveOnly, MoveOnly, some_comp <MoveOnly>, some_alloc2<V>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // POCS allocator, nothrow swap for comp
typedef std::map<MoveOnly, MoveOnly, some_comp2<MoveOnly>, some_alloc <V>> C;
C c1, c2;
static_assert( noexcept(swap(c1, c2)), "");
static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // always equal allocator, nothrow swap for comp
typedef std::map<MoveOnly, MoveOnly, some_comp2<MoveOnly>, some_alloc2<V>> C;
C c1, c2;
static_assert( noexcept(swap(c1, c2)), "");
static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // NOT always equal allocator, nothrow swap for comp
typedef std::map<MoveOnly, MoveOnly, some_comp2<MoveOnly>, some_alloc3<V>> C;
C c1, c2;
static_assert( noexcept(swap(c1, c2)), "");
LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
#endif

View File

@ -22,6 +22,7 @@
// This tests a conforming extension
#include <map>
#include <utility>
#include <cassert>
#include "test_macros.h"
@ -96,51 +97,42 @@ int main()
typedef std::pair<const MoveOnly, MoveOnly> V;
{
typedef std::multimap<MoveOnly, MoveOnly> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{
typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<V>> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{
typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<V>> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{
typedef std::multimap<MoveOnly, MoveOnly, some_comp<MoveOnly>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
#if TEST_STD_VER >= 14
{ // POCS allocator, throwable swap for comp
typedef std::multimap<MoveOnly, MoveOnly, some_comp <MoveOnly>, some_alloc <V>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // always equal allocator, throwable swap for comp
typedef std::multimap<MoveOnly, MoveOnly, some_comp <MoveOnly>, some_alloc2<V>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // POCS allocator, nothrow swap for comp
typedef std::multimap<MoveOnly, MoveOnly, some_comp2<MoveOnly>, some_alloc <V>> C;
C c1, c2;
static_assert( noexcept(swap(c1, c2)), "");
static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // always equal allocator, nothrow swap for comp
typedef std::multimap<MoveOnly, MoveOnly, some_comp2<MoveOnly>, some_alloc2<V>> C;
C c1, c2;
static_assert( noexcept(swap(c1, c2)), "");
static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // NOT always equal allocator, nothrow swap for comp
typedef std::map<MoveOnly, MoveOnly, some_comp2<MoveOnly>, some_alloc3<V>> C;
C c1, c2;
static_assert( noexcept(swap(c1, c2)), "");
typedef std::multimap<MoveOnly, MoveOnly, some_comp2<MoveOnly>, some_alloc3<V>> C;
LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
#endif
}

View File

@ -22,6 +22,7 @@
// This tests a conforming extension
#include <set>
#include <utility>
#include <cassert>
#include "test_macros.h"
@ -95,51 +96,42 @@ int main()
{
{
typedef std::multiset<MoveOnly> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{
typedef std::multiset<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{
typedef std::multiset<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{
typedef std::multiset<MoveOnly, some_comp<MoveOnly>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
#if TEST_STD_VER >= 14
{ // POCS allocator, throwable swap for comp
typedef std::multiset<MoveOnly, some_comp <MoveOnly>, some_alloc <MoveOnly>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // always equal allocator, throwable swap for comp
typedef std::multiset<MoveOnly, some_comp <MoveOnly>, some_alloc2<MoveOnly>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // POCS allocator, nothrow swap for comp
typedef std::multiset<MoveOnly, some_comp2<MoveOnly>, some_alloc <MoveOnly>> C;
C c1, c2;
static_assert( noexcept(swap(c1, c2)), "");
static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // always equal allocator, nothrow swap for comp
typedef std::multiset<MoveOnly, some_comp2<MoveOnly>, some_alloc2<MoveOnly>> C;
C c1, c2;
static_assert( noexcept(swap(c1, c2)), "");
static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // NOT always equal allocator, nothrow swap for comp
typedef std::multiset<MoveOnly, some_comp2<MoveOnly>, some_alloc3<MoveOnly>> C;
C c1, c2;
static_assert( noexcept(swap(c1, c2)), "");
LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
#endif
}

View File

@ -22,6 +22,7 @@
// This tests a conforming extension
#include <set>
#include <utility>
#include <cassert>
#include "test_macros.h"
@ -95,51 +96,42 @@ int main()
{
{
typedef std::set<MoveOnly> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{
typedef std::set<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{
typedef std::set<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{
typedef std::set<MoveOnly, some_comp<MoveOnly>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
#if TEST_STD_VER >= 14
{ // POCS allocator, throwable swap for comp
typedef std::set<MoveOnly, some_comp <MoveOnly>, some_alloc <MoveOnly>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // always equal allocator, throwable swap for comp
typedef std::set<MoveOnly, some_comp <MoveOnly>, some_alloc2<MoveOnly>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // POCS allocator, nothrow swap for comp
typedef std::set<MoveOnly, some_comp2<MoveOnly>, some_alloc <MoveOnly>> C;
C c1, c2;
static_assert( noexcept(swap(c1, c2)), "");
static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // always equal allocator, nothrow swap for comp
typedef std::set<MoveOnly, some_comp2<MoveOnly>, some_alloc2<MoveOnly>> C;
C c1, c2;
static_assert( noexcept(swap(c1, c2)), "");
static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // NOT always equal allocator, nothrow swap for comp
typedef std::set<MoveOnly, some_comp2<MoveOnly>, some_alloc3<MoveOnly>> C;
C c1, c2;
static_assert( noexcept(swap(c1, c2)), "");
LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
#endif

View File

@ -18,6 +18,7 @@
// UNSUPPORTED: c++98, c++03
#include <queue>
#include <utility>
#include <cassert>
#include "MoveOnly.h"
@ -26,7 +27,6 @@ int main()
{
{
typedef std::priority_queue<MoveOnly> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
}

View File

@ -17,6 +17,7 @@
// UNSUPPORTED: c++98, c++03
#include <queue>
#include <utility>
#include <cassert>
#include "MoveOnly.h"
@ -25,7 +26,6 @@ int main()
{
{
typedef std::queue<MoveOnly> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
}

View File

@ -17,6 +17,7 @@
// UNSUPPORTED: c++98, c++03
#include <stack>
#include <utility>
#include <cassert>
#include "MoveOnly.h"
@ -25,7 +26,6 @@ int main()
{
{
typedef std::stack<MoveOnly> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
}

View File

@ -21,6 +21,7 @@
// This tests a conforming extension
#include <deque>
#include <utility>
#include <cassert>
#include "test_macros.h"
@ -56,35 +57,30 @@ int main()
{
{
typedef std::deque<MoveOnly> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{
typedef std::deque<MoveOnly, test_allocator<MoveOnly>> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{
typedef std::deque<MoveOnly, other_allocator<MoveOnly>> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{
typedef std::deque<MoveOnly, some_alloc<MoveOnly>> 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::deque<MoveOnly, some_alloc2<MoveOnly>> 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

View File

@ -21,6 +21,7 @@
// This tests a conforming extension
#include <forward_list>
#include <utility>
#include <cassert>
#include "test_macros.h"
@ -56,35 +57,30 @@ int main()
{
{
typedef std::forward_list<MoveOnly> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{
typedef std::forward_list<MoveOnly, test_allocator<MoveOnly>> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{
typedef std::forward_list<MoveOnly, other_allocator<MoveOnly>> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{
typedef std::forward_list<MoveOnly, some_alloc<MoveOnly>> 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::forward_list<MoveOnly, some_alloc2<MoveOnly>> 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
}

View File

@ -21,6 +21,7 @@
// This tests a conforming extension
#include <list>
#include <utility>
#include <cassert>
#include "test_macros.h"
@ -56,35 +57,30 @@ int main()
{
{
typedef std::list<MoveOnly> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{
typedef std::list<MoveOnly, test_allocator<MoveOnly>> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{
typedef std::list<MoveOnly, other_allocator<MoveOnly>> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{
typedef std::list<MoveOnly, some_alloc<MoveOnly>> 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::list<MoveOnly, some_alloc2<MoveOnly>> 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

View File

@ -22,6 +22,7 @@
// This tests a conforming extension
#include <vector>
#include <utility>
#include <cassert>
#include "test_macros.h"
@ -56,35 +57,30 @@ int main()
{
{
typedef std::vector<bool> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{
typedef std::vector<bool, test_allocator<bool>> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{
typedef std::vector<bool, other_allocator<bool>> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{
typedef std::vector<bool, some_alloc<bool>> 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<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::vector<bool, some_alloc2<bool>> 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<C&>(), std::declval<C&>())), "");
}
#endif
}

View File

@ -22,6 +22,7 @@
// This tests a conforming extension
#include <vector>
#include <utility>
#include <cassert>
#include "test_macros.h"
@ -57,35 +58,30 @@ int main()
{
{
typedef std::vector<MoveOnly> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{
typedef std::vector<MoveOnly, test_allocator<MoveOnly>> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{
typedef std::vector<MoveOnly, other_allocator<MoveOnly>> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{
typedef std::vector<MoveOnly, some_alloc<MoveOnly>> 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::vector<MoveOnly, some_alloc2<MoveOnly>> 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
}

View File

@ -26,6 +26,7 @@
// This tests a conforming extension
#include <unordered_map>
#include <utility>
#include <cassert>
#include "test_macros.h"
@ -122,79 +123,65 @@ int main()
typedef std::pair<const MoveOnly, MoveOnly> MapType;
{
typedef std::unordered_map<MoveOnly, MoveOnly> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{
typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
std::equal_to<MoveOnly>, test_allocator<MapType>> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{
typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
std::equal_to<MoveOnly>, other_allocator<MapType>> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{
typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{
typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
some_comp<MoveOnly>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
#if TEST_STD_VER >= 14
{ // POCS allocator, throwable swap for hash, throwable swap for comp
typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>, some_comp <MoveOnly>, some_alloc <MapType>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // always equal allocator, throwable swap for hash, throwable swap for comp
typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>, some_comp <MoveOnly>, some_alloc2<MapType>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // POCS allocator, throwable swap for hash, nothrow swap for comp
typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>, some_comp2<MoveOnly>, some_alloc <MapType>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // always equal allocator, throwable swap for hash, nothrow swap for comp
typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>, some_comp2<MoveOnly>, some_alloc2<MapType>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // POCS allocator, nothrow swap for hash, throwable swap for comp
typedef std::unordered_map<MoveOnly, MoveOnly, some_hash2<MoveOnly>, some_comp <MoveOnly>, some_alloc <MapType>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // always equal allocator, nothrow swap for hash, throwable swap for comp
typedef std::unordered_map<MoveOnly, MoveOnly, some_hash2<MoveOnly>, some_comp <MoveOnly>, some_alloc2<MapType>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // POCS allocator, nothrow swap for hash, nothrow swap for comp
typedef std::unordered_map<MoveOnly, MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc <MapType>> C;
C c1, c2;
static_assert( noexcept(swap(c1, c2)), "");
static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // always equal allocator, nothrow swap for hash, nothrow swap for comp
typedef std::unordered_map<MoveOnly, MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc2<MapType>> C;
C c1, c2;
static_assert( noexcept(swap(c1, c2)), "");
static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // NOT always equal allocator, nothrow swap for hash, nothrow swap for comp
typedef std::unordered_map<MoveOnly, MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc3<MapType>> C;
C c1, c2;
static_assert( noexcept(swap(c1, c2)), "");
LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
#endif
}

View File

@ -26,6 +26,7 @@
// This tests a conforming extension
#include <unordered_map>
#include <utility>
#include <cassert>
#include "test_macros.h"
@ -121,78 +122,64 @@ int main()
typedef std::pair<const MoveOnly, MoveOnly> V;
{
typedef std::unordered_multimap<MoveOnly, MoveOnly> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{
typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
std::equal_to<MoveOnly>, test_allocator<V>> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{
typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
std::equal_to<MoveOnly>, other_allocator<V>> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{
typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{
typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
some_comp<MoveOnly>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
#if TEST_STD_VER >= 14
{ // POCS allocator, throwable swap for hash, throwable swap for comp
typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>, some_comp <MoveOnly>, some_alloc <V>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // always equal allocator, throwable swap for hash, throwable swap for comp
typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>, some_comp <MoveOnly>, some_alloc2<V>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // POCS allocator, throwable swap for hash, nothrow swap for comp
typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>, some_comp2<MoveOnly>, some_alloc <V>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // always equal allocator, throwable swap for hash, nothrow swap for comp
typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>, some_comp2<MoveOnly>, some_alloc2<V>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // POCS allocator, nothrow swap for hash, throwable swap for comp
typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash2<MoveOnly>, some_comp <MoveOnly>, some_alloc <V>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // always equal allocator, nothrow swap for hash, throwable swap for comp
typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash2<MoveOnly>, some_comp <MoveOnly>, some_alloc2<V>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // POCS allocator, nothrow swap for hash, nothrow swap for comp
typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc <V>> C;
C c1, c2;
static_assert( noexcept(swap(c1, c2)), "");
static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // always equal allocator, nothrow swap for hash, nothrow swap for comp
typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc2<V>> C;
C c1, c2;
static_assert( noexcept(swap(c1, c2)), "");
static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // NOT always equal allocator, nothrow swap for hash, nothrow swap for comp
typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc3<V>> C;
C c1, c2;
static_assert( noexcept(swap(c1, c2)), "");
LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
#endif
}

View File

@ -26,6 +26,7 @@
// This tests a conforming extension
#include <unordered_set>
#include <utility>
#include <cassert>
#include "test_macros.h"
@ -122,79 +123,65 @@ int main()
{
{
typedef std::unordered_multiset<MoveOnly> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{
typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{
typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{
typedef std::unordered_multiset<MoveOnly, some_hash<MoveOnly>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{
typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
some_comp<MoveOnly>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
#if TEST_STD_VER >= 14
{ // POCS allocator, throwable swap for hash, throwable swap for comp
typedef std::unordered_multiset<MoveOnly, some_hash<MoveOnly>, some_comp <MoveOnly>, some_alloc <MoveOnly>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // always equal allocator, throwable swap for hash, throwable swap for comp
typedef std::unordered_multiset<MoveOnly, some_hash<MoveOnly>, some_comp <MoveOnly>, some_alloc2<MoveOnly>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // POCS allocator, throwable swap for hash, nothrow swap for comp
typedef std::unordered_multiset<MoveOnly, some_hash<MoveOnly>, some_comp2<MoveOnly>, some_alloc <MoveOnly>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // always equal allocator, throwable swap for hash, nothrow swap for comp
typedef std::unordered_multiset<MoveOnly, some_hash<MoveOnly>, some_comp2<MoveOnly>, some_alloc2<MoveOnly>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // POCS allocator, nothrow swap for hash, throwable swap for comp
typedef std::unordered_multiset<MoveOnly, some_hash2<MoveOnly>, some_comp <MoveOnly>, some_alloc <MoveOnly>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // always equal allocator, nothrow swap for hash, throwable swap for comp
typedef std::unordered_multiset<MoveOnly, some_hash2<MoveOnly>, some_comp <MoveOnly>, some_alloc2<MoveOnly>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // POCS allocator, nothrow swap for hash, nothrow swap for comp
typedef std::unordered_multiset<MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc <MoveOnly>> C;
C c1, c2;
static_assert( noexcept(swap(c1, c2)), "");
static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // always equal allocator, nothrow swap for hash, nothrow swap for comp
typedef std::unordered_multiset<MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc2<MoveOnly>> C;
C c1, c2;
static_assert( noexcept(swap(c1, c2)), "");
static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // NOT always equal allocator, nothrow swap for hash, nothrow swap for comp
typedef std::unordered_multiset<MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc3<MoveOnly>> C;
C c1, c2;
static_assert( noexcept(swap(c1, c2)), "");
LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
#endif
}

View File

@ -26,6 +26,7 @@
// This tests a conforming extension
#include <unordered_set>
#include <utility>
#include <cassert>
#include "test_macros.h"
@ -122,79 +123,65 @@ int main()
{
{
typedef std::unordered_set<MoveOnly> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{
typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{
typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{
typedef std::unordered_set<MoveOnly, some_hash<MoveOnly>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{
typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
some_comp<MoveOnly>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
#if TEST_STD_VER >= 14
{ // POCS allocator, throwable swap for hash, throwable swap for comp
typedef std::unordered_set<MoveOnly, some_hash<MoveOnly>, some_comp <MoveOnly>, some_alloc <MoveOnly>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // always equal allocator, throwable swap for hash, throwable swap for comp
typedef std::unordered_set<MoveOnly, some_hash<MoveOnly>, some_comp <MoveOnly>, some_alloc2<MoveOnly>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // POCS allocator, throwable swap for hash, nothrow swap for comp
typedef std::unordered_set<MoveOnly, some_hash<MoveOnly>, some_comp2<MoveOnly>, some_alloc <MoveOnly>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // always equal allocator, throwable swap for hash, nothrow swap for comp
typedef std::unordered_set<MoveOnly, some_hash<MoveOnly>, some_comp2<MoveOnly>, some_alloc2<MoveOnly>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // POCS allocator, nothrow swap for hash, throwable swap for comp
typedef std::unordered_set<MoveOnly, some_hash2<MoveOnly>, some_comp <MoveOnly>, some_alloc <MoveOnly>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // always equal allocator, nothrow swap for hash, throwable swap for comp
typedef std::unordered_set<MoveOnly, some_hash2<MoveOnly>, some_comp <MoveOnly>, some_alloc2<MoveOnly>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // POCS allocator, nothrow swap for hash, nothrow swap for comp
typedef std::unordered_set<MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc <MoveOnly>> C;
C c1, c2;
static_assert( noexcept(swap(c1, c2)), "");
static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // always equal allocator, nothrow swap for hash, nothrow swap for comp
typedef std::unordered_set<MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc2<MoveOnly>> C;
C c1, c2;
static_assert( noexcept(swap(c1, c2)), "");
static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
{ // NOT always equal allocator, nothrow swap for hash, nothrow swap for comp
typedef std::unordered_set<MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc3<MoveOnly>> C;
C c1, c2;
static_assert( noexcept(swap(c1, c2)), "");
LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
#endif
}

View File

@ -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
}