aboutsummaryrefslogtreecommitdiff
path: root/test/std/containers/sequences/vector
diff options
context:
space:
mode:
Diffstat (limited to 'test/std/containers/sequences/vector')
-rw-r--r--test/std/containers/sequences/vector/contiguous.pass.cpp2
-rw-r--r--test/std/containers/sequences/vector/iterators.pass.cpp3
-rw-r--r--test/std/containers/sequences/vector/vector.capacity/max_size.pass.cpp48
-rw-r--r--test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp5
-rw-r--r--test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp8
-rw-r--r--test/std/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp5
-rw-r--r--test/std/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp6
-rw-r--r--test/std/containers/sequences/vector/vector.cons/construct_default.pass.cpp4
-rw-r--r--test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp16
-rw-r--r--test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp8
-rw-r--r--test/std/containers/sequences/vector/vector.cons/construct_size.pass.cpp3
-rw-r--r--test/std/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp5
-rw-r--r--test/std/containers/sequences/vector/vector.cons/copy.pass.cpp2
-rw-r--r--test/std/containers/sequences/vector/vector.cons/copy_alloc.pass.cpp2
-rw-r--r--test/std/containers/sequences/vector/vector.cons/dtor_noexcept.pass.cpp3
-rw-r--r--test/std/containers/sequences/vector/vector.data/data.pass.cpp2
-rw-r--r--test/std/containers/sequences/vector/vector.data/data_const.pass.cpp2
-rw-r--r--test/std/containers/sequences/vector/vector.modifiers/emplace.pass.cpp38
-rw-r--r--test/std/containers/sequences/vector/vector.modifiers/emplace_back.pass.cpp34
-rw-r--r--test/std/containers/sequences/vector/vector.modifiers/erase_iter_db1.pass.cpp51
-rw-r--r--test/std/containers/sequences/vector/vector.modifiers/erase_iter_db2.pass.cpp53
-rw-r--r--test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db1.pass.cpp51
-rw-r--r--test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db2.pass.cpp51
-rw-r--r--test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db3.pass.cpp51
-rw-r--r--test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db4.pass.cpp49
-rw-r--r--test/std/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp55
-rw-r--r--test/std/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp34
-rw-r--r--test/std/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp33
-rw-r--r--test/std/containers/sequences/vector/vector.modifiers/insert_iter_value.pass.cpp35
-rw-r--r--test/std/containers/sequences/vector/vector.modifiers/pop_back.pass.cpp22
-rw-r--r--test/std/containers/sequences/vector/vector.modifiers/push_back.pass.cpp38
-rw-r--r--test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp14
-rw-r--r--test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp38
-rw-r--r--test/std/containers/sequences/vector/vector.special/db_swap_1.pass.cpp56
-rw-r--r--test/std/containers/sequences/vector/vector.special/swap.pass.cpp14
-rw-r--r--test/std/containers/sequences/vector/vector.special/swap_noexcept.pass.cpp18
36 files changed, 222 insertions, 637 deletions
diff --git a/test/std/containers/sequences/vector/contiguous.pass.cpp b/test/std/containers/sequences/vector/contiguous.pass.cpp
index 70084246eae9..9dfcf7a63e49 100644
--- a/test/std/containers/sequences/vector/contiguous.pass.cpp
+++ b/test/std/containers/sequences/vector/contiguous.pass.cpp
@@ -21,7 +21,7 @@ template <class C>
void test_contiguous ( const C &c )
{
for ( size_t i = 0; i < c.size(); ++i )
- assert ( *(c.begin() + i) == *(std::addressof(*c.begin()) + i));
+ assert ( *(c.begin() + static_cast<typename C::difference_type>(i)) == *(std::addressof(*c.begin()) + i));
}
int main()
diff --git a/test/std/containers/sequences/vector/iterators.pass.cpp b/test/std/containers/sequences/vector/iterators.pass.cpp
index 8dc14977f282..a1ce2be32718 100644
--- a/test/std/containers/sequences/vector/iterators.pass.cpp
+++ b/test/std/containers/sequences/vector/iterators.pass.cpp
@@ -20,6 +20,7 @@
#include <cassert>
#include <iterator>
+#include "test_macros.h"
#include "min_allocator.h"
struct A
@@ -135,7 +136,7 @@ int main()
assert(j->first == 3);
}
#endif
-#if _LIBCPP_STD_VER > 11
+#if TEST_STD_VER > 11
{ // N3644 testing
typedef std::vector<int> C;
C::iterator ii1{}, ii2{};
diff --git a/test/std/containers/sequences/vector/vector.capacity/max_size.pass.cpp b/test/std/containers/sequences/vector/vector.capacity/max_size.pass.cpp
new file mode 100644
index 000000000000..5f7a6268d55c
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.capacity/max_size.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// size_type max_size() const;
+
+#include <cassert>
+#include <limits>
+#include <type_traits>
+#include <vector>
+
+#include "test_allocator.h"
+#include "test_macros.h"
+
+
+int main() {
+ {
+ typedef limited_allocator<int, 10> A;
+ typedef std::vector<int, A> C;
+ C c;
+ assert(c.max_size() <= 10);
+ LIBCPP_ASSERT(c.max_size() == 10);
+ }
+ {
+ typedef limited_allocator<int, (size_t)-1> A;
+ typedef std::vector<int, A> C;
+ const C::difference_type max_dist =
+ std::numeric_limits<C::difference_type>::max();
+ C c;
+ assert(c.max_size() <= max_dist);
+ LIBCPP_ASSERT(c.max_size() == max_dist);
+ }
+ {
+ typedef std::vector<char> C;
+ const C::difference_type max_dist =
+ std::numeric_limits<C::difference_type>::max();
+ C c;
+ assert(c.max_size() <= max_dist);
+ assert(c.max_size() <= alloc_max_size(c.get_allocator()));
+ }
+}
diff --git a/test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp b/test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp
index d04e43db508d..abaa709d4ea2 100644
--- a/test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp
+++ b/test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp
@@ -13,7 +13,7 @@
#include <vector>
#include <cassert>
-#include "../../../stack_allocator.h"
+#include "test_allocator.h"
#include "min_allocator.h"
#include "asan_testing.h"
@@ -37,7 +37,8 @@ int main()
assert(is_contiguous_container_asan_correct(v));
}
{
- std::vector<int, stack_allocator<int, 250> > v(100);
+ // Add 1 for implementations that dynamically allocate a container proxy.
+ std::vector<int, limited_allocator<int, 250 + 1> > v(100);
assert(v.capacity() == 100);
v.reserve(50);
assert(v.size() == 100);
diff --git a/test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp b/test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp
index ce74cf9b7c23..6409acaf65c1 100644
--- a/test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp
+++ b/test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp
@@ -13,7 +13,7 @@
#include <vector>
#include <cassert>
-#include "../../../stack_allocator.h"
+#include "test_allocator.h"
#include "MoveOnly.h"
#include "min_allocator.h"
#include "asan_testing.h"
@@ -33,7 +33,8 @@ int main()
assert(is_contiguous_container_asan_correct(v));
}
{
- std::vector<MoveOnly, stack_allocator<MoveOnly, 300> > v(100);
+ // Add 1 for implementations that dynamically allocate a container proxy.
+ std::vector<MoveOnly, limited_allocator<MoveOnly, 300 + 1> > v(100);
v.resize(50);
assert(v.size() == 50);
assert(v.capacity() == 100);
@@ -56,7 +57,8 @@ int main()
assert(is_contiguous_container_asan_correct(v));
}
{
- std::vector<int, stack_allocator<int, 300> > v(100);
+ // Add 1 for implementations that dynamically allocate a container proxy.
+ std::vector<int, limited_allocator<int, 300 + 1> > v(100);
v.resize(50);
assert(v.size() == 50);
assert(v.capacity() == 100);
diff --git a/test/std/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp b/test/std/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp
index 3e7df312731f..0bb909710bc9 100644
--- a/test/std/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp
+++ b/test/std/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp
@@ -13,7 +13,7 @@
#include <vector>
#include <cassert>
-#include "../../../stack_allocator.h"
+#include "test_allocator.h"
#include "min_allocator.h"
#include "asan_testing.h"
@@ -35,7 +35,8 @@ int main()
assert(v[i] == 1);
}
{
- std::vector<int, stack_allocator<int, 300> > v(100);
+ // Add 1 for implementations that dynamically allocate a container proxy.
+ std::vector<int, limited_allocator<int, 300 + 1> > v(100);
v.resize(50, 1);
assert(v.size() == 50);
assert(v.capacity() == 100);
diff --git a/test/std/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp b/test/std/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp
index 10ce33f43bd2..daf9b092f493 100644
--- a/test/std/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp
+++ b/test/std/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp
@@ -13,7 +13,7 @@
#include <vector>
#include <cassert>
-#include "../../../stack_allocator.h"
+#include "test_allocator.h"
#include "min_allocator.h"
#include "asan_testing.h"
@@ -29,7 +29,7 @@ int main()
assert(is_contiguous_container_asan_correct(v));
}
{
- std::vector<int, stack_allocator<int, 401> > v(100);
+ std::vector<int, limited_allocator<int, 401> > v(100);
v.push_back(1);
assert(is_contiguous_container_asan_correct(v));
v.shrink_to_fit();
@@ -39,7 +39,7 @@ int main()
}
#ifndef _LIBCPP_NO_EXCEPTIONS
{
- std::vector<int, stack_allocator<int, 400> > v(100);
+ std::vector<int, limited_allocator<int, 400> > v(100);
v.push_back(1);
assert(is_contiguous_container_asan_correct(v));
v.shrink_to_fit();
diff --git a/test/std/containers/sequences/vector/vector.cons/construct_default.pass.cpp b/test/std/containers/sequences/vector/vector.cons/construct_default.pass.cpp
index 4e6eb00cebb8..edeae04d7bd7 100644
--- a/test/std/containers/sequences/vector/vector.cons/construct_default.pass.cpp
+++ b/test/std/containers/sequences/vector/vector.cons/construct_default.pass.cpp
@@ -18,7 +18,7 @@
#include "test_macros.h"
#include "test_allocator.h"
#include "../../../NotConstructible.h"
-#include "../../../stack_allocator.h"
+#include "test_allocator.h"
#include "min_allocator.h"
#include "asan_testing.h"
@@ -71,7 +71,7 @@ int main()
(test_allocator<NotConstructible>(5));
}
{
- std::vector<int, stack_allocator<int, 10> > v;
+ std::vector<int, limited_allocator<int, 10> > v;
assert(v.empty());
}
#if TEST_STD_VER >= 11
diff --git a/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp b/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
index 5542e91059d6..ec4944d1ad1c 100644
--- a/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
+++ b/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
@@ -13,10 +13,11 @@
#include <vector>
#include <cassert>
+#include <cstddef>
#include "test_macros.h"
#include "test_iterators.h"
-#include "../../../stack_allocator.h"
+#include "test_allocator.h"
#include "min_allocator.h"
#include "asan_testing.h"
@@ -26,7 +27,7 @@ test(Iterator first, Iterator last)
{
C c(first, last);
LIBCPP_ASSERT(c.__invariants());
- assert(c.size() == std::distance(first, last));
+ assert(c.size() == static_cast<std::size_t>(std::distance(first, last)));
LIBCPP_ASSERT(is_contiguous_container_asan_correct(c));
for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i, ++first)
assert(*i == *first);
@@ -42,11 +43,12 @@ int main()
test<std::vector<int> >(random_access_iterator<const int*>(a), random_access_iterator<const int*>(an));
test<std::vector<int> >(a, an);
- test<std::vector<int, stack_allocator<int, 63> > >(input_iterator<const int*>(a), input_iterator<const int*>(an));
- test<std::vector<int, stack_allocator<int, 18> > >(forward_iterator<const int*>(a), forward_iterator<const int*>(an));
- test<std::vector<int, stack_allocator<int, 18> > >(bidirectional_iterator<const int*>(a), bidirectional_iterator<const int*>(an));
- test<std::vector<int, stack_allocator<int, 18> > >(random_access_iterator<const int*>(a), random_access_iterator<const int*>(an));
- test<std::vector<int, stack_allocator<int, 18> > >(a, an);
+ test<std::vector<int, limited_allocator<int, 63> > >(input_iterator<const int*>(a), input_iterator<const int*>(an));
+ // Add 1 for implementations that dynamically allocate a container proxy.
+ test<std::vector<int, limited_allocator<int, 18 + 1> > >(forward_iterator<const int*>(a), forward_iterator<const int*>(an));
+ test<std::vector<int, limited_allocator<int, 18 + 1> > >(bidirectional_iterator<const int*>(a), bidirectional_iterator<const int*>(an));
+ test<std::vector<int, limited_allocator<int, 18 + 1> > >(random_access_iterator<const int*>(a), random_access_iterator<const int*>(an));
+ test<std::vector<int, limited_allocator<int, 18 + 1> > >(a, an);
#if TEST_STD_VER >= 11
test<std::vector<int, min_allocator<int>> >(input_iterator<const int*>(a), input_iterator<const int*>(an));
test<std::vector<int, min_allocator<int>> >(forward_iterator<const int*>(a), forward_iterator<const int*>(an));
diff --git a/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp b/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp
index f40088ea3e86..b4482ddb2727 100644
--- a/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp
+++ b/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp
@@ -14,10 +14,11 @@
#include <vector>
#include <cassert>
+#include <cstddef>
#include "test_macros.h"
#include "test_iterators.h"
-#include "../../../stack_allocator.h"
+#include "test_allocator.h"
#include "min_allocator.h"
#include "asan_testing.h"
@@ -27,7 +28,7 @@ test(Iterator first, Iterator last, const A& a)
{
C c(first, last, a);
LIBCPP_ASSERT(c.__invariants());
- assert(c.size() == std::distance(first, last));
+ assert(c.size() == static_cast<std::size_t>(std::distance(first, last)));
LIBCPP_ASSERT(is_contiguous_container_asan_correct(c));
for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i, ++first)
assert(*i == *first);
@@ -40,6 +41,9 @@ struct implicit_conv_allocator : min_allocator<T>
{
implicit_conv_allocator(void*) {}
implicit_conv_allocator(const implicit_conv_allocator&) = default;
+
+ template <class U>
+ implicit_conv_allocator(implicit_conv_allocator<U>) {}
};
#endif
diff --git a/test/std/containers/sequences/vector/vector.cons/construct_size.pass.cpp b/test/std/containers/sequences/vector/vector.cons/construct_size.pass.cpp
index 46e5ecdc9a56..7416a6ac9d7b 100644
--- a/test/std/containers/sequences/vector/vector.cons/construct_size.pass.cpp
+++ b/test/std/containers/sequences/vector/vector.cons/construct_size.pass.cpp
@@ -32,6 +32,9 @@ test2(typename C::size_type n, typename C::allocator_type const& a = typename C:
LIBCPP_ASSERT(is_contiguous_container_asan_correct(c));
for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i)
assert(*i == typename C::value_type());
+#else
+ ((void)n);
+ ((void)a);
#endif
}
diff --git a/test/std/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp b/test/std/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp
index d3774d1a6595..dcaaa2cd4a30 100644
--- a/test/std/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp
+++ b/test/std/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp
@@ -15,7 +15,7 @@
#include <cassert>
#include "test_macros.h"
-#include "../../../stack_allocator.h"
+#include "test_allocator.h"
#include "min_allocator.h"
#include "asan_testing.h"
@@ -34,7 +34,8 @@ test(typename C::size_type n, const typename C::value_type& x)
int main()
{
test<std::vector<int> >(50, 3);
- test<std::vector<int, stack_allocator<int, 50> > >(50, 5);
+ // Add 1 for implementations that dynamically allocate a container proxy.
+ test<std::vector<int, limited_allocator<int, 50 + 1> > >(50, 5);
#if TEST_STD_VER >= 11
test<std::vector<int, min_allocator<int>> >(50, 3);
#endif
diff --git a/test/std/containers/sequences/vector/vector.cons/copy.pass.cpp b/test/std/containers/sequences/vector/vector.cons/copy.pass.cpp
index 105217bbf15c..887444c81959 100644
--- a/test/std/containers/sequences/vector/vector.cons/copy.pass.cpp
+++ b/test/std/containers/sequences/vector/vector.cons/copy.pass.cpp
@@ -23,7 +23,7 @@ template <class C>
void
test(const C& x)
{
- unsigned s = x.size();
+ typename C::size_type s = x.size();
C c(x);
LIBCPP_ASSERT(c.__invariants());
assert(c.size() == s);
diff --git a/test/std/containers/sequences/vector/vector.cons/copy_alloc.pass.cpp b/test/std/containers/sequences/vector/vector.cons/copy_alloc.pass.cpp
index 47259c747332..bf910df05c2a 100644
--- a/test/std/containers/sequences/vector/vector.cons/copy_alloc.pass.cpp
+++ b/test/std/containers/sequences/vector/vector.cons/copy_alloc.pass.cpp
@@ -23,7 +23,7 @@ template <class C>
void
test(const C& x, const typename C::allocator_type& a)
{
- unsigned s = x.size();
+ typename C::size_type s = x.size();
C c(x, a);
LIBCPP_ASSERT(c.__invariants());
assert(c.size() == s);
diff --git a/test/std/containers/sequences/vector/vector.cons/dtor_noexcept.pass.cpp b/test/std/containers/sequences/vector/vector.cons/dtor_noexcept.pass.cpp
index bd538120442d..10a381f9c8cc 100644
--- a/test/std/containers/sequences/vector/vector.cons/dtor_noexcept.pass.cpp
+++ b/test/std/containers/sequences/vector/vector.cons/dtor_noexcept.pass.cpp
@@ -16,6 +16,7 @@
#include <vector>
#include <cassert>
+#include "test_macros.h"
#include "MoveOnly.h"
#include "test_allocator.h"
@@ -43,6 +44,6 @@ int main()
}
{
typedef std::vector<MoveOnly, some_alloc<MoveOnly>> C;
- static_assert(!std::is_nothrow_destructible<C>::value, "");
+ LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible<C>::value, "");
}
}
diff --git a/test/std/containers/sequences/vector/vector.data/data.pass.cpp b/test/std/containers/sequences/vector/vector.data/data.pass.cpp
index f6c0575d958c..b7ea3a286f32 100644
--- a/test/std/containers/sequences/vector/vector.data/data.pass.cpp
+++ b/test/std/containers/sequences/vector/vector.data/data.pass.cpp
@@ -21,7 +21,7 @@ struct Nasty {
Nasty() : i_(0) {}
Nasty(int i) : i_(i) {}
~Nasty() {}
-
+
Nasty * operator&() const { assert(false); return nullptr; }
int i_;
};
diff --git a/test/std/containers/sequences/vector/vector.data/data_const.pass.cpp b/test/std/containers/sequences/vector/vector.data/data_const.pass.cpp
index c97ad29708b8..3c013c1ae8af 100644
--- a/test/std/containers/sequences/vector/vector.data/data_const.pass.cpp
+++ b/test/std/containers/sequences/vector/vector.data/data_const.pass.cpp
@@ -21,7 +21,7 @@ struct Nasty {
Nasty() : i_(0) {}
Nasty(int i) : i_(i) {}
~Nasty() {}
-
+
Nasty * operator&() const { assert(false); return nullptr; }
int i_;
};
diff --git a/test/std/containers/sequences/vector/vector.modifiers/emplace.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/emplace.pass.cpp
index 8bcc23979668..d08f4e3c4e23 100644
--- a/test/std/containers/sequences/vector/vector.modifiers/emplace.pass.cpp
+++ b/test/std/containers/sequences/vector/vector.modifiers/emplace.pass.cpp
@@ -7,22 +7,20 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03
+
// <vector>
// template <class... Args> iterator emplace(const_iterator pos, Args&&... args);
-#if _LIBCPP_DEBUG >= 1
-#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
-#endif
-
#include <vector>
#include <cassert>
-#include "../../../stack_allocator.h"
+
+#include "test_macros.h"
+#include "test_allocator.h"
#include "min_allocator.h"
#include "asan_testing.h"
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
class A
{
int i_;
@@ -55,11 +53,8 @@ public:
double getd() const {return d_;}
};
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
int main()
{
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
std::vector<A> c;
std::vector<A>::iterator i = c.emplace(c.cbegin(), 2, 3.5);
@@ -88,8 +83,8 @@ int main()
assert(is_contiguous_container_asan_correct(c));
}
{
- std::vector<A, stack_allocator<A, 7> > c;
- std::vector<A, stack_allocator<A, 7> >::iterator i = c.emplace(c.cbegin(), 2, 3.5);
+ std::vector<A, limited_allocator<A, 7> > c;
+ std::vector<A, limited_allocator<A, 7> >::iterator i = c.emplace(c.cbegin(), 2, 3.5);
assert(i == c.begin());
assert(c.size() == 1);
assert(c.front().geti() == 2);
@@ -114,15 +109,6 @@ int main()
assert(c.back().getd() == 4.5);
assert(is_contiguous_container_asan_correct(c));
}
-#if _LIBCPP_DEBUG >= 1
- {
- std::vector<A> c1;
- std::vector<A> c2;
- std::vector<A>::iterator i = c1.emplace(c2.cbegin(), 2, 3.5);
- assert(false);
- }
-#endif
-#if TEST_STD_VER >= 11
{
std::vector<A, min_allocator<A>> c;
std::vector<A, min_allocator<A>>::iterator i = c.emplace(c.cbegin(), 2, 3.5);
@@ -147,14 +133,4 @@ int main()
assert(c.back().geti() == 3);
assert(c.back().getd() == 4.5);
}
-#if _LIBCPP_DEBUG >= 1
- {
- std::vector<A, min_allocator<A>> c1;
- std::vector<A, min_allocator<A>> c2;
- std::vector<A, min_allocator<A>>::iterator i = c1.emplace(c2.cbegin(), 2, 3.5);
- assert(false);
- }
-#endif
-#endif
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
diff --git a/test/std/containers/sequences/vector/vector.modifiers/emplace_back.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/emplace_back.pass.cpp
index 61ccade76b02..2fece8c78c78 100644
--- a/test/std/containers/sequences/vector/vector.modifiers/emplace_back.pass.cpp
+++ b/test/std/containers/sequences/vector/vector.modifiers/emplace_back.pass.cpp
@@ -7,19 +7,19 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03
+
// <vector>
-// template <class... Args> void emplace_back(Args&&... args);
+// template <class... Args> reference emplace_back(Args&&... args);
#include <vector>
#include <cassert>
-#include "../../../stack_allocator.h"
+#include "test_allocator.h"
#include "min_allocator.h"
#include "test_allocator.h"
#include "asan_testing.h"
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
class A
{
int i_;
@@ -52,20 +52,19 @@ public:
double getd() const {return d_;}
};
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
int main()
{
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
std::vector<A> c;
- c.emplace_back(2, 3.5);
+ A& r1 = c.emplace_back(2, 3.5);
assert(c.size() == 1);
+ assert(&r1 == &c.back());
assert(c.front().geti() == 2);
assert(c.front().getd() == 3.5);
assert(is_contiguous_container_asan_correct(c));
- c.emplace_back(3, 4.5);
+ A& r2 = c.emplace_back(3, 4.5);
assert(c.size() == 2);
+ assert(&r2 == &c.back());
assert(c.front().geti() == 2);
assert(c.front().getd() == 3.5);
assert(c.back().geti() == 3);
@@ -73,30 +72,33 @@ int main()
assert(is_contiguous_container_asan_correct(c));
}
{
- std::vector<A, stack_allocator<A, 4> > c;
- c.emplace_back(2, 3.5);
+ std::vector<A, limited_allocator<A, 4> > c;
+ A& r1 = c.emplace_back(2, 3.5);
assert(c.size() == 1);
+ assert(&r1 == &c.back());
assert(c.front().geti() == 2);
assert(c.front().getd() == 3.5);
assert(is_contiguous_container_asan_correct(c));
- c.emplace_back(3, 4.5);
+ A& r2 = c.emplace_back(3, 4.5);
assert(c.size() == 2);
+ assert(&r2 == &c.back());
assert(c.front().geti() == 2);
assert(c.front().getd() == 3.5);
assert(c.back().geti() == 3);
assert(c.back().getd() == 4.5);
assert(is_contiguous_container_asan_correct(c));
}
-#if TEST_STD_VER >= 11
{
std::vector<A, min_allocator<A>> c;
- c.emplace_back(2, 3.5);
+ A& r1 = c.emplace_back(2, 3.5);
assert(c.size() == 1);
+ assert(&r1 == &c.back());
assert(c.front().geti() == 2);
assert(c.front().getd() == 3.5);
assert(is_contiguous_container_asan_correct(c));
- c.emplace_back(3, 4.5);
+ A& r2 = c.emplace_back(3, 4.5);
assert(c.size() == 2);
+ assert(&r2 == &c.back());
assert(c.front().geti() == 2);
assert(c.front().getd() == 3.5);
assert(c.back().geti() == 3);
@@ -111,6 +113,4 @@ int main()
assert(c.size() == 2);
assert(is_contiguous_container_asan_correct(c));
}
-#endif
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
diff --git a/test/std/containers/sequences/vector/vector.modifiers/erase_iter_db1.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/erase_iter_db1.pass.cpp
deleted file mode 100644
index b2c22d6ae696..000000000000
--- a/test/std/containers/sequences/vector/vector.modifiers/erase_iter_db1.pass.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// <vector>
-
-// Call erase(const_iterator position) with end()
-
-#if _LIBCPP_DEBUG >= 1
-
-#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
-
-#include <vector>
-#include <cassert>
-#include <cstdlib>
-#include <exception>
-
-#include "min_allocator.h"
-
-int main()
-{
- {
- int a1[] = {1, 2, 3};
- std::vector<int> l1(a1, a1+3);
- std::vector<int>::const_iterator i = l1.end();
- l1.erase(i);
- assert(false);
- }
-#if TEST_STD_VER >= 11
- {
- int a1[] = {1, 2, 3};
- std::vector<int, min_allocator<int>> l1(a1, a1+3);
- std::vector<int, min_allocator<int>>::const_iterator i = l1.end();
- l1.erase(i);
- assert(false);
- }
-#endif
-}
-
-#else
-
-int main()
-{
-}
-
-#endif
diff --git a/test/std/containers/sequences/vector/vector.modifiers/erase_iter_db2.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/erase_iter_db2.pass.cpp
deleted file mode 100644
index da0b6d4a059b..000000000000
--- a/test/std/containers/sequences/vector/vector.modifiers/erase_iter_db2.pass.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// <vector>
-
-// Call erase(const_iterator position) with iterator from another container
-
-#if _LIBCPP_DEBUG >= 1
-
-#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
-
-#include <vector>
-#include <cassert>
-#include <cstdlib>
-#include <exception>
-
-#include "min_allocator.h"
-
-int main()
-{
- {
- int a1[] = {1, 2, 3};
- std::vector<int> l1(a1, a1+3);
- std::vector<int> l2(a1, a1+3);
- std::vector<int>::const_iterator i = l2.begin();
- l1.erase(i);
- assert(false);
- }
-#if TEST_STD_VER >= 11
- {
- int a1[] = {1, 2, 3};
- std::vector<int, min_allocator<int>> l1(a1, a1+3);
- std::vector<int, min_allocator<int>> l2(a1, a1+3);
- std::vector<int, min_allocator<int>>::const_iterator i = l2.begin();
- l1.erase(i);
- assert(false);
- }
-#endif
-}
-
-#else
-
-int main()
-{
-}
-
-#endif
diff --git a/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db1.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db1.pass.cpp
deleted file mode 100644
index 14d3ca803ca3..000000000000
--- a/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db1.pass.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// <vector>
-
-// Call erase(const_iterator first, const_iterator last); with first iterator from another container
-
-#if _LIBCPP_DEBUG >= 1
-
-#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
-
-#include <vector>
-#include <cassert>
-#include <exception>
-#include <cstdlib>
-
-#include "min_allocator.h"
-
-int main()
-{
- {
- int a1[] = {1, 2, 3};
- std::vector<int> l1(a1, a1+3);
- std::vector<int> l2(a1, a1+3);
- std::vector<int>::iterator i = l1.erase(l2.cbegin(), l1.cbegin()+1);
- assert(false);
- }
-#if TEST_STD_VER >= 11
- {
- int a1[] = {1, 2, 3};
- std::vector<int, min_allocator<int>> l1(a1, a1+3);
- std::vector<int, min_allocator<int>> l2(a1, a1+3);
- std::vector<int, min_allocator<int>>::iterator i = l1.erase(l2.cbegin(), l1.cbegin()+1);
- assert(false);
- }
-#endif
-}
-
-#else
-
-int main()
-{
-}
-
-#endif
diff --git a/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db2.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db2.pass.cpp
deleted file mode 100644
index 04c040a8f797..000000000000
--- a/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db2.pass.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// <vector>
-
-// Call erase(const_iterator first, const_iterator last); with second iterator from another container
-
-#if _LIBCPP_DEBUG >= 1
-
-#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
-
-#include <vector>
-#include <cassert>
-#include <exception>
-#include <cstdlib>
-
-#include "min_allocator.h"
-
-int main()
-{
- {
- int a1[] = {1, 2, 3};
- std::vector<int> l1(a1, a1+3);
- std::vector<int> l2(a1, a1+3);
- std::vector<int>::iterator i = l1.erase(l1.cbegin(), l2.cbegin()+1);
- assert(false);
- }
-#if TEST_STD_VER >= 11
- {
- int a1[] = {1, 2, 3};
- std::vector<int, min_allocator<int>> l1(a1, a1+3);
- std::vector<int, min_allocator<int>> l2(a1, a1+3);
- std::vector<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), l2.cbegin()+1);
- assert(false);
- }
-#endif
-}
-
-#else
-
-int main()
-{
-}
-
-#endif
diff --git a/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db3.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db3.pass.cpp
deleted file mode 100644
index ba183a83f0b1..000000000000
--- a/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db3.pass.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// <vector>
-
-// Call erase(const_iterator first, const_iterator last); with both iterators from another container
-
-#if _LIBCPP_DEBUG >= 1
-
-#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
-
-#include <vector>
-#include <cassert>
-#include <exception>
-#include <cstdlib>
-
-#include "min_allocator.h"
-
-int main()
-{
- {
- int a1[] = {1, 2, 3};
- std::vector<int> l1(a1, a1+3);
- std::vector<int> l2(a1, a1+3);
- std::vector<int>::iterator i = l1.erase(l2.cbegin(), l2.cbegin()+1);
- assert(false);
- }
-#if TEST_STD_VER >= 11
- {
- int a1[] = {1, 2, 3};
- std::vector<int, min_allocator<int>> l1(a1, a1+3);
- std::vector<int, min_allocator<int>> l2(a1, a1+3);
- std::vector<int, min_allocator<int>>::iterator i = l1.erase(l2.cbegin(), l2.cbegin()+1);
- assert(false);
- }
-#endif
-}
-
-#else
-
-int main()
-{
-}
-
-#endif
diff --git a/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db4.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db4.pass.cpp
deleted file mode 100644
index 0fb8071fc679..000000000000
--- a/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db4.pass.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// <vector>
-
-// Call erase(const_iterator first, const_iterator last); with a bad range
-
-#if _LIBCPP_DEBUG >= 1
-
-#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
-
-#include <vector>
-#include <cassert>
-#include <exception>
-#include <cstdlib>
-
-#include "min_allocator.h"
-
-int main()
-{
- {
- int a1[] = {1, 2, 3};
- std::vector<int> l1(a1, a1+3);
- std::vector<int>::iterator i = l1.erase(l1.cbegin()+1, l1.cbegin());
- assert(false);
- }
-#if TEST_STD_VER >= 11
- {
- int a1[] = {1, 2, 3};
- std::vector<int, min_allocator<int>> l1(a1, a1+3);
- std::vector<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin()+1, l1.cbegin());
- assert(false);
- }
-#endif
-}
-
-#else
-
-int main()
-{
-}
-
-#endif
diff --git a/test/std/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp
index b8953021187f..258b9d9f7517 100644
--- a/test/std/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp
+++ b/test/std/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp
@@ -12,13 +12,12 @@
// template <class Iter>
// iterator insert(const_iterator position, Iter first, Iter last);
-#if _LIBCPP_DEBUG >= 1
-#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
-#endif
-
#include <vector>
#include <cassert>
-#include "../../../stack_allocator.h"
+#include <cstddef>
+
+#include "test_macros.h"
+#include "test_allocator.h"
#include "test_iterators.h"
#include "min_allocator.h"
#include "asan_testing.h"
@@ -37,7 +36,7 @@ int main()
int j;
for (j = 0; j < 10; ++j)
assert(v[j] == 0);
- for (int k = 0; k < N; ++j, ++k)
+ for (std::size_t k = 0; k < N; ++j, ++k)
assert(v[j] == a[k]);
for (; j < 105; ++j)
assert(v[j] == 0);
@@ -54,7 +53,7 @@ int main()
int j;
for (j = 0; j < 10; ++j)
assert(v[j] == 0);
- for (int k = 0; k < N; ++j, ++k)
+ for (std::size_t k = 0; k < N; ++j, ++k)
assert(v[j] == a[k]);
for (; j < 105; ++j)
assert(v[j] == 0);
@@ -69,10 +68,10 @@ int main()
forward_iterator<const int*>(a+N));
assert(v.size() == sz + N);
assert(i == v.begin() + 10);
- int j;
+ std::size_t j;
for (j = 0; j < 10; ++j)
assert(v[j] == 0);
- for (int k = 0; k < N; ++j, ++k)
+ for (std::size_t k = 0; k < N; ++j, ++k)
assert(v[j] == a[k]);
for (; j < v.size(); ++j)
assert(v[j] == 0);
@@ -87,16 +86,16 @@ int main()
forward_iterator<const int*>(a+N));
assert(v.size() == sz + N);
assert(i == v.begin() + 10);
- int j;
+ std::size_t j;
for (j = 0; j < 10; ++j)
assert(v[j] == 0);
- for (int k = 0; k < N; ++j, ++k)
+ for (std::size_t k = 0; k < N; ++j, ++k)
assert(v[j] == a[k]);
for (; j < v.size(); ++j)
assert(v[j] == 0);
}
{
- std::vector<int, stack_allocator<int, 308> > v(100);
+ std::vector<int, limited_allocator<int, 308> > v(100);
int a[] = {1, 2, 3, 4, 5};
const int N = sizeof(a)/sizeof(a[0]);
std::vector<int>::iterator i = v.insert(v.cbegin() + 10, input_iterator<const int*>(a),
@@ -107,13 +106,13 @@ int main()
int j;
for (j = 0; j < 10; ++j)
assert(v[j] == 0);
- for (int k = 0; k < N; ++j, ++k)
+ for (std::size_t k = 0; k < N; ++j, ++k)
assert(v[j] == a[k]);
for (; j < 105; ++j)
assert(v[j] == 0);
}
{
- std::vector<int, stack_allocator<int, 300> > v(100);
+ std::vector<int, limited_allocator<int, 300> > v(100);
int a[] = {1, 2, 3, 4, 5};
const int N = sizeof(a)/sizeof(a[0]);
std::vector<int>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const int*>(a),
@@ -124,22 +123,11 @@ int main()
int j;
for (j = 0; j < 10; ++j)
assert(v[j] == 0);
- for (int k = 0; k < N; ++j, ++k)
+ for (std::size_t k = 0; k < N; ++j, ++k)
assert(v[j] == a[k]);
for (; j < 105; ++j)
assert(v[j] == 0);
}
-#if _LIBCPP_DEBUG >= 1
- {
- std::vector<int> v(100);
- std::vector<int> v2(100);
- int a[] = {1, 2, 3, 4, 5};
- const int N = sizeof(a)/sizeof(a[0]);
- std::vector<int>::iterator i = v.insert(v2.cbegin() + 10, input_iterator<const int*>(a),
- input_iterator<const int*>(a+N));
- assert(false);
- }
-#endif
#if TEST_STD_VER >= 11
{
std::vector<int, min_allocator<int>> v(100);
@@ -153,7 +141,7 @@ int main()
int j;
for (j = 0; j < 10; ++j)
assert(v[j] == 0);
- for (int k = 0; k < N; ++j, ++k)
+ for (std::size_t k = 0; k < N; ++j, ++k)
assert(v[j] == a[k]);
for (; j < 105; ++j)
assert(v[j] == 0);
@@ -170,21 +158,10 @@ int main()
int j;
for (j = 0; j < 10; ++j)
assert(v[j] == 0);
- for (int k = 0; k < N; ++j, ++k)
+ for (std::size_t k = 0; k < N; ++j, ++k)
assert(v[j] == a[k]);
for (; j < 105; ++j)
assert(v[j] == 0);
}
-#if _LIBCPP_DEBUG >= 1
- {
- std::vector<int, min_allocator<int>> v(100);
- std::vector<int, min_allocator<int>> v2(100);
- int a[] = {1, 2, 3, 4, 5};
- const int N = sizeof(a)/sizeof(a[0]);
- std::vector<int, min_allocator<int>>::iterator i = v.insert(v2.cbegin() + 10, input_iterator<const int*>(a),
- input_iterator<const int*>(a+N));
- assert(false);
- }
-#endif
#endif
}
diff --git a/test/std/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp
index e1ad6be054e5..8794d924588b 100644
--- a/test/std/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp
+++ b/test/std/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp
@@ -7,24 +7,23 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03
+
// <vector>
// iterator insert(const_iterator position, value_type&& x);
-#if _LIBCPP_DEBUG >= 1
-#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
-#endif
-
#include <vector>
#include <cassert>
-#include "../../../stack_allocator.h"
+
+#include "test_macros.h"
+#include "test_allocator.h"
#include "MoveOnly.h"
#include "min_allocator.h"
#include "asan_testing.h"
int main()
{
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
std::vector<MoveOnly> v(100);
std::vector<MoveOnly>::iterator i = v.insert(v.cbegin() + 10, MoveOnly(3));
@@ -39,8 +38,8 @@ int main()
assert(v[j] == MoveOnly());
}
{
- std::vector<MoveOnly, stack_allocator<MoveOnly, 300> > v(100);
- std::vector<MoveOnly, stack_allocator<MoveOnly, 300> >::iterator i = v.insert(v.cbegin() + 10, MoveOnly(3));
+ std::vector<MoveOnly, limited_allocator<MoveOnly, 300> > v(100);
+ std::vector<MoveOnly, limited_allocator<MoveOnly, 300> >::iterator i = v.insert(v.cbegin() + 10, MoveOnly(3));
assert(v.size() == 101);
assert(is_contiguous_container_asan_correct(v));
assert(i == v.begin() + 10);
@@ -51,15 +50,6 @@ int main()
for (++j; j < 101; ++j)
assert(v[j] == MoveOnly());
}
-#if _LIBCPP_DEBUG >= 1
- {
- std::vector<int> v1(3);
- std::vector<int> v2(3);
- v1.insert(v2.begin(), 4);
- assert(false);
- }
-#endif
-#if TEST_STD_VER >= 11
{
std::vector<MoveOnly, min_allocator<MoveOnly>> v(100);
std::vector<MoveOnly, min_allocator<MoveOnly>>::iterator i = v.insert(v.cbegin() + 10, MoveOnly(3));
@@ -73,14 +63,4 @@ int main()
for (++j; j < 101; ++j)
assert(v[j] == MoveOnly());
}
-#if _LIBCPP_DEBUG >= 1
- {
- std::vector<int, min_allocator<int>> v1(3);
- std::vector<int, min_allocator<int>> v2(3);
- v1.insert(v2.begin(), 4);
- assert(false);
- }
-#endif
-#endif
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
diff --git a/test/std/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp
index ed4d6c976e9c..b6fc9ac73ea1 100644
--- a/test/std/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp
+++ b/test/std/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp
@@ -11,13 +11,12 @@
// iterator insert(const_iterator position, size_type n, const value_type& x);
-#if _LIBCPP_DEBUG >= 1
-#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
-#endif
-
#include <vector>
#include <cassert>
-#include "../../../stack_allocator.h"
+#include <cstddef>
+
+#include "test_macros.h"
+#include "test_allocator.h"
#include "min_allocator.h"
#include "asan_testing.h"
@@ -45,7 +44,7 @@ int main()
assert(v.size() == sz + 5);
assert(is_contiguous_container_asan_correct(v));
assert(i == v.begin() + 10);
- int j;
+ std::size_t j;
for (j = 0; j < 10; ++j)
assert(v[j] == 0);
for (; j < 15; ++j)
@@ -61,7 +60,7 @@ int main()
assert(v.size() == sz + 5);
assert(is_contiguous_container_asan_correct(v));
assert(i == v.begin() + 10);
- int j;
+ std::size_t j;
for (j = 0; j < 10; ++j)
assert(v[j] == 0);
for (; j < 15; ++j)
@@ -70,8 +69,8 @@ int main()
assert(v[j] == 0);
}
{
- std::vector<int, stack_allocator<int, 300> > v(100);
- std::vector<int, stack_allocator<int, 300> >::iterator i = v.insert(v.cbegin() + 10, 5, 1);
+ std::vector<int, limited_allocator<int, 300> > v(100);
+ std::vector<int, limited_allocator<int, 300> >::iterator i = v.insert(v.cbegin() + 10, 5, 1);
assert(v.size() == 105);
assert(is_contiguous_container_asan_correct(v));
assert(i == v.begin() + 10);
@@ -83,14 +82,6 @@ int main()
for (++j; j < 105; ++j)
assert(v[j] == 0);
}
-#if _LIBCPP_DEBUG >= 1
- {
- std::vector<int> c1(100);
- std::vector<int> c2;
- std::vector<int>::iterator i = c1.insert(c2.cbegin() + 10, 5, 1);
- assert(false);
- }
-#endif
#if TEST_STD_VER >= 11
{
std::vector<int, min_allocator<int>> v(100);
@@ -120,13 +111,5 @@ int main()
for (++j; j < 105; ++j)
assert(v[j] == 0);
}
-#if _LIBCPP_DEBUG >= 1
- {
- std::vector<int, min_allocator<int>> c1(100);
- std::vector<int, min_allocator<int>> c2;
- std::vector<int, min_allocator<int>>::iterator i = c1.insert(c2.cbegin() + 10, 5, 1);
- assert(false);
- }
-#endif
#endif
}
diff --git a/test/std/containers/sequences/vector/vector.modifiers/insert_iter_value.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/insert_iter_value.pass.cpp
index ba030e9e3fb7..5010f89493f0 100644
--- a/test/std/containers/sequences/vector/vector.modifiers/insert_iter_value.pass.cpp
+++ b/test/std/containers/sequences/vector/vector.modifiers/insert_iter_value.pass.cpp
@@ -11,13 +11,12 @@
// iterator insert(const_iterator position, const value_type& x);
-#if _LIBCPP_DEBUG >= 1
-#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
-#endif
-
#include <vector>
#include <cassert>
-#include "../../../stack_allocator.h"
+#include <cstddef>
+
+#include "test_macros.h"
+#include "test_allocator.h"
#include "min_allocator.h"
#include "asan_testing.h"
@@ -44,7 +43,7 @@ int main()
assert(v.size() == sz + 1);
assert(is_contiguous_container_asan_correct(v));
assert(i == v.begin() + 10);
- int j;
+ std::size_t j;
for (j = 0; j < 10; ++j)
assert(v[j] == 0);
assert(v[j] == 1);
@@ -60,7 +59,7 @@ int main()
assert(v.size() == sz + 1);
assert(is_contiguous_container_asan_correct(v));
assert(i == v.begin() + 10);
- int j;
+ std::size_t j;
for (j = 0; j < 10; ++j)
assert(v[j] == 0);
assert(v[j] == 1);
@@ -68,8 +67,8 @@ int main()
assert(v[j] == 0);
}
{
- std::vector<int, stack_allocator<int, 300> > v(100);
- std::vector<int, stack_allocator<int, 300> >::iterator i = v.insert(v.cbegin() + 10, 1);
+ std::vector<int, limited_allocator<int, 300> > v(100);
+ std::vector<int, limited_allocator<int, 300> >::iterator i = v.insert(v.cbegin() + 10, 1);
assert(v.size() == 101);
assert(is_contiguous_container_asan_correct(v));
assert(i == v.begin() + 10);
@@ -80,15 +79,6 @@ int main()
for (++j; j < 101; ++j)
assert(v[j] == 0);
}
-#if _LIBCPP_DEBUG >= 1
- {
- std::vector<int> v1(3);
- std::vector<int> v2(3);
- int i = 4;
- v1.insert(v2.begin(), i);
- assert(false);
- }
-#endif
#if TEST_STD_VER >= 11
{
std::vector<int, min_allocator<int>> v(100);
@@ -103,14 +93,5 @@ int main()
for (++j; j < 101; ++j)
assert(v[j] == 0);
}
-#if _LIBCPP_DEBUG >= 1
- {
- std::vector<int, min_allocator<int>> v1(3);
- std::vector<int, min_allocator<int>> v2(3);
- int i = 4;
- v1.insert(v2.begin(), i);
- assert(false);
- }
-#endif
#endif
}
diff --git a/test/std/containers/sequences/vector/vector.modifiers/pop_back.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/pop_back.pass.cpp
index c81e41904fc8..c44023827ea5 100644
--- a/test/std/containers/sequences/vector/vector.modifiers/pop_back.pass.cpp
+++ b/test/std/containers/sequences/vector/vector.modifiers/pop_back.pass.cpp
@@ -11,20 +11,13 @@
// void pop_back();
-#if _LIBCPP_DEBUG >= 1
-#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
-#endif
-
#include <vector>
#include <cassert>
-#include "../../../stack_allocator.h"
-#include "min_allocator.h"
-#if _LIBCPP_DEBUG >= 1
-#include <cstdlib>
-#include <exception>
+#include "test_macros.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
-#endif
int main()
{
@@ -34,10 +27,7 @@ int main()
assert(c.size() == 1);
c.pop_back();
assert(c.size() == 0);
-#if _LIBCPP_DEBUG >= 1
- c.pop_back();
- assert(false);
-#endif
+
}
#if TEST_STD_VER >= 11
{
@@ -46,10 +36,6 @@ int main()
assert(c.size() == 1);
c.pop_back();
assert(c.size() == 0);
-#if _LIBCPP_DEBUG >= 1
- c.pop_back();
- assert(false);
-#endif
}
#endif
}
diff --git a/test/std/containers/sequences/vector/vector.modifiers/push_back.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/push_back.pass.cpp
index bef3b9c8d17d..3b568b7e06d0 100644
--- a/test/std/containers/sequences/vector/vector.modifiers/push_back.pass.cpp
+++ b/test/std/containers/sequences/vector/vector.modifiers/push_back.pass.cpp
@@ -13,7 +13,8 @@
#include <vector>
#include <cassert>
-#include "../../../stack_allocator.h"
+#include <cstddef>
+#include "test_allocator.h"
#include "min_allocator.h"
#include "asan_testing.h"
@@ -24,55 +25,58 @@ int main()
c.push_back(0);
assert(c.size() == 1);
assert(is_contiguous_container_asan_correct(c));
- for (int j = 0; j < c.size(); ++j)
+ for (int j = 0; static_cast<std::size_t>(j) < c.size(); ++j)
assert(c[j] == j);
c.push_back(1);
assert(c.size() == 2);
assert(is_contiguous_container_asan_correct(c));
- for (int j = 0; j < c.size(); ++j)
+ for (int j = 0; static_cast<std::size_t>(j) < c.size(); ++j)
assert(c[j] == j);
c.push_back(2);
assert(c.size() == 3);
assert(is_contiguous_container_asan_correct(c));
- for (int j = 0; j < c.size(); ++j)
+ for (int j = 0; static_cast<std::size_t>(j) < c.size(); ++j)
assert(c[j] == j);
c.push_back(3);
assert(c.size() == 4);
assert(is_contiguous_container_asan_correct(c));
- for (int j = 0; j < c.size(); ++j)
+ for (int j = 0; static_cast<std::size_t>(j) < c.size(); ++j)
assert(c[j] == j);
c.push_back(4);
assert(c.size() == 5);
assert(is_contiguous_container_asan_correct(c));
- for (int j = 0; j < c.size(); ++j)
+ for (int j = 0; static_cast<std::size_t>(j) < c.size(); ++j)
assert(c[j] == j);
}
{
- std::vector<int, stack_allocator<int, 15> > c;
+ // libc++ needs 15 because it grows by 2x (1 + 2 + 4 + 8).
+ // Use 17 for implementations that dynamically allocate a container proxy
+ // and grow by 1.5x (1 for proxy + 1 + 2 + 3 + 4 + 6).
+ std::vector<int, limited_allocator<int, 17> > c;
c.push_back(0);
assert(c.size() == 1);
assert(is_contiguous_container_asan_correct(c));
- for (int j = 0; j < c.size(); ++j)
+ for (int j = 0; static_cast<std::size_t>(j) < c.size(); ++j)
assert(c[j] == j);
c.push_back(1);
assert(c.size() == 2);
assert(is_contiguous_container_asan_correct(c));
- for (int j = 0; j < c.size(); ++j)
+ for (int j = 0; static_cast<std::size_t>(j) < c.size(); ++j)
assert(c[j] == j);
c.push_back(2);
assert(c.size() == 3);
assert(is_contiguous_container_asan_correct(c));
- for (int j = 0; j < c.size(); ++j)
+ for (int j = 0; static_cast<std::size_t>(j) < c.size(); ++j)
assert(c[j] == j);
c.push_back(3);
assert(c.size() == 4);
assert(is_contiguous_container_asan_correct(c));
- for (int j = 0; j < c.size(); ++j)
+ for (int j = 0; static_cast<std::size_t>(j) < c.size(); ++j)
assert(c[j] == j);
c.push_back(4);
assert(c.size() == 5);
assert(is_contiguous_container_asan_correct(c));
- for (int j = 0; j < c.size(); ++j)
+ for (int j = 0; static_cast<std::size_t>(j) < c.size(); ++j)
assert(c[j] == j);
}
#if TEST_STD_VER >= 11
@@ -81,27 +85,27 @@ int main()
c.push_back(0);
assert(c.size() == 1);
assert(is_contiguous_container_asan_correct(c));
- for (int j = 0; j < c.size(); ++j)
+ for (int j = 0; static_cast<std::size_t>(j) < c.size(); ++j)
assert(c[j] == j);
c.push_back(1);
assert(c.size() == 2);
assert(is_contiguous_container_asan_correct(c));
- for (int j = 0; j < c.size(); ++j)
+ for (int j = 0; static_cast<std::size_t>(j) < c.size(); ++j)
assert(c[j] == j);
c.push_back(2);
assert(c.size() == 3);
assert(is_contiguous_container_asan_correct(c));
- for (int j = 0; j < c.size(); ++j)
+ for (int j = 0; static_cast<std::size_t>(j) < c.size(); ++j)
assert(c[j] == j);
c.push_back(3);
assert(c.size() == 4);
assert(is_contiguous_container_asan_correct(c));
- for (int j = 0; j < c.size(); ++j)
+ for (int j = 0; static_cast<std::size_t>(j) < c.size(); ++j)
assert(c[j] == j);
c.push_back(4);
assert(c.size() == 5);
assert(is_contiguous_container_asan_correct(c));
- for (int j = 0; j < c.size(); ++j)
+ for (int j = 0; static_cast<std::size_t>(j) < c.size(); ++j)
assert(c[j] == j);
}
#endif
diff --git a/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp
index 5fa93aab89c7..eabe029a3a77 100644
--- a/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp
+++ b/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp
@@ -7,7 +7,6 @@
//
//===----------------------------------------------------------------------===//
-// XFAIL: libcpp-no-exceptions
// <vector>
// void push_back(const value_type& x);
@@ -16,10 +15,10 @@
#include <cassert>
#include "asan_testing.h"
+#include "test_macros.h"
// Flag that makes the copy constructor for CMyClass throw an exception
-static bool gCopyConstructorShouldThow = false;
-
+static bool gCopyConstructorShouldThrow = false;
class CMyClass {
public: CMyClass(int tag);
@@ -52,8 +51,8 @@ CMyClass::CMyClass(const CMyClass& iOther) :
fMagicValue(kStartedConstructionMagicValue), fTag(iOther.fTag)
{
// If requested, throw an exception _before_ setting fMagicValue to kFinishedConstructionMagicValue
- if (gCopyConstructorShouldThow) {
- throw std::exception();
+ if (gCopyConstructorShouldThrow) {
+ TEST_THROW(std::exception());
}
// Signal that the constructor has finished running
fMagicValue = kFinishedConstructionMagicValue;
@@ -76,12 +75,15 @@ int main()
assert(is_contiguous_container_asan_correct(vec));
assert(is_contiguous_container_asan_correct(vec2));
- gCopyConstructorShouldThow = true;
+#ifndef TEST_HAS_NO_EXCEPTIONS
+ gCopyConstructorShouldThrow = true;
try {
vec.push_back(instance);
+ assert(false);
}
catch (...) {
assert(vec==vec2);
assert(is_contiguous_container_asan_correct(vec));
}
+#endif
}
diff --git a/test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp
index 64762eb374e8..f4a1f5d5f519 100644
--- a/test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp
+++ b/test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp
@@ -13,8 +13,9 @@
#include <vector>
#include <cassert>
+#include <cstddef>
#include "MoveOnly.h"
-#include "../../../stack_allocator.h"
+#include "test_allocator.h"
#include "min_allocator.h"
#include "asan_testing.h"
@@ -26,55 +27,58 @@ int main()
c.push_back(MoveOnly(0));
assert(c.size() == 1);
assert(is_contiguous_container_asan_correct(c));
- for (int j = 0; j < c.size(); ++j)
+ for (int j = 0; static_cast<std::size_t>(j) < c.size(); ++j)
assert(c[j] == MoveOnly(j));
c.push_back(MoveOnly(1));
assert(c.size() == 2);
assert(is_contiguous_container_asan_correct(c));
- for (int j = 0; j < c.size(); ++j)
+ for (int j = 0; static_cast<std::size_t>(j) < c.size(); ++j)
assert(c[j] == MoveOnly(j));
c.push_back(MoveOnly(2));
assert(c.size() == 3);
assert(is_contiguous_container_asan_correct(c));
- for (int j = 0; j < c.size(); ++j)
+ for (int j = 0; static_cast<std::size_t>(j) < c.size(); ++j)
assert(c[j] == MoveOnly(j));
c.push_back(MoveOnly(3));
assert(c.size() == 4);
assert(is_contiguous_container_asan_correct(c));
- for (int j = 0; j < c.size(); ++j)
+ for (int j = 0; static_cast<std::size_t>(j) < c.size(); ++j)
assert(c[j] == MoveOnly(j));
c.push_back(MoveOnly(4));
assert(c.size() == 5);
assert(is_contiguous_container_asan_correct(c));
- for (int j = 0; j < c.size(); ++j)
+ for (int j = 0; static_cast<std::size_t>(j) < c.size(); ++j)
assert(c[j] == MoveOnly(j));
}
{
- std::vector<MoveOnly, stack_allocator<MoveOnly, 15> > c;
+ // libc++ needs 15 because it grows by 2x (1 + 2 + 4 + 8).
+ // Use 17 for implementations that dynamically allocate a container proxy
+ // and grow by 1.5x (1 for proxy + 1 + 2 + 3 + 4 + 6).
+ std::vector<MoveOnly, limited_allocator<MoveOnly, 17> > c;
c.push_back(MoveOnly(0));
assert(c.size() == 1);
assert(is_contiguous_container_asan_correct(c));
- for (int j = 0; j < c.size(); ++j)
+ for (int j = 0; static_cast<std::size_t>(j) < c.size(); ++j)
assert(c[j] == MoveOnly(j));
c.push_back(MoveOnly(1));
assert(c.size() == 2);
assert(is_contiguous_container_asan_correct(c));
- for (int j = 0; j < c.size(); ++j)
+ for (int j = 0; static_cast<std::size_t>(j) < c.size(); ++j)
assert(c[j] == MoveOnly(j));
c.push_back(MoveOnly(2));
assert(c.size() == 3);
assert(is_contiguous_container_asan_correct(c));
- for (int j = 0; j < c.size(); ++j)
+ for (int j = 0; static_cast<std::size_t>(j) < c.size(); ++j)
assert(c[j] == MoveOnly(j));
c.push_back(MoveOnly(3));
assert(c.size() == 4);
assert(is_contiguous_container_asan_correct(c));
- for (int j = 0; j < c.size(); ++j)
+ for (int j = 0; static_cast<std::size_t>(j) < c.size(); ++j)
assert(c[j] == MoveOnly(j));
c.push_back(MoveOnly(4));
assert(c.size() == 5);
assert(is_contiguous_container_asan_correct(c));
- for (int j = 0; j < c.size(); ++j)
+ for (int j = 0; static_cast<std::size_t>(j) < c.size(); ++j)
assert(c[j] == MoveOnly(j));
}
#if TEST_STD_VER >= 11
@@ -83,27 +87,27 @@ int main()
c.push_back(MoveOnly(0));
assert(c.size() == 1);
assert(is_contiguous_container_asan_correct(c));
- for (int j = 0; j < c.size(); ++j)
+ for (int j = 0; static_cast<std::size_t>(j) < c.size(); ++j)
assert(c[j] == MoveOnly(j));
c.push_back(MoveOnly(1));
assert(c.size() == 2);
assert(is_contiguous_container_asan_correct(c));
- for (int j = 0; j < c.size(); ++j)
+ for (int j = 0; static_cast<std::size_t>(j) < c.size(); ++j)
assert(c[j] == MoveOnly(j));
c.push_back(MoveOnly(2));
assert(c.size() == 3);
assert(is_contiguous_container_asan_correct(c));
- for (int j = 0; j < c.size(); ++j)
+ for (int j = 0; static_cast<std::size_t>(j) < c.size(); ++j)
assert(c[j] == MoveOnly(j));
c.push_back(MoveOnly(3));
assert(c.size() == 4);
assert(is_contiguous_container_asan_correct(c));
- for (int j = 0; j < c.size(); ++j)
+ for (int j = 0; static_cast<std::size_t>(j) < c.size(); ++j)
assert(c[j] == MoveOnly(j));
c.push_back(MoveOnly(4));
assert(c.size() == 5);
assert(is_contiguous_container_asan_correct(c));
- for (int j = 0; j < c.size(); ++j)
+ for (int j = 0; static_cast<std::size_t>(j) < c.size(); ++j)
assert(c[j] == MoveOnly(j));
}
#endif
diff --git a/test/std/containers/sequences/vector/vector.special/db_swap_1.pass.cpp b/test/std/containers/sequences/vector/vector.special/db_swap_1.pass.cpp
deleted file mode 100644
index 1bb761181422..000000000000
--- a/test/std/containers/sequences/vector/vector.special/db_swap_1.pass.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// <vector>
-
-// template <class T, class Alloc>
-// void swap(vector<T,Alloc>& x, vector<T,Alloc>& y);
-
-#if _LIBCPP_DEBUG >= 1
-#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
-#endif
-
-#include <vector>
-#include <cassert>
-
-#include "min_allocator.h"
-
-int main()
-{
-#if _LIBCPP_DEBUG >= 1
- {
- int a1[] = {1, 3, 7, 9, 10};
- int a2[] = {0, 2, 4, 5, 6, 8, 11};
- std::vector<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
- std::vector<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
- std::vector<int>::iterator i1 = c1.begin();
- std::vector<int>::iterator i2 = c2.begin();
- swap(c1, c2);
- c1.erase(i2);
- c2.erase(i1);
- c1.erase(i1);
- assert(false);
- }
-#if TEST_STD_VER >= 11
- {
- int a1[] = {1, 3, 7, 9, 10};
- int a2[] = {0, 2, 4, 5, 6, 8, 11};
- std::vector<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
- std::vector<int, min_allocator<int>> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
- std::vector<int, min_allocator<int>>::iterator i1 = c1.begin();
- std::vector<int, min_allocator<int>>::iterator i2 = c2.begin();
- swap(c1, c2);
- c1.erase(i2);
- c2.erase(i1);
- c1.erase(i1);
- assert(false);
- }
-#endif
-#endif
-}
diff --git a/test/std/containers/sequences/vector/vector.special/swap.pass.cpp b/test/std/containers/sequences/vector/vector.special/swap.pass.cpp
index 3d01129fa008..0f42d891a587 100644
--- a/test/std/containers/sequences/vector/vector.special/swap.pass.cpp
+++ b/test/std/containers/sequences/vector/vector.special/swap.pass.cpp
@@ -77,21 +77,18 @@ int main()
assert(is_contiguous_container_asan_correct(c1));
assert(is_contiguous_container_asan_correct(c2));
}
-#ifndef _LIBCPP_DEBUG_LEVEL
-// This test known to result in undefined behavior detected by _LIBCPP_DEBUG_LEVEL >= 1
{
int a1[] = {1, 3, 7, 9, 10};
int a2[] = {0, 2, 4, 5, 6, 8, 11};
typedef test_allocator<int> A;
- std::vector<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1));
- std::vector<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(2));
+ std::vector<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1, 1));
+ std::vector<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(1, 2));
swap(c1, c2);
assert((c1 == std::vector<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
- assert(c1.get_allocator() == A(1));
+ assert(c1.get_allocator().get_id() == 1);
assert((c2 == std::vector<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
- assert(c2.get_allocator() == A(2));
+ assert(c2.get_allocator().get_id() == 2);
}
-#endif
{
int a1[] = {1, 3, 7, 9, 10};
int a2[] = {0, 2, 4, 5, 6, 8, 11};
@@ -165,8 +162,6 @@ int main()
assert(is_contiguous_container_asan_correct(c1));
assert(is_contiguous_container_asan_correct(c2));
}
-#ifndef _LIBCPP_DEBUG_LEVEL
-// This test known to result in undefined behavior detected by _LIBCPP_DEBUG_LEVEL >= 1
{
int a1[] = {1, 3, 7, 9, 10};
int a2[] = {0, 2, 4, 5, 6, 8, 11};
@@ -184,5 +179,4 @@ int main()
assert(is_contiguous_container_asan_correct(c2));
}
#endif
-#endif
}
diff --git a/test/std/containers/sequences/vector/vector.special/swap_noexcept.pass.cpp b/test/std/containers/sequences/vector/vector.special/swap_noexcept.pass.cpp
index 89fa301ad9bd..214f9a577571 100644
--- a/test/std/containers/sequences/vector/vector.special/swap_noexcept.pass.cpp
+++ b/test/std/containers/sequences/vector/vector.special/swap_noexcept.pass.cpp
@@ -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
}