Make move_noexcept.pass.cpp tests more portable. Patch from STL@microsoft.com

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@276581 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2016-07-24 23:19:51 +00:00
parent 7ee04dd6f2
commit a29e0e5ba2
14 changed files with 53 additions and 39 deletions

View File

@@ -20,6 +20,7 @@
#include <map> #include <map>
#include <cassert> #include <cassert>
#include "test_macros.h"
#include "MoveOnly.h" #include "MoveOnly.h"
#include "test_allocator.h" #include "test_allocator.h"
@@ -36,15 +37,15 @@ int main()
typedef std::pair<const MoveOnly, MoveOnly> V; typedef std::pair<const MoveOnly, MoveOnly> V;
{ {
typedef std::map<MoveOnly, MoveOnly> C; typedef std::map<MoveOnly, MoveOnly> C;
static_assert(std::is_nothrow_move_constructible<C>::value, ""); LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, "");
} }
{ {
typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<V>> C; typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<V>> C;
static_assert(std::is_nothrow_move_constructible<C>::value, ""); LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, "");
} }
{ {
typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<V>> C; typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<V>> C;
static_assert(std::is_nothrow_move_constructible<C>::value, ""); LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, "");
} }
{ {
typedef std::map<MoveOnly, MoveOnly, some_comp<MoveOnly>> C; typedef std::map<MoveOnly, MoveOnly, some_comp<MoveOnly>> C;

View File

@@ -20,6 +20,7 @@
#include <map> #include <map>
#include <cassert> #include <cassert>
#include "test_macros.h"
#include "MoveOnly.h" #include "MoveOnly.h"
#include "test_allocator.h" #include "test_allocator.h"
@@ -36,15 +37,15 @@ int main()
typedef std::pair<const MoveOnly, MoveOnly> V; typedef std::pair<const MoveOnly, MoveOnly> V;
{ {
typedef std::multimap<MoveOnly, MoveOnly> C; typedef std::multimap<MoveOnly, MoveOnly> C;
static_assert(std::is_nothrow_move_constructible<C>::value, ""); LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, "");
} }
{ {
typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<V>> C; typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<V>> C;
static_assert(std::is_nothrow_move_constructible<C>::value, ""); LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, "");
} }
{ {
typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<V>> C; typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<V>> C;
static_assert(std::is_nothrow_move_constructible<C>::value, ""); LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, "");
} }
{ {
typedef std::multimap<MoveOnly, MoveOnly, some_comp<MoveOnly>> C; typedef std::multimap<MoveOnly, MoveOnly, some_comp<MoveOnly>> C;

View File

@@ -20,6 +20,7 @@
#include <set> #include <set>
#include <cassert> #include <cassert>
#include "test_macros.h"
#include "MoveOnly.h" #include "MoveOnly.h"
#include "test_allocator.h" #include "test_allocator.h"
@@ -35,15 +36,15 @@ int main()
{ {
{ {
typedef std::multiset<MoveOnly> C; typedef std::multiset<MoveOnly> C;
static_assert(std::is_nothrow_move_constructible<C>::value, ""); LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, "");
} }
{ {
typedef std::multiset<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C; typedef std::multiset<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
static_assert(std::is_nothrow_move_constructible<C>::value, ""); LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, "");
} }
{ {
typedef std::multiset<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C; typedef std::multiset<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
static_assert(std::is_nothrow_move_constructible<C>::value, ""); LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, "");
} }
{ {
typedef std::multiset<MoveOnly, some_comp<MoveOnly>> C; typedef std::multiset<MoveOnly, some_comp<MoveOnly>> C;

View File

@@ -20,6 +20,7 @@
#include <set> #include <set>
#include <cassert> #include <cassert>
#include "test_macros.h"
#include "MoveOnly.h" #include "MoveOnly.h"
#include "test_allocator.h" #include "test_allocator.h"
@@ -35,15 +36,15 @@ int main()
{ {
{ {
typedef std::set<MoveOnly> C; typedef std::set<MoveOnly> C;
static_assert(std::is_nothrow_move_constructible<C>::value, ""); LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, "");
} }
{ {
typedef std::set<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C; typedef std::set<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
static_assert(std::is_nothrow_move_constructible<C>::value, ""); LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, "");
} }
{ {
typedef std::set<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C; typedef std::set<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
static_assert(std::is_nothrow_move_constructible<C>::value, ""); LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, "");
} }
{ {
typedef std::set<MoveOnly, some_comp<MoveOnly>> C; typedef std::set<MoveOnly, some_comp<MoveOnly>> C;

View File

@@ -19,12 +19,13 @@
#include <queue> #include <queue>
#include <cassert> #include <cassert>
#include "test_macros.h"
#include "MoveOnly.h" #include "MoveOnly.h"
int main() int main()
{ {
{ {
typedef std::queue<MoveOnly> C; typedef std::queue<MoveOnly> C;
static_assert(std::is_nothrow_move_constructible<C>::value, ""); LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, "");
} }
} }

View File

@@ -19,12 +19,13 @@
#include <stack> #include <stack>
#include <cassert> #include <cassert>
#include "test_macros.h"
#include "MoveOnly.h" #include "MoveOnly.h"
int main() int main()
{ {
{ {
typedef std::stack<MoveOnly> C; typedef std::stack<MoveOnly> C;
static_assert(std::is_nothrow_move_constructible<C>::value, ""); LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, "");
} }
} }

View File

@@ -19,6 +19,7 @@
#include <deque> #include <deque>
#include <cassert> #include <cassert>
#include "test_macros.h"
#include "MoveOnly.h" #include "MoveOnly.h"
#include "test_allocator.h" #include "test_allocator.h"
@@ -33,15 +34,15 @@ int main()
{ {
{ {
typedef std::deque<MoveOnly> C; typedef std::deque<MoveOnly> C;
static_assert(std::is_nothrow_move_constructible<C>::value, ""); LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, "");
} }
{ {
typedef std::deque<MoveOnly, test_allocator<MoveOnly>> C; typedef std::deque<MoveOnly, test_allocator<MoveOnly>> C;
static_assert(std::is_nothrow_move_constructible<C>::value, ""); LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, "");
} }
{ {
typedef std::deque<MoveOnly, other_allocator<MoveOnly>> C; typedef std::deque<MoveOnly, other_allocator<MoveOnly>> C;
static_assert(std::is_nothrow_move_constructible<C>::value, ""); LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, "");
} }
{ {
typedef std::deque<MoveOnly, some_alloc<MoveOnly>> C; typedef std::deque<MoveOnly, some_alloc<MoveOnly>> C;

View File

@@ -19,6 +19,7 @@
#include <forward_list> #include <forward_list>
#include <cassert> #include <cassert>
#include "test_macros.h"
#include "MoveOnly.h" #include "MoveOnly.h"
#include "test_allocator.h" #include "test_allocator.h"
@@ -33,15 +34,15 @@ int main()
{ {
{ {
typedef std::forward_list<MoveOnly> C; typedef std::forward_list<MoveOnly> C;
static_assert(std::is_nothrow_move_constructible<C>::value, ""); LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, "");
} }
{ {
typedef std::forward_list<MoveOnly, test_allocator<MoveOnly>> C; typedef std::forward_list<MoveOnly, test_allocator<MoveOnly>> C;
static_assert(std::is_nothrow_move_constructible<C>::value, ""); LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, "");
} }
{ {
typedef std::forward_list<MoveOnly, other_allocator<MoveOnly>> C; typedef std::forward_list<MoveOnly, other_allocator<MoveOnly>> C;
static_assert(std::is_nothrow_move_constructible<C>::value, ""); LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, "");
} }
{ {
typedef std::forward_list<MoveOnly, some_alloc<MoveOnly>> C; typedef std::forward_list<MoveOnly, some_alloc<MoveOnly>> C;

View File

@@ -19,6 +19,7 @@
#include <list> #include <list>
#include <cassert> #include <cassert>
#include "test_macros.h"
#include "MoveOnly.h" #include "MoveOnly.h"
#include "test_allocator.h" #include "test_allocator.h"
@@ -33,15 +34,15 @@ int main()
{ {
{ {
typedef std::list<MoveOnly> C; typedef std::list<MoveOnly> C;
static_assert(std::is_nothrow_move_constructible<C>::value, ""); LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, "");
} }
{ {
typedef std::list<MoveOnly, test_allocator<MoveOnly>> C; typedef std::list<MoveOnly, test_allocator<MoveOnly>> C;
static_assert(std::is_nothrow_move_constructible<C>::value, ""); LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, "");
} }
{ {
typedef std::list<MoveOnly, other_allocator<MoveOnly>> C; typedef std::list<MoveOnly, other_allocator<MoveOnly>> C;
static_assert(std::is_nothrow_move_constructible<C>::value, ""); LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, "");
} }
{ {
typedef std::list<MoveOnly, some_alloc<MoveOnly>> C; typedef std::list<MoveOnly, some_alloc<MoveOnly>> C;

View File

@@ -19,6 +19,7 @@
#include <vector> #include <vector>
#include <cassert> #include <cassert>
#include "test_macros.h"
#include "test_allocator.h" #include "test_allocator.h"
template <class T> template <class T>
@@ -32,21 +33,21 @@ int main()
{ {
{ {
typedef std::vector<bool> C; typedef std::vector<bool> C;
static_assert(std::is_nothrow_move_constructible<C>::value, ""); LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, "");
} }
{ {
typedef std::vector<bool, test_allocator<bool>> C; typedef std::vector<bool, test_allocator<bool>> C;
static_assert(std::is_nothrow_move_constructible<C>::value, ""); LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, "");
} }
{ {
typedef std::vector<bool, other_allocator<bool>> C; typedef std::vector<bool, other_allocator<bool>> C;
static_assert(std::is_nothrow_move_constructible<C>::value, ""); LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, "");
} }
{ {
typedef std::vector<bool, some_alloc<bool>> C; typedef std::vector<bool, some_alloc<bool>> C;
// In C++17, move constructors for allocators are not allowed to throw // In C++17, move constructors for allocators are not allowed to throw
#if TEST_STD_VER > 14 #if TEST_STD_VER > 14
static_assert( std::is_nothrow_move_constructible<C>::value, ""); LIBCPP_STATIC_ASSERT( std::is_nothrow_move_constructible<C>::value, "");
#else #else
static_assert(!std::is_nothrow_move_constructible<C>::value, ""); static_assert(!std::is_nothrow_move_constructible<C>::value, "");
#endif #endif

View File

@@ -20,6 +20,7 @@
#include <unordered_map> #include <unordered_map>
#include <cassert> #include <cassert>
#include "test_macros.h"
#include "MoveOnly.h" #include "MoveOnly.h"
#include "test_allocator.h" #include "test_allocator.h"
@@ -43,17 +44,17 @@ int main()
{ {
{ {
typedef std::unordered_map<MoveOnly, MoveOnly> C; typedef std::unordered_map<MoveOnly, MoveOnly> C;
static_assert(std::is_nothrow_move_constructible<C>::value, ""); LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, "");
} }
{ {
typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>, typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C; std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
static_assert(std::is_nothrow_move_constructible<C>::value, ""); LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, "");
} }
{ {
typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>, typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C; std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
static_assert(std::is_nothrow_move_constructible<C>::value, ""); LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, "");
} }
{ {
typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>> C; typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;

View File

@@ -20,6 +20,7 @@
#include <unordered_map> #include <unordered_map>
#include <cassert> #include <cassert>
#include "test_macros.h"
#include "MoveOnly.h" #include "MoveOnly.h"
#include "test_allocator.h" #include "test_allocator.h"
@@ -43,17 +44,17 @@ int main()
{ {
{ {
typedef std::unordered_multimap<MoveOnly, MoveOnly> C; typedef std::unordered_multimap<MoveOnly, MoveOnly> C;
static_assert(std::is_nothrow_move_constructible<C>::value, ""); LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, "");
} }
{ {
typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>, typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C; std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
static_assert(std::is_nothrow_move_constructible<C>::value, ""); LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, "");
} }
{ {
typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>, typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C; std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
static_assert(std::is_nothrow_move_constructible<C>::value, ""); LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, "");
} }
{ {
typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>> C; typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;

View File

@@ -20,6 +20,7 @@
#include <unordered_set> #include <unordered_set>
#include <cassert> #include <cassert>
#include "test_macros.h"
#include "MoveOnly.h" #include "MoveOnly.h"
#include "test_allocator.h" #include "test_allocator.h"
@@ -43,17 +44,17 @@ int main()
{ {
{ {
typedef std::unordered_multiset<MoveOnly> C; typedef std::unordered_multiset<MoveOnly> C;
static_assert(std::is_nothrow_move_constructible<C>::value, ""); LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, "");
} }
{ {
typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>, typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C; std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C;
static_assert(std::is_nothrow_move_constructible<C>::value, ""); LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, "");
} }
{ {
typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>, typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C; std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C;
static_assert(std::is_nothrow_move_constructible<C>::value, ""); LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, "");
} }
{ {
typedef std::unordered_multiset<MoveOnly, some_hash<MoveOnly>> C; typedef std::unordered_multiset<MoveOnly, some_hash<MoveOnly>> C;

View File

@@ -20,6 +20,7 @@
#include <unordered_set> #include <unordered_set>
#include <cassert> #include <cassert>
#include "test_macros.h"
#include "MoveOnly.h" #include "MoveOnly.h"
#include "test_allocator.h" #include "test_allocator.h"
@@ -43,17 +44,17 @@ int main()
{ {
{ {
typedef std::unordered_set<MoveOnly> C; typedef std::unordered_set<MoveOnly> C;
static_assert(std::is_nothrow_move_constructible<C>::value, ""); LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, "");
} }
{ {
typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>, typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C; std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C;
static_assert(std::is_nothrow_move_constructible<C>::value, ""); LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, "");
} }
{ {
typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>, typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C; std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C;
static_assert(std::is_nothrow_move_constructible<C>::value, ""); LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, "");
} }
{ {
typedef std::unordered_set<MoveOnly, some_hash<MoveOnly>> C; typedef std::unordered_set<MoveOnly, some_hash<MoveOnly>> C;