diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-01-02 19:18:58 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-01-02 19:18:58 +0000 |
commit | 53a420fba21cf1644972b34dcd811a43cdb8368d (patch) | |
tree | 66a19f6f8b65215772549a51d688492ab8addc0d /test/std/containers/sequences | |
parent | b50f1549701eb950921e5d6f2e55ba1a1dadbb43 (diff) | |
download | src-53a420fba21cf1644972b34dcd811a43cdb8368d.tar.gz src-53a420fba21cf1644972b34dcd811a43cdb8368d.zip |
Vendor import of libc++ trunk r290819:vendor/libc++/libc++-trunk-r290819
Notes
Notes:
svn path=/vendor/libc++/dist/; revision=311123
svn path=/vendor/libc++/libc++-trunk-r290819/; revision=311124; tag=vendor/libc++/libc++-trunk-r290819
Diffstat (limited to 'test/std/containers/sequences')
129 files changed, 823 insertions, 1046 deletions
diff --git a/test/std/containers/sequences/array/array.tuple/get.fail.cpp b/test/std/containers/sequences/array/array.tuple/get.fail.cpp index 13323dd8e519..45e1d2b46b0f 100644 --- a/test/std/containers/sequences/array/array.tuple/get.fail.cpp +++ b/test/std/containers/sequences/array/array.tuple/get.fail.cpp @@ -19,7 +19,6 @@ #include <array> #include <cassert> -#include "test_macros.h" // std::array is explicitly allowed to be initialized with A a = { init-list };. // Disable the missing braces warning for this reason. @@ -32,10 +31,6 @@ int main() typedef std::array<T, 3> C; C c = {1, 2, 3.5}; std::get<3>(c) = 5.5; // expected-note {{requested here}} -#if TEST_STD_VER >= 11 // expected-error@array:* {{static_assert failed "Index out of bounds in std::get<> (std::array)"}} -#else - // expected-error@array:* {{implicit instantiation of undefined template '__static_assert_test<false>'}} -#endif } } diff --git a/test/std/containers/sequences/array/at.pass.cpp b/test/std/containers/sequences/array/at.pass.cpp index 9707beeb3946..29483153d4ab 100644 --- a/test/std/containers/sequences/array/at.pass.cpp +++ b/test/std/containers/sequences/array/at.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // <array> // reference operator[] (size_type) @@ -40,8 +39,14 @@ int main() r2 = 7.5; assert(c.back() == 7.5); - try { (void) c.at(3); } +#ifndef TEST_HAS_NO_EXCEPTIONS + try + { + (void) c.at(3); + assert(false); + } catch (const std::out_of_range &) {} +#endif } { typedef double T; @@ -53,8 +58,14 @@ int main() C::const_reference r2 = c.at(2); assert(r2 == 3.5); - try { (void) c.at(3); } +#ifndef TEST_HAS_NO_EXCEPTIONS + try + { + (void) c.at(3); + assert(false); + } catch (const std::out_of_range &) {} +#endif } #if TEST_STD_VER > 11 diff --git a/test/std/containers/sequences/array/iterators.pass.cpp b/test/std/containers/sequences/array/iterators.pass.cpp index 233e9328c4ed..1f9904e1fa71 100644 --- a/test/std/containers/sequences/array/iterators.pass.cpp +++ b/test/std/containers/sequences/array/iterators.pass.cpp @@ -15,6 +15,8 @@ #include <iterator> #include <cassert> +#include "test_macros.h" + int main() { { @@ -36,7 +38,7 @@ int main() assert(i == j); } -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 { // N3644 testing { typedef std::array<int, 5> C; diff --git a/test/std/containers/sequences/deque/deque.capacity/access.pass.cpp b/test/std/containers/sequences/deque/deque.capacity/access.pass.cpp index a6a8e7424b25..6f3458a63d19 100644 --- a/test/std/containers/sequences/deque/deque.capacity/access.pass.cpp +++ b/test/std/containers/sequences/deque/deque.capacity/access.pass.cpp @@ -52,18 +52,18 @@ int main() { { std::deque<int> c = make<std::deque<int> >(10); - for (unsigned i = 0; i < 10; ++i) + for (int i = 0; i < 10; ++i) assert(c[i] == i); - for (unsigned i = 0; i < 10; ++i) + for (int i = 0; i < 10; ++i) assert(c.at(i) == i); assert(c.front() == 0); assert(c.back() == 9); } { const std::deque<int> c = make<std::deque<int> >(10); - for (unsigned i = 0; i < 10; ++i) + for (int i = 0; i < 10; ++i) assert(c[i] == i); - for (unsigned i = 0; i < 10; ++i) + for (int i = 0; i < 10; ++i) assert(c.at(i) == i); assert(c.front() == 0); assert(c.back() == 9); @@ -71,18 +71,18 @@ int main() #if TEST_STD_VER >= 11 { std::deque<int, min_allocator<int>> c = make<std::deque<int, min_allocator<int>> >(10); - for (unsigned i = 0; i < 10; ++i) + for (int i = 0; i < 10; ++i) assert(c[i] == i); - for (unsigned i = 0; i < 10; ++i) + for (int i = 0; i < 10; ++i) assert(c.at(i) == i); assert(c.front() == 0); assert(c.back() == 9); } { const std::deque<int, min_allocator<int>> c = make<std::deque<int, min_allocator<int>> >(10); - for (unsigned i = 0; i < 10; ++i) + for (int i = 0; i < 10; ++i) assert(c[i] == i); - for (unsigned i = 0; i < 10; ++i) + for (int i = 0; i < 10; ++i) assert(c.at(i) == i); assert(c.front() == 0); assert(c.back() == 9); diff --git a/test/std/containers/sequences/deque/deque.capacity/max_size.pass.cpp b/test/std/containers/sequences/deque/deque.capacity/max_size.pass.cpp new file mode 100644 index 000000000000..11ce9d2f6899 --- /dev/null +++ b/test/std/containers/sequences/deque/deque.capacity/max_size.pass.cpp @@ -0,0 +1,47 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <deque> + +// size_type max_size() const; + +#include <cassert> +#include <deque> +#include <limits> +#include <type_traits> + +#include "test_allocator.h" +#include "test_macros.h" + +int main() { + { + typedef limited_allocator<int, 10> A; + typedef std::deque<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::deque<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::deque<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/deque/deque.capacity/resize_size.pass.cpp b/test/std/containers/sequences/deque/deque.capacity/resize_size.pass.cpp index 53c6bd3380a2..330fd40b7229 100644 --- a/test/std/containers/sequences/deque/deque.capacity/resize_size.pass.cpp +++ b/test/std/containers/sequences/deque/deque.capacity/resize_size.pass.cpp @@ -15,6 +15,7 @@ #include <algorithm> #include <iterator> #include <cassert> +#include <cstddef> #include "test_macros.h" #include "min_allocator.h" @@ -48,12 +49,12 @@ test(C& c1, int size) typedef typename C::const_iterator CI; typename C::size_type c1_osize = c1.size(); c1.resize(size); - assert(c1.size() == size); - assert(distance(c1.begin(), c1.end()) == c1.size()); + assert(c1.size() == static_cast<std::size_t>(size)); + assert(static_cast<std::size_t>(distance(c1.begin(), c1.end())) == c1.size()); CI i = c1.begin(); - for (int j = 0; j < std::min(c1_osize, c1.size()); ++j, ++i) + for (int j = 0; static_cast<std::size_t>(j) < std::min(c1_osize, c1.size()); ++j, ++i) assert(*i == j); - for (int j = c1_osize; j < c1.size(); ++j, ++i) + for (std::size_t j = c1_osize; j < c1.size(); ++j, ++i) assert(*i == 0); } diff --git a/test/std/containers/sequences/deque/deque.capacity/resize_size_value.pass.cpp b/test/std/containers/sequences/deque/deque.capacity/resize_size_value.pass.cpp index 12af64386bd8..3737e727c7b7 100644 --- a/test/std/containers/sequences/deque/deque.capacity/resize_size_value.pass.cpp +++ b/test/std/containers/sequences/deque/deque.capacity/resize_size_value.pass.cpp @@ -15,6 +15,7 @@ #include <algorithm> #include <iterator> #include <cassert> +#include <cstddef> #include "test_macros.h" #include "min_allocator.h" @@ -48,12 +49,12 @@ test(C& c1, int size, int x) typedef typename C::const_iterator CI; typename C::size_type c1_osize = c1.size(); c1.resize(size, x); - assert(c1.size() == size); - assert(distance(c1.begin(), c1.end()) == c1.size()); + assert(c1.size() == static_cast<std::size_t>(size)); + assert(static_cast<std::size_t>(distance(c1.begin(), c1.end())) == c1.size()); CI i = c1.begin(); - for (int j = 0; j < std::min(c1_osize, c1.size()); ++j, ++i) + for (int j = 0; static_cast<std::size_t>(j) < std::min(c1_osize, c1.size()); ++j, ++i) assert(*i == j); - for (int j = c1_osize; j < c1.size(); ++j, ++i) + for (std::size_t j = c1_osize; j < c1.size(); ++j, ++i) assert(*i == x); } diff --git a/test/std/containers/sequences/deque/deque.cons/assign_iter_iter.pass.cpp b/test/std/containers/sequences/deque/deque.cons/assign_iter_iter.pass.cpp index 6507f58e1194..f06067786cfd 100644 --- a/test/std/containers/sequences/deque/deque.cons/assign_iter_iter.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/assign_iter_iter.pass.cpp @@ -14,6 +14,7 @@ #include <deque> #include <cassert> +#include <cstddef> #include "test_macros.h" #include "test_iterators.h" @@ -46,7 +47,7 @@ void test(C& c1, const C& c2) { c1.assign(c2.begin(), c2.end()); - assert(distance(c1.begin(), c1.end()) == c1.size()); + assert(static_cast<std::size_t>(distance(c1.begin(), c1.end())) == c1.size()); assert(c1 == c2); } @@ -66,7 +67,7 @@ testI(C& c1, const C& c2) typedef typename C::const_iterator CI; typedef input_iterator<CI> ICI; c1.assign(ICI(c2.begin()), ICI(c2.end())); - assert(distance(c1.begin(), c1.end()) == c1.size()); + assert(static_cast<std::size_t>(distance(c1.begin(), c1.end())) == c1.size()); assert(c1 == c2); } diff --git a/test/std/containers/sequences/deque/deque.cons/assign_size_value.pass.cpp b/test/std/containers/sequences/deque/deque.cons/assign_size_value.pass.cpp index e00e0442d22e..08325b73008c 100644 --- a/test/std/containers/sequences/deque/deque.cons/assign_size_value.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/assign_size_value.pass.cpp @@ -13,6 +13,7 @@ #include <deque> #include <cassert> +#include <cstddef> #include "test_macros.h" #include "test_iterators.h" @@ -46,8 +47,8 @@ test(C& c1, int size, int v) { typedef typename C::const_iterator CI; c1.assign(size, v); - assert(c1.size() == size); - assert(distance(c1.begin(), c1.end()) == c1.size()); + assert(c1.size() == static_cast<std::size_t>(size)); + assert(static_cast<std::size_t>(distance(c1.begin(), c1.end())) == c1.size()); for (CI i = c1.begin(); i != c1.end(); ++i) assert(*i == v); } diff --git a/test/std/containers/sequences/deque/deque.cons/copy.pass.cpp b/test/std/containers/sequences/deque/deque.cons/copy.pass.cpp index ec73555b9c4f..1840545680d1 100644 --- a/test/std/containers/sequences/deque/deque.cons/copy.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/copy.pass.cpp @@ -13,6 +13,8 @@ #include <deque> #include <cassert> + +#include "test_macros.h" #include "test_allocator.h" #include "min_allocator.h" @@ -37,15 +39,13 @@ int main() assert(v2 == v); assert(v2.get_allocator() == v.get_allocator()); } -#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE +#if TEST_STD_VER >= 11 { std::deque<int, other_allocator<int> > v(3, 2, other_allocator<int>(5)); std::deque<int, other_allocator<int> > v2 = v; assert(v2 == v); assert(v2.get_allocator() == other_allocator<int>(-2)); } -#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE -#if TEST_STD_VER >= 11 { int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45}; int* an = ab + sizeof(ab)/sizeof(ab[0]); diff --git a/test/std/containers/sequences/deque/deque.cons/default.pass.cpp b/test/std/containers/sequences/deque/deque.cons/default.pass.cpp index 7c42d9e7786e..127b08609464 100644 --- a/test/std/containers/sequences/deque/deque.cons/default.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/default.pass.cpp @@ -14,7 +14,7 @@ #include <deque> #include <cassert> -#include "../../../stack_allocator.h" +#include "test_allocator.h" #include "../../../NotConstructible.h" #include "min_allocator.h" @@ -33,7 +33,7 @@ test() int main() { test<int, std::allocator<int> >(); - test<NotConstructible, stack_allocator<NotConstructible, 1> >(); + test<NotConstructible, limited_allocator<NotConstructible, 1> >(); #if TEST_STD_VER >= 11 test<int, min_allocator<int> >(); test<NotConstructible, min_allocator<NotConstructible> >(); diff --git a/test/std/containers/sequences/deque/deque.cons/dtor_noexcept.pass.cpp b/test/std/containers/sequences/deque/deque.cons/dtor_noexcept.pass.cpp index 503e1237e9eb..59955157421d 100644 --- a/test/std/containers/sequences/deque/deque.cons/dtor_noexcept.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/dtor_noexcept.pass.cpp @@ -16,6 +16,7 @@ #include <deque> #include <cassert> +#include "test_macros.h" #include "MoveOnly.h" #include "test_allocator.h" @@ -43,6 +44,6 @@ int main() } { typedef std::deque<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/deque/deque.cons/iter_iter.pass.cpp b/test/std/containers/sequences/deque/deque.cons/iter_iter.pass.cpp index 12a7faf686db..87445c5b2b67 100644 --- a/test/std/containers/sequences/deque/deque.cons/iter_iter.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/iter_iter.pass.cpp @@ -13,8 +13,9 @@ #include <deque> #include <cassert> +#include <cstddef> -#include "../../../stack_allocator.h" +#include "test_allocator.h" #include "test_iterators.h" #include "min_allocator.h" @@ -27,8 +28,8 @@ test(InputIterator f, InputIterator l) typedef std::deque<T, Allocator> C; typedef typename C::const_iterator const_iterator; C d(f, l); - assert(d.size() == std::distance(f, l)); - assert(distance(d.begin(), d.end()) == d.size()); + assert(d.size() == static_cast<std::size_t>(std::distance(f, l))); + assert(static_cast<std::size_t>(distance(d.begin(), d.end())) == d.size()); for (const_iterator i = d.begin(), e = d.end(); i != e; ++i, ++f) assert(*i == *f); } @@ -41,8 +42,8 @@ test(InputIterator f, InputIterator l) typedef std::deque<T, Allocator> C; typedef typename C::const_iterator const_iterator; C d(f, l); - assert(d.size() == std::distance(f, l)); - assert(distance(d.begin(), d.end()) == d.size()); + assert(d.size() == static_cast<std::size_t>(std::distance(f, l))); + assert(static_cast<std::size_t>(distance(d.begin(), d.end())) == d.size()); for (const_iterator i = d.begin(), e = d.end(); i != e; ++i, ++f) assert(*i == *f); } @@ -55,7 +56,7 @@ int main() test(forward_iterator<const int*>(ab), forward_iterator<const int*>(an)); test(bidirectional_iterator<const int*>(ab), bidirectional_iterator<const int*>(an)); test(random_access_iterator<const int*>(ab), random_access_iterator<const int*>(an)); - test<stack_allocator<int, 4096> >(ab, an); + test<limited_allocator<int, 4096> >(ab, an); #if TEST_STD_VER >= 11 test<min_allocator<int> >(ab, an); #endif diff --git a/test/std/containers/sequences/deque/deque.cons/iter_iter_alloc.pass.cpp b/test/std/containers/sequences/deque/deque.cons/iter_iter_alloc.pass.cpp index c8f7759a19d6..54227ebc12d8 100644 --- a/test/std/containers/sequences/deque/deque.cons/iter_iter_alloc.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/iter_iter_alloc.pass.cpp @@ -14,6 +14,7 @@ #include <deque> #include <cassert> +#include <cstddef> #include "test_iterators.h" #include "test_allocator.h" @@ -28,8 +29,8 @@ test(InputIterator f, InputIterator l, const Allocator& a) typedef typename C::const_iterator const_iterator; C d(f, l, a); assert(d.get_allocator() == a); - assert(d.size() == std::distance(f, l)); - assert(distance(d.begin(), d.end()) == d.size()); + assert(d.size() == static_cast<std::size_t>(std::distance(f, l))); + assert(static_cast<std::size_t>(distance(d.begin(), d.end())) == d.size()); for (const_iterator i = d.begin(), e = d.end(); i != e; ++i, ++f) assert(*i == *f); } diff --git a/test/std/containers/sequences/deque/deque.cons/move_assign_noexcept.pass.cpp b/test/std/containers/sequences/deque/deque.cons/move_assign_noexcept.pass.cpp index cebf76a15a4a..9b813ce342a3 100644 --- a/test/std/containers/sequences/deque/deque.cons/move_assign_noexcept.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/move_assign_noexcept.pass.cpp @@ -21,6 +21,7 @@ #include <deque> #include <cassert> +#include "test_macros.h" #include "MoveOnly.h" #include "test_allocator.h" @@ -43,10 +44,10 @@ int main() } { typedef std::deque<MoveOnly, other_allocator<MoveOnly>> C; - static_assert(std::is_nothrow_move_assignable<C>::value, ""); + LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable<C>::value, ""); } { typedef std::deque<MoveOnly, some_alloc<MoveOnly>> C; - static_assert(!std::is_nothrow_move_assignable<C>::value, ""); + LIBCPP_STATIC_ASSERT(!std::is_nothrow_move_assignable<C>::value, ""); } } diff --git a/test/std/containers/sequences/deque/deque.cons/move_noexcept.pass.cpp b/test/std/containers/sequences/deque/deque.cons/move_noexcept.pass.cpp index f53e1ba6c807..e0669dc70ca9 100644 --- a/test/std/containers/sequences/deque/deque.cons/move_noexcept.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/move_noexcept.pass.cpp @@ -19,6 +19,7 @@ #include <deque> #include <cassert> +#include "test_macros.h" #include "MoveOnly.h" #include "test_allocator.h" @@ -33,15 +34,15 @@ int main() { { 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; - 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; - 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; diff --git a/test/std/containers/sequences/deque/deque.cons/size.pass.cpp b/test/std/containers/sequences/deque/deque.cons/size.pass.cpp index b3fccf6671c9..64b3d811fdc9 100644 --- a/test/std/containers/sequences/deque/deque.cons/size.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/size.pass.cpp @@ -13,8 +13,10 @@ #include <deque> #include <cassert> +#include <cstddef> -#include "../../../stack_allocator.h" +#include "test_macros.h" +#include "test_allocator.h" #include "DefaultOnly.h" #include "min_allocator.h" @@ -22,21 +24,21 @@ template <class T, class Allocator> void test2(unsigned n) { -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 typedef std::deque<T, Allocator> C; typedef typename C::const_iterator const_iterator; assert(DefaultOnly::count == 0); { C d(n, Allocator()); - assert(DefaultOnly::count == n); + assert(static_cast<unsigned>(DefaultOnly::count) == n); assert(d.size() == n); - assert(distance(d.begin(), d.end()) == d.size()); -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + assert(static_cast<std::size_t>(distance(d.begin(), d.end())) == d.size()); for (const_iterator i = d.begin(), e = d.end(); i != e; ++i) assert(*i == T()); -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } assert(DefaultOnly::count == 0); +#else + ((void)n); #endif } @@ -49,13 +51,13 @@ test1(unsigned n) assert(DefaultOnly::count == 0); { C d(n); - assert(DefaultOnly::count == n); + assert(static_cast<unsigned>(DefaultOnly::count) == n); assert(d.size() == n); - assert(distance(d.begin(), d.end()) == d.size()); -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + assert(static_cast<std::size_t>(distance(d.begin(), d.end())) == d.size()); +#if TEST_STD_VER >= 11 for (const_iterator i = d.begin(), e = d.end(); i != e; ++i) assert(*i == T()); -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#endif } assert(DefaultOnly::count == 0); } @@ -64,7 +66,7 @@ template <class T, class Allocator> void test3(unsigned n, Allocator const &alloc = Allocator()) { -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 typedef std::deque<T, Allocator> C; typedef typename C::const_iterator const_iterator; { @@ -72,6 +74,9 @@ test3(unsigned n, Allocator const &alloc = Allocator()) assert(d.size() == n); assert(d.get_allocator() == alloc); } +#else + ((void)n); + ((void)alloc); #endif } @@ -98,13 +103,13 @@ int main() test<DefaultOnly, std::allocator<DefaultOnly> >(4096); test<DefaultOnly, std::allocator<DefaultOnly> >(4097); - test1<DefaultOnly, stack_allocator<DefaultOnly, 4096> >(4095); + LIBCPP_ONLY(test1<DefaultOnly, limited_allocator<DefaultOnly, 4096> >(4095)); #if TEST_STD_VER >= 11 test<DefaultOnly, min_allocator<DefaultOnly> >(4095); #endif -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 test3<DefaultOnly, std::allocator<DefaultOnly>> (1023); test3<int, std::allocator<int>>(1); test3<int, min_allocator<int>> (3); diff --git a/test/std/containers/sequences/deque/deque.cons/size_value.pass.cpp b/test/std/containers/sequences/deque/deque.cons/size_value.pass.cpp index aeda168d19d4..2c8eee7cbe5f 100644 --- a/test/std/containers/sequences/deque/deque.cons/size_value.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/size_value.pass.cpp @@ -13,8 +13,9 @@ #include <deque> #include <cassert> +#include <cstddef> -#include "../../../stack_allocator.h" +#include "test_allocator.h" #include "min_allocator.h" template <class T, class Allocator> @@ -25,7 +26,7 @@ test(unsigned n, const T& x) typedef typename C::const_iterator const_iterator; C d(n, x); assert(d.size() == n); - assert(distance(d.begin(), d.end()) == d.size()); + assert(static_cast<std::size_t>(distance(d.begin(), d.end())) == d.size()); for (const_iterator i = d.begin(), e = d.end(); i != e; ++i) assert(*i == x); } @@ -44,7 +45,7 @@ int main() test<int, std::allocator<int> >(4095, 78); test<int, std::allocator<int> >(4096, 1165); test<int, std::allocator<int> >(4097, 157); - test<int, stack_allocator<int, 4096> >(4095, 90); + LIBCPP_ONLY(test<int, limited_allocator<int, 4096> >(4095, 90)); #if TEST_STD_VER >= 11 test<int, min_allocator<int> >(4095, 90); #endif diff --git a/test/std/containers/sequences/deque/deque.cons/size_value_alloc.pass.cpp b/test/std/containers/sequences/deque/deque.cons/size_value_alloc.pass.cpp index ed8a7e13baa5..6706411c2537 100644 --- a/test/std/containers/sequences/deque/deque.cons/size_value_alloc.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/size_value_alloc.pass.cpp @@ -13,6 +13,7 @@ #include <deque> #include <cassert> +#include <cstddef> #include "min_allocator.h" @@ -25,7 +26,7 @@ test(unsigned n, const T& x, const Allocator& a) C d(n, x, a); assert(d.get_allocator() == a); assert(d.size() == n); - assert(distance(d.begin(), d.end()) == d.size()); + assert(static_cast<std::size_t>(distance(d.begin(), d.end())) == d.size()); for (const_iterator i = d.begin(), e = d.end(); i != e; ++i) assert(*i == x); } diff --git a/test/std/containers/sequences/deque/deque.modifiers/emplace.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/emplace.pass.cpp index 713f2159e598..33a0b6df364d 100644 --- a/test/std/containers/sequences/deque/deque.modifiers/emplace.pass.cpp +++ b/test/std/containers/sequences/deque/deque.modifiers/emplace.pass.cpp @@ -15,6 +15,7 @@ #include <deque> #include <cassert> +#include <cstddef> #include "../../../Emplaceable.h" #include "min_allocator.h" @@ -51,7 +52,7 @@ test(int P, C& c1) CI i = c1.emplace(c1.begin() + P, Emplaceable(1, 2.5)); assert(i == c1.begin() + P); assert(c1.size() == c1_osize + 1); - assert(distance(c1.begin(), c1.end()) == c1.size()); + assert(static_cast<std::size_t>(distance(c1.begin(), c1.end())) == c1.size()); assert(*i == Emplaceable(1, 2.5)); } diff --git a/test/std/containers/sequences/deque/deque.modifiers/emplace_back.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/emplace_back.pass.cpp index 784b3a38553a..e3a35362b186 100644 --- a/test/std/containers/sequences/deque/deque.modifiers/emplace_back.pass.cpp +++ b/test/std/containers/sequences/deque/deque.modifiers/emplace_back.pass.cpp @@ -7,19 +7,21 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <deque> -// template <class... Args> void emplace_back(Args&&... args); +// template <class... Args> reference emplace_back(Args&&... args); #include <deque> +#include <cstddef> #include <cassert> +#include "test_macros.h" #include "../../../Emplaceable.h" #include "min_allocator.h" #include "test_allocator.h" -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - template <class C> C make(int size, int start = 0 ) @@ -47,12 +49,15 @@ void test(C& c1) { typedef typename C::iterator I; + typedef typename C::reference Ref; std::size_t c1_osize = c1.size(); - c1.emplace_back(Emplaceable(1, 2.5)); + Ref ref = c1.emplace_back(Emplaceable(1, 2.5)); assert(c1.size() == c1_osize + 1); - assert(distance(c1.begin(), c1.end()) == c1.size()); + assert(distance(c1.begin(), c1.end()) + == static_cast<std::ptrdiff_t>(c1.size())); I i = c1.end(); assert(*--i == Emplaceable(1, 2.5)); + assert(&(*i) == &ref); } template <class C> @@ -63,11 +68,8 @@ testN(int start, int N) test(c1); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES - int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); @@ -75,7 +77,6 @@ int main() for (int j = 0; j < N; ++j) testN<std::deque<Emplaceable> >(rng[i], rng[j]); } -#if TEST_STD_VER >= 11 { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); @@ -94,6 +95,4 @@ int main() c.emplace_front(1, 2, 3); assert(c.size() == 4); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/deque/deque.modifiers/emplace_front.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/emplace_front.pass.cpp index afc0e4972e38..26c700de7253 100644 --- a/test/std/containers/sequences/deque/deque.modifiers/emplace_front.pass.cpp +++ b/test/std/containers/sequences/deque/deque.modifiers/emplace_front.pass.cpp @@ -7,18 +7,20 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <deque> -// template <class... Args> void emplace_front(Args&&... args); +// template <class... Args> reference emplace_front(Args&&... args); #include <deque> +#include <cstddef> #include <cassert> +#include "test_macros.h" #include "../../../Emplaceable.h" #include "min_allocator.h" -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - template <class C> C make(int size, int start = 0 ) @@ -46,12 +48,15 @@ void test(C& c1) { typedef typename C::iterator I; + typedef typename C::reference Ref; std::size_t c1_osize = c1.size(); - c1.emplace_front(Emplaceable(1, 2.5)); + Ref res_ref = c1.emplace_front(Emplaceable(1, 2.5)); assert(c1.size() == c1_osize + 1); - assert(distance(c1.begin(), c1.end()) == c1.size()); + assert(distance(c1.begin(), c1.end()) + == static_cast<std::ptrdiff_t>(c1.size())); I i = c1.begin(); assert(*i == Emplaceable(1, 2.5)); + assert(&res_ref == &(*i)); } template <class C> @@ -62,11 +67,9 @@ testN(int start, int N) test(c1); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); @@ -74,7 +77,6 @@ int main() for (int j = 0; j < N; ++j) testN<std::deque<Emplaceable> >(rng[i], rng[j]); } -#if TEST_STD_VER >= 11 { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); @@ -82,6 +84,4 @@ int main() for (int j = 0; j < N; ++j) testN<std::deque<Emplaceable, min_allocator<Emplaceable>> >(rng[i], rng[j]); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/deque/deque.modifiers/erase_iter.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/erase_iter.pass.cpp index 116ed9aa4b5a..def032c2705a 100644 --- a/test/std/containers/sequences/deque/deque.modifiers/erase_iter.pass.cpp +++ b/test/std/containers/sequences/deque/deque.modifiers/erase_iter.pass.cpp @@ -15,6 +15,7 @@ #include <algorithm> #include <iterator> #include <cassert> +#include <cstddef> #include "min_allocator.h" @@ -45,17 +46,17 @@ void test(int P, C& c1) { typedef typename C::iterator I; - assert(P < c1.size()); + assert(static_cast<std::size_t>(P) < c1.size()); std::size_t c1_osize = c1.size(); I i = c1.erase(c1.cbegin() + P); assert(i == c1.begin() + P); assert(c1.size() == c1_osize - 1); - assert(distance(c1.begin(), c1.end()) == c1.size()); + assert(static_cast<std::size_t>(distance(c1.begin(), c1.end())) == c1.size()); i = c1.begin(); int j = 0; for (; j < P; ++j, ++i) assert(*i == j); - for (++j; j < c1_osize; ++j, ++i) + for (++j; static_cast<std::size_t>(j) < c1_osize; ++j, ++i) assert(*i == j); } diff --git a/test/std/containers/sequences/deque/deque.modifiers/erase_iter_iter.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/erase_iter_iter.pass.cpp index a53abaf85d33..338c66d81f97 100644 --- a/test/std/containers/sequences/deque/deque.modifiers/erase_iter_iter.pass.cpp +++ b/test/std/containers/sequences/deque/deque.modifiers/erase_iter_iter.pass.cpp @@ -17,6 +17,7 @@ #include <algorithm> #include <iterator> #include <cassert> +#include <cstddef> #include "min_allocator.h" @@ -47,17 +48,17 @@ void test(int P, C& c1, int size) { typedef typename C::iterator I; - assert(P + size <= c1.size()); + assert(static_cast<std::size_t>(P + size) <= c1.size()); std::size_t c1_osize = c1.size(); I i = c1.erase(c1.cbegin() + P, c1.cbegin() + (P + size)); assert(i == c1.begin() + P); assert(c1.size() == c1_osize - size); - assert(distance(c1.begin(), c1.end()) == c1.size()); + assert(static_cast<std::size_t>(distance(c1.begin(), c1.end())) == c1.size()); i = c1.begin(); int j = 0; for (; j < P; ++j, ++i) assert(*i == j); - for (j += size; j < c1_osize; ++j, ++i) + for (j += size; static_cast<std::size_t>(j) < c1_osize; ++j, ++i) assert(*i == j); } diff --git a/test/std/containers/sequences/deque/deque.modifiers/insert_iter_iter.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/insert_iter_iter.pass.cpp index fbe3cb69ccdd..f843ff3a5da4 100644 --- a/test/std/containers/sequences/deque/deque.modifiers/insert_iter_iter.pass.cpp +++ b/test/std/containers/sequences/deque/deque.modifiers/insert_iter_iter.pass.cpp @@ -16,11 +16,12 @@ #include <deque> #include <cassert> +#include <cstddef> #include "test_macros.h" #include "test_iterators.h" #include "MoveOnly.h" -#include "../../../stack_allocator.h" +#include "test_allocator.h" #include "min_allocator.h" template <class C> @@ -57,13 +58,13 @@ test(int P, const C& c0, const C& c2) CI i = c1.insert(c1.begin() + P, BCI(c2.begin()), BCI(c2.end())); assert(i == c1.begin() + P); assert(c1.size() == c1_osize + c2.size()); - assert(distance(c1.begin(), c1.end()) == c1.size()); + assert(static_cast<std::size_t>(distance(c1.begin(), c1.end())) == c1.size()); i = c1.begin(); for (int j = 0; j < P; ++j, ++i) assert(*i == j); - for (int j = 0; j < c2.size(); ++j, ++i) + for (int j = 0; static_cast<std::size_t>(j) < c2.size(); ++j, ++i) assert(*i == j); - for (int j = P; j < c1_osize; ++j, ++i) + for (int j = P; static_cast<std::size_t>(j) < c1_osize; ++j, ++i) assert(*i == j); } { @@ -74,13 +75,13 @@ test(int P, const C& c0, const C& c2) CI i = c1.insert(c1.begin() + P, BCI(c2.begin()), BCI(c2.end())); assert(i == c1.begin() + P); assert(c1.size() == c1_osize + c2.size()); - assert(distance(c1.begin(), c1.end()) == c1.size()); + assert(static_cast<std::size_t>(distance(c1.begin(), c1.end())) == c1.size()); i = c1.begin(); for (int j = 0; j < P; ++j, ++i) assert(*i == j); - for (int j = 0; j < c2.size(); ++j, ++i) + for (int j = 0; static_cast<std::size_t>(j) < c2.size(); ++j, ++i) assert(*i == j); - for (int j = P; j < c1_osize; ++j, ++i) + for (int j = P; static_cast<std::size_t>(j) < c1_osize; ++j, ++i) assert(*i == j); } { @@ -91,13 +92,13 @@ test(int P, const C& c0, const C& c2) CI i = c1.insert(c1.begin() + P, BCI(c2.begin()), BCI(c2.end())); assert(i == c1.begin() + P); assert(c1.size() == c1_osize + c2.size()); - assert(distance(c1.begin(), c1.end()) == c1.size()); + assert(static_cast<std::size_t>(distance(c1.begin(), c1.end())) == c1.size()); i = c1.begin(); for (int j = 0; j < P; ++j, ++i) assert(*i == j); - for (int j = 0; j < c2.size(); ++j, ++i) + for (int j = 0; static_cast<std::size_t>(j) < c2.size(); ++j, ++i) assert(*i == j); - for (int j = P; j < c1_osize; ++j, ++i) + for (int j = P; static_cast<std::size_t>(j) < c1_osize; ++j, ++i) assert(*i == j); } } @@ -172,13 +173,13 @@ testI(int P, C& c1, const C& c2) CI i = c1.insert(c1.begin() + P, ICI(c2.begin()), ICI(c2.end())); assert(i == c1.begin() + P); assert(c1.size() == c1_osize + c2.size()); - assert(distance(c1.begin(), c1.end()) == c1.size()); + assert(static_cast<std::size_t>(distance(c1.begin(), c1.end())) == c1.size()); i = c1.begin(); for (int j = 0; j < P; ++j, ++i) assert(*i == j); - for (int j = 0; j < c2.size(); ++j, ++i) + for (int j = 0; static_cast<std::size_t>(j) < c2.size(); ++j, ++i) assert(*i == j); - for (int j = P; j < c1_osize; ++j, ++i) + for (int j = P; static_cast<std::size_t>(j) < c1_osize; ++j, ++i) assert(*i == j); } @@ -270,7 +271,7 @@ int main() testN<std::deque<int> >(rng[i], rng[j], rng[k]); testNI<std::deque<int> >(1500, 2000, 1000); #if TEST_STD_VER >= 11 - test_move<std::deque<MoveOnly, stack_allocator<MoveOnly, 2000> > >(); + test_move<std::deque<MoveOnly, limited_allocator<MoveOnly, 2000> > >(); #endif } #if TEST_STD_VER >= 11 diff --git a/test/std/containers/sequences/deque/deque.modifiers/insert_rvalue.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/insert_rvalue.pass.cpp index 3c7b0fef28b4..4ce8bbdd57d3 100644 --- a/test/std/containers/sequences/deque/deque.modifiers/insert_rvalue.pass.cpp +++ b/test/std/containers/sequences/deque/deque.modifiers/insert_rvalue.pass.cpp @@ -15,6 +15,7 @@ #include <deque> #include <cassert> +#include <cstddef> #include "MoveOnly.h" #include "min_allocator.h" @@ -51,13 +52,13 @@ test(int P, C& c1, int x) CI i = c1.insert(c1.begin() + P, MoveOnly(x)); assert(i == c1.begin() + P); assert(c1.size() == c1_osize + 1); - assert(distance(c1.begin(), c1.end()) == c1.size()); + assert(static_cast<std::size_t>(distance(c1.begin(), c1.end())) == c1.size()); i = c1.begin(); for (int j = 0; j < P; ++j, ++i) assert(*i == MoveOnly(j)); assert(*i == MoveOnly(x)); ++i; - for (int j = P; j < c1_osize; ++j, ++i) + for (int j = P; static_cast<std::size_t>(j) < c1_osize; ++j, ++i) assert(*i == MoveOnly(j)); } diff --git a/test/std/containers/sequences/deque/deque.modifiers/insert_size_value.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/insert_size_value.pass.cpp index 0efe3b44c604..779b9464e07a 100644 --- a/test/std/containers/sequences/deque/deque.modifiers/insert_size_value.pass.cpp +++ b/test/std/containers/sequences/deque/deque.modifiers/insert_size_value.pass.cpp @@ -15,6 +15,7 @@ #include <deque> #include <cassert> +#include <cstddef> #include "test_macros.h" #include "min_allocator.h" @@ -50,13 +51,13 @@ test(int P, C& c1, int size, int x) CI i = c1.insert(c1.begin() + P, size, x); assert(i == c1.begin() + P); assert(c1.size() == c1_osize + size); - assert(distance(c1.begin(), c1.end()) == c1.size()); + assert(static_cast<std::size_t>(distance(c1.begin(), c1.end())) == c1.size()); i = c1.begin(); for (int j = 0; j < P; ++j, ++i) assert(*i == j); for (int j = 0; j < size; ++j, ++i) assert(*i == x); - for (int j = P; j < c1_osize; ++j, ++i) + for (int j = P; static_cast<std::size_t>(j) < c1_osize; ++j, ++i) assert(*i == j); } @@ -120,7 +121,7 @@ self_reference_test() CI jt = c.cbegin() + j; c.insert(it, 5, *jt); assert(c.size() == 25); - assert(distance(c.begin(), c.end()) == c.size()); + assert(static_cast<std::size_t>(distance(c.begin(), c.end())) == c.size()); it = c.cbegin(); for (int k = 0; k < i; ++k, ++it) assert(*it == k); diff --git a/test/std/containers/sequences/deque/deque.modifiers/insert_value.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/insert_value.pass.cpp index 04c4ca4f7b26..e0c2d0129ef0 100644 --- a/test/std/containers/sequences/deque/deque.modifiers/insert_value.pass.cpp +++ b/test/std/containers/sequences/deque/deque.modifiers/insert_value.pass.cpp @@ -13,6 +13,7 @@ #include <deque> #include <cassert> +#include <cstddef> #include "test_macros.h" #include "min_allocator.h" @@ -48,13 +49,13 @@ test(int P, C& c1, int x) CI i = c1.insert(c1.begin() + P, x); assert(i == c1.begin() + P); assert(c1.size() == c1_osize + 1); - assert(distance(c1.begin(), c1.end()) == c1.size()); + assert(static_cast<std::size_t>(distance(c1.begin(), c1.end())) == c1.size()); i = c1.begin(); for (int j = 0; j < P; ++j, ++i) assert(*i == j); assert(*i == x); ++i; - for (int j = P; j < c1_osize; ++j, ++i) + for (int j = P; static_cast<std::size_t>(j) < c1_osize; ++j, ++i) assert(*i == j); } @@ -102,7 +103,7 @@ self_reference_test() CI jt = c.cbegin() + j; c.insert(it, *jt); assert(c.size() == 21); - assert(distance(c.begin(), c.end()) == c.size()); + assert(static_cast<std::size_t>(distance(c.begin(), c.end())) == c.size()); it = c.cbegin(); for (int k = 0; k < i; ++k, ++it) assert(*it == k); diff --git a/test/std/containers/sequences/deque/deque.modifiers/pop_back.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/pop_back.pass.cpp index aeb62c9d996a..2336b81d4fcd 100644 --- a/test/std/containers/sequences/deque/deque.modifiers/pop_back.pass.cpp +++ b/test/std/containers/sequences/deque/deque.modifiers/pop_back.pass.cpp @@ -13,6 +13,7 @@ #include <deque> #include <cassert> +#include <cstddef> #include "min_allocator.h" @@ -46,9 +47,9 @@ test(C& c1) std::size_t c1_osize = c1.size(); c1.pop_back(); assert(c1.size() == c1_osize - 1); - assert(distance(c1.begin(), c1.end()) == c1.size()); + assert(static_cast<std::size_t>(distance(c1.begin(), c1.end())) == c1.size()); I i = c1.begin(); - for (int j = 0; j < c1.size(); ++j, ++i) + for (int j = 0; static_cast<std::size_t>(j) < c1.size(); ++j, ++i) assert(*i == j); } diff --git a/test/std/containers/sequences/deque/deque.modifiers/pop_front.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/pop_front.pass.cpp index c7a3a625eab6..3de5586ab920 100644 --- a/test/std/containers/sequences/deque/deque.modifiers/pop_front.pass.cpp +++ b/test/std/containers/sequences/deque/deque.modifiers/pop_front.pass.cpp @@ -13,6 +13,7 @@ #include <deque> #include <cassert> +#include <cstddef> #include "min_allocator.h" @@ -46,9 +47,9 @@ test(C& c1) std::size_t c1_osize = c1.size(); c1.pop_front(); assert(c1.size() == c1_osize - 1); - assert(distance(c1.begin(), c1.end()) == c1.size()); + assert(static_cast<std::size_t>(distance(c1.begin(), c1.end())) == c1.size()); I i = c1.begin(); - for (int j = 1; j < c1.size(); ++j, ++i) + for (int j = 1; static_cast<std::size_t>(j) < c1.size(); ++j, ++i) assert(*i == j); } diff --git a/test/std/containers/sequences/deque/deque.modifiers/push_back_exception_safety.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/push_back_exception_safety.pass.cpp index 1fe1da102f37..db22086fd4c9 100644 --- a/test/std/containers/sequences/deque/deque.modifiers/push_back_exception_safety.pass.cpp +++ b/test/std/containers/sequences/deque/deque.modifiers/push_back_exception_safety.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions +// UNSUPPORTED: libcpp-no-exceptions // <deque> // void push_back(const value_type& x); diff --git a/test/std/containers/sequences/deque/deque.modifiers/push_front.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/push_front.pass.cpp index ee4f3d7f9ed7..ef9839721a2e 100644 --- a/test/std/containers/sequences/deque/deque.modifiers/push_front.pass.cpp +++ b/test/std/containers/sequences/deque/deque.modifiers/push_front.pass.cpp @@ -13,6 +13,7 @@ #include <deque> #include <cassert> +#include <cstddef> #include "min_allocator.h" @@ -46,11 +47,11 @@ test(C& c1, int x) std::size_t c1_osize = c1.size(); c1.push_front(x); assert(c1.size() == c1_osize + 1); - assert(distance(c1.begin(), c1.end()) == c1.size()); + assert(static_cast<std::size_t>(distance(c1.begin(), c1.end())) == c1.size()); I i = c1.begin(); assert(*i == x); ++i; - for (int j = 0; j < c1_osize; ++j, ++i) + for (int j = 0; static_cast<std::size_t>(j) < c1_osize; ++j, ++i) assert(*i == j); } diff --git a/test/std/containers/sequences/deque/deque.modifiers/push_front_exception_safety.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/push_front_exception_safety.pass.cpp index 7464870f07e1..7a90c8a75962 100644 --- a/test/std/containers/sequences/deque/deque.modifiers/push_front_exception_safety.pass.cpp +++ b/test/std/containers/sequences/deque/deque.modifiers/push_front_exception_safety.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions +// UNSUPPORTED: libcpp-no-exceptions // <deque> // void push_front(const value_type& x); diff --git a/test/std/containers/sequences/deque/deque.modifiers/push_front_rvalue.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/push_front_rvalue.pass.cpp index ab15ca3326bf..8e734a639344 100644 --- a/test/std/containers/sequences/deque/deque.modifiers/push_front_rvalue.pass.cpp +++ b/test/std/containers/sequences/deque/deque.modifiers/push_front_rvalue.pass.cpp @@ -13,6 +13,7 @@ #include <deque> #include <cassert> +#include <cstddef> #include "MoveOnly.h" #include "min_allocator.h" @@ -49,11 +50,11 @@ test(C& c1, int x) std::size_t c1_osize = c1.size(); c1.push_front(MoveOnly(x)); assert(c1.size() == c1_osize + 1); - assert(distance(c1.begin(), c1.end()) == c1.size()); + assert(static_cast<std::size_t>(distance(c1.begin(), c1.end())) == c1.size()); I i = c1.begin(); assert(*i == MoveOnly(x)); ++i; - for (int j = 0; j < c1_osize; ++j, ++i) + for (int j = 0; static_cast<std::size_t>(j) < c1_osize; ++j, ++i) assert(*i == MoveOnly(j)); } diff --git a/test/std/containers/sequences/deque/deque.special/swap.pass.cpp b/test/std/containers/sequences/deque/deque.special/swap.pass.cpp index ab21f434937e..05bbf878ae0d 100644 --- a/test/std/containers/sequences/deque/deque.special/swap.pass.cpp +++ b/test/std/containers/sequences/deque/deque.special/swap.pass.cpp @@ -65,13 +65,13 @@ int main() int a1[] = {1, 3, 7, 9, 10}; int a2[] = {0, 2, 4, 5, 6, 8, 11}; typedef test_allocator<int> A; - std::deque<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1)); - std::deque<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(2)); + std::deque<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1, 1)); + std::deque<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(1, 2)); swap(c1, c2); assert((c1 == std::deque<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::deque<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0])))); - assert(c2.get_allocator() == A(2)); + assert(c2.get_allocator().get_id() == 2); } { int a1[] = {1, 3, 7, 9, 10}; diff --git a/test/std/containers/sequences/deque/deque.special/swap_noexcept.pass.cpp b/test/std/containers/sequences/deque/deque.special/swap_noexcept.pass.cpp index 2f999e9a7a5d..c0af762fb277 100644 --- a/test/std/containers/sequences/deque/deque.special/swap_noexcept.pass.cpp +++ b/test/std/containers/sequences/deque/deque.special/swap_noexcept.pass.cpp @@ -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 diff --git a/test/std/containers/sequences/deque/iterators.pass.cpp b/test/std/containers/sequences/deque/iterators.pass.cpp index 19d7996f824f..5c7ae01e60e9 100644 --- a/test/std/containers/sequences/deque/iterators.pass.cpp +++ b/test/std/containers/sequences/deque/iterators.pass.cpp @@ -20,6 +20,7 @@ #include <iterator> #include <cassert> +#include "test_macros.h" #include "min_allocator.h" int main() @@ -44,7 +45,7 @@ int main() assert(i == j); } #endif -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 { // N3644 testing std::deque<int>::iterator ii1{}, ii2{}; std::deque<int>::iterator ii4 = ii1; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/copy.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/copy.pass.cpp index 5240afa82b80..65ab7abe23ba 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/copy.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/copy.pass.cpp @@ -15,6 +15,7 @@ #include <cassert> #include <iterator> +#include "test_macros.h" #include "test_allocator.h" #include "min_allocator.h" @@ -27,14 +28,14 @@ int main() const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; C c0(std::begin(t), std::end(t), A(10)); C c = c0; - unsigned n = 0; + int n = 0; for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) assert(*i == n); assert(n == std::end(t) - std::begin(t)); assert(c == c0); assert(c.get_allocator() == A(10)); } -#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE +#if TEST_STD_VER >= 11 { typedef int T; typedef other_allocator<int> A; @@ -42,15 +43,13 @@ int main() const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; C c0(std::begin(t), std::end(t), A(10)); C c = c0; - unsigned n = 0; + int n = 0; for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) assert(*i == n); assert(n == std::end(t) - std::begin(t)); assert(c == c0); assert(c.get_allocator() == A(-2)); } -#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE -#if TEST_STD_VER >= 11 { typedef int T; typedef min_allocator<int> A; @@ -58,7 +57,7 @@ int main() const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; C c0(std::begin(t), std::end(t), A()); C c = c0; - unsigned n = 0; + int n = 0; for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) assert(*i == n); assert(n == std::end(t) - std::begin(t)); diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/copy_alloc.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/copy_alloc.pass.cpp index e4b73bb54e9b..744bba419f37 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/copy_alloc.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/copy_alloc.pass.cpp @@ -27,7 +27,7 @@ int main() const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; C c0(std::begin(t), std::end(t), A(10)); C c(c0, A(9)); - unsigned n = 0; + int n = 0; for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) assert(*i == n); assert(n == std::end(t) - std::begin(t)); @@ -41,7 +41,7 @@ int main() const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; C c0(std::begin(t), std::end(t), A(10)); C c(c0, A(9)); - unsigned n = 0; + int n = 0; for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) assert(*i == n); assert(n == std::end(t) - std::begin(t)); @@ -56,7 +56,7 @@ int main() const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; C c0(std::begin(t), std::end(t), A()); C c(c0, A()); - unsigned n = 0; + int n = 0; for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) assert(*i == n); assert(n == std::end(t) - std::begin(t)); diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/dtor_noexcept.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/dtor_noexcept.pass.cpp index 85d929b4e32e..f70119e3c2af 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/dtor_noexcept.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/dtor_noexcept.pass.cpp @@ -16,6 +16,7 @@ #include <forward_list> #include <cassert> +#include "test_macros.h" #include "MoveOnly.h" #include "test_allocator.h" @@ -43,6 +44,6 @@ int main() } { typedef std::forward_list<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/forwardlist/forwardlist.cons/init.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/init.pass.cpp index c783f60ff4c9..ac73d142a67e 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/init.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/init.pass.cpp @@ -23,7 +23,7 @@ int main() typedef int T; typedef std::forward_list<T> C; C c = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; - unsigned n = 0; + int n = 0; for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) assert(*i == n); assert(n == 10); @@ -33,7 +33,7 @@ int main() typedef int T; typedef std::forward_list<T, min_allocator<T>> C; C c = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; - unsigned n = 0; + int n = 0; for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) assert(*i == n); assert(n == 10); diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/init_alloc.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/init_alloc.pass.cpp index ba9984f969b5..844be20015dd 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/init_alloc.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/init_alloc.pass.cpp @@ -25,7 +25,7 @@ int main() typedef test_allocator<T> A; typedef std::forward_list<T, A> C; C c({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, A(14)); - unsigned n = 0; + int n = 0; for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) assert(*i == n); assert(n == 10); @@ -37,7 +37,7 @@ int main() typedef min_allocator<T> A; typedef std::forward_list<T, A> C; C c({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, A()); - unsigned n = 0; + int n = 0; for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) assert(*i == n); assert(n == 10); diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp index a3e204ec28da..a5948b9ef799 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp @@ -30,7 +30,7 @@ int main() typedef std::move_iterator<T*> I; C c0(I(std::begin(t)), I(std::end(t)), A(10)); C c = std::move(c0); - unsigned n = 0; + int n = 0; for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) assert(*i == n); assert(n == std::end(t) - std::begin(t)); @@ -45,7 +45,7 @@ int main() typedef std::move_iterator<T*> I; C c0(I(std::begin(t)), I(std::end(t)), A(10)); C c = std::move(c0); - unsigned n = 0; + int n = 0; for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) assert(*i == n); assert(n == std::end(t) - std::begin(t)); @@ -61,7 +61,7 @@ int main() typedef std::move_iterator<T*> I; C c0(I(std::begin(t)), I(std::end(t)), A()); C c = std::move(c0); - unsigned n = 0; + int n = 0; for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) assert(*i == n); assert(n == std::end(t) - std::begin(t)); diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/move_assign_noexcept.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/move_assign_noexcept.pass.cpp index b9a6ef7ab8a8..5f278e31c0de 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/move_assign_noexcept.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/move_assign_noexcept.pass.cpp @@ -21,6 +21,7 @@ #include <forward_list> #include <cassert> +#include "test_macros.h" #include "MoveOnly.h" #include "test_allocator.h" @@ -43,10 +44,10 @@ int main() } { typedef std::forward_list<MoveOnly, other_allocator<MoveOnly>> C; - static_assert(std::is_nothrow_move_assignable<C>::value, ""); + LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable<C>::value, ""); } { typedef std::forward_list<MoveOnly, some_alloc<MoveOnly>> C; - static_assert(!std::is_nothrow_move_assignable<C>::value, ""); + LIBCPP_STATIC_ASSERT(!std::is_nothrow_move_assignable<C>::value, ""); } } diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/move_noexcept.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/move_noexcept.pass.cpp index 0359133afc9b..089f6d6807cb 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/move_noexcept.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/move_noexcept.pass.cpp @@ -19,6 +19,7 @@ #include <forward_list> #include <cassert> +#include "test_macros.h" #include "MoveOnly.h" #include "test_allocator.h" @@ -33,15 +34,15 @@ int main() { { 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; - 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; - 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; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/range.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/range.pass.cpp index 3c0f2b8403ca..5a7137463caf 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/range.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/range.pass.cpp @@ -27,7 +27,7 @@ int main() typedef input_iterator<const T*> I; const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; C c(I(std::begin(t)), I(std::end(t))); - unsigned n = 0; + int n = 0; for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) assert(*i == n); assert(n == std::end(t) - std::begin(t)); @@ -39,7 +39,7 @@ int main() typedef input_iterator<const T*> I; const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; C c(I(std::begin(t)), I(std::end(t))); - unsigned n = 0; + int n = 0; for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) assert(*i == n); assert(n == std::end(t) - std::begin(t)); diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/range_alloc.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/range_alloc.pass.cpp index 96a29d24e89c..03d1c4530c53 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/range_alloc.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/range_alloc.pass.cpp @@ -30,7 +30,7 @@ int main() typedef input_iterator<const T*> I; const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; C c(I(std::begin(t)), I(std::end(t)), A(13)); - unsigned n = 0; + int n = 0; for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) assert(*i == n); assert(n == std::end(t) - std::begin(t)); @@ -44,7 +44,7 @@ int main() typedef input_iterator<const T*> I; const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; C c(I(std::begin(t)), I(std::end(t)), A()); - unsigned n = 0; + int n = 0; for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) assert(*i == n); assert(n == std::end(t) - std::begin(t)); diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/size.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/size.pass.cpp index 736d59936aa3..b536ccf4910e 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/size.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/size.pass.cpp @@ -14,18 +14,23 @@ #include <forward_list> #include <cassert> +#include <cstddef> +#include "test_macros.h" #include "DefaultOnly.h" #include "min_allocator.h" template <class T, class Allocator> void check_allocator(unsigned n, Allocator const &alloc = Allocator()) { -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 typedef std::forward_list<T, Allocator> C; C d(n, alloc); assert(d.get_allocator() == alloc); - assert(std::distance(d.begin(), d.end()) == n); + assert(static_cast<std::size_t>(std::distance(d.begin(), d.end())) == n); +#else + ((void)n); + ((void)alloc); #endif } @@ -37,12 +42,14 @@ int main() unsigned N = 10; C c(N); unsigned n = 0; - for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + + for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) { +#if TEST_STD_VER >= 11 assert(*i == T()); #else - ; + ((void)0); #endif + } assert(n == N); } #if TEST_STD_VER >= 11 @@ -53,11 +60,7 @@ int main() C c(N); unsigned n = 0; for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES assert(*i == T()); -#else - ; -#endif assert(n == N); check_allocator<T, min_allocator<T>> ( 0 ); check_allocator<T, min_allocator<T>> ( 3 ); diff --git a/test/std/containers/sequences/forwardlist/forwardlist.iter/iterators.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.iter/iterators.pass.cpp index 925cca4d5e8d..d9daf87fb1a6 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.iter/iterators.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.iter/iterators.pass.cpp @@ -20,6 +20,7 @@ #include <cassert> #include <iterator> +#include "test_macros.h" #include "min_allocator.h" int main() @@ -120,7 +121,7 @@ int main() C::const_iterator j; } #endif -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 { // N3644 testing std::forward_list<int>::iterator ii1{}, ii2{}; std::forward_list<int>::iterator ii4 = ii1; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/emplace_front.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/emplace_front.pass.cpp index 18ed69d33f0b..589e71894b8c 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/emplace_front.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/emplace_front.pass.cpp @@ -7,9 +7,11 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <forward_list> -// template <class... Args> void emplace_front(Args&&... args); +// template <class... Args> reference emplace_front(Args&&... args); #include <forward_list> #include <cassert> @@ -19,32 +21,32 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef Emplaceable T; typedef std::forward_list<T> C; C c; - c.emplace_front(); + T& r1 = c.emplace_front(); assert(c.front() == Emplaceable()); + assert(&r1 == &c.front()); assert(distance(c.begin(), c.end()) == 1); - c.emplace_front(1, 2.5); + T& r2 = c.emplace_front(1, 2.5); assert(c.front() == Emplaceable(1, 2.5)); + assert(&r2 == &c.front()); assert(*next(c.begin()) == Emplaceable()); assert(distance(c.begin(), c.end()) == 2); } -#if TEST_STD_VER >= 11 { typedef Emplaceable T; typedef std::forward_list<T, min_allocator<T>> C; C c; - c.emplace_front(); + T& r1 = c.emplace_front(); assert(c.front() == Emplaceable()); + assert(&r1 == &c.front()); assert(distance(c.begin(), c.end()) == 1); - c.emplace_front(1, 2.5); + T& r2 = c.emplace_front(1, 2.5); assert(c.front() == Emplaceable(1, 2.5)); + assert(&r2 == &c.front()); assert(*next(c.begin()) == Emplaceable()); assert(distance(c.begin(), c.end()) == 2); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_exception_safety.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_exception_safety.pass.cpp index b501347e7893..bff550a0e07c 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_exception_safety.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_exception_safety.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions +// UNSUPPORTED: libcpp-no-exceptions // <forward_list> // void push_front(const value_type& x); diff --git a/test/std/containers/sequences/forwardlist/forwardlist.ops/remove_if.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.ops/remove_if.pass.cpp index ef6f6a0f1887..4c41f53fa94c 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.ops/remove_if.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.ops/remove_if.pass.cpp @@ -14,6 +14,7 @@ #include <forward_list> #include <iterator> #include <cassert> +#include <cstddef> #include "min_allocator.h" #include "counting_predicates.hpp" @@ -37,7 +38,7 @@ int main() Predicate cp(g); c1.remove_if(std::ref(cp)); assert(c1 == c2); - assert(cp.count() == std::distance(std::begin(t1), std::end(t1))); + assert(cp.count() == static_cast<std::size_t>(std::distance(std::begin(t1), std::end(t1)))); } { typedef int T; @@ -49,7 +50,7 @@ int main() Predicate cp(g); c1.remove_if(std::ref(cp)); assert(c1 == c2); - assert(cp.count() == std::distance(std::begin(t1), std::end(t1))); + assert(cp.count() == static_cast<std::size_t>(std::distance(std::begin(t1), std::end(t1)))); } { typedef int T; @@ -62,7 +63,7 @@ int main() Predicate cp(g); c1.remove_if(std::ref(cp)); assert(c1 == c2); - assert(cp.count() == std::distance(std::begin(t1), std::end(t1))); + assert(cp.count() == static_cast<std::size_t>(std::distance(std::begin(t1), std::end(t1)))); } { typedef int T; @@ -86,7 +87,7 @@ int main() Predicate cp(g); c1.remove_if(std::ref(cp)); assert(c1 == c2); - assert(cp.count() == std::distance(std::begin(t1), std::end(t1))); + assert(cp.count() == static_cast<std::size_t>(std::distance(std::begin(t1), std::end(t1)))); } #if TEST_STD_VER >= 11 { @@ -100,7 +101,7 @@ int main() Predicate cp(g); c1.remove_if(std::ref(cp)); assert(c1 == c2); - assert(cp.count() == std::distance(std::begin(t1), std::end(t1))); + assert(cp.count() == static_cast<std::size_t>(std::distance(std::begin(t1), std::end(t1)))); } { typedef int T; @@ -112,7 +113,7 @@ int main() Predicate cp(g); c1.remove_if(std::ref(cp)); assert(c1 == c2); - assert(cp.count() == std::distance(std::begin(t1), std::end(t1))); + assert(cp.count() == static_cast<std::size_t>(std::distance(std::begin(t1), std::end(t1)))); } { typedef int T; @@ -125,7 +126,7 @@ int main() Predicate cp(g); c1.remove_if(std::ref(cp)); assert(c1 == c2); - assert(cp.count() == std::distance(std::begin(t1), std::end(t1))); + assert(cp.count() == static_cast<std::size_t>(std::distance(std::begin(t1), std::end(t1)))); } { typedef int T; @@ -149,7 +150,7 @@ int main() Predicate cp(g); c1.remove_if(std::ref(cp)); assert(c1 == c2); - assert(cp.count() == std::distance(std::begin(t1), std::end(t1))); + assert(cp.count() == static_cast<std::size_t>(std::distance(std::begin(t1), std::end(t1)))); } #endif } diff --git a/test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_flist.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_flist.pass.cpp index c8d4e2d34f1e..eec9e42636a2 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_flist.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_flist.pass.cpp @@ -14,14 +14,15 @@ #include <forward_list> #include <cassert> #include <iterator> +#include <cstddef> #include "min_allocator.h" typedef int T; const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7}; const T t2[] = {10, 11, 12, 13, 14, 15}; -const int size_t1 = std::end(t1) - std::begin(t1); -const int size_t2 = std::end(t2) - std::begin(t2); +const std::ptrdiff_t size_t1 = std::end(t1) - std::begin(t1); +const std::ptrdiff_t size_t2 = std::end(t2) - std::begin(t2); template <class C> void diff --git a/test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_one.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_one.pass.cpp index 349a3872d754..cc86c9625671 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_one.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_one.pass.cpp @@ -14,6 +14,7 @@ #include <forward_list> #include <cassert> #include <iterator> +#include <cstddef> #include "test_macros.h" #include "min_allocator.h" @@ -21,8 +22,8 @@ typedef int T; const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7}; const T t2[] = {10, 11, 12}; -const int size_t1 = std::end(t1) - std::begin(t1); -const int size_t2 = std::end(t2) - std::begin(t2); +const std::ptrdiff_t size_t1 = std::end(t1) - std::begin(t1); +const std::ptrdiff_t size_t2 = std::end(t2) - std::begin(t2); template <class C> void diff --git a/test/std/containers/sequences/forwardlist/forwardlist.spec/member_swap.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.spec/member_swap.pass.cpp index e7a8d048f6f6..242a00bd8608 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.spec/member_swap.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.spec/member_swap.pass.cpp @@ -24,16 +24,16 @@ int main() typedef test_allocator<T> A; typedef std::forward_list<T, A> C; const T t1[] = {0, 1, 2, 3, 4, 5}; - C c1(std::begin(t1), std::end(t1), A(1)); + C c1(std::begin(t1), std::end(t1), A(1, 1)); const T t2[] = {10, 11, 12}; - C c2(std::begin(t2), std::end(t2), A(2)); + C c2(std::begin(t2), std::end(t2), A(1, 2)); c1.swap(c2); assert(distance(c1.begin(), c1.end()) == 3); assert(*next(c1.begin(), 0) == 10); assert(*next(c1.begin(), 1) == 11); assert(*next(c1.begin(), 2) == 12); - assert(c1.get_allocator() == A(1)); + assert(c1.get_allocator().get_id() == 1); assert(distance(c2.begin(), c2.end()) == 6); assert(*next(c2.begin(), 0) == 0); @@ -42,19 +42,19 @@ int main() assert(*next(c2.begin(), 3) == 3); assert(*next(c2.begin(), 4) == 4); assert(*next(c2.begin(), 5) == 5); - assert(c2.get_allocator() == A(2)); + assert(c2.get_allocator().get_id() == 2); } { typedef int T; typedef test_allocator<T> A; typedef std::forward_list<T, A> C; const T t1[] = {0, 1, 2, 3, 4, 5}; - C c1(std::begin(t1), std::end(t1), A(1)); - C c2(A(2)); + C c1(std::begin(t1), std::end(t1), A(1, 1)); + C c2(A(1, 2)); c1.swap(c2); assert(distance(c1.begin(), c1.end()) == 0); - assert(c1.get_allocator() == A(1)); + assert(c1.get_allocator().get_id() == 1); assert(distance(c2.begin(), c2.end()) == 6); assert(*next(c2.begin(), 0) == 0); @@ -63,39 +63,39 @@ int main() assert(*next(c2.begin(), 3) == 3); assert(*next(c2.begin(), 4) == 4); assert(*next(c2.begin(), 5) == 5); - assert(c2.get_allocator() == A(2)); + assert(c2.get_allocator().get_id() == 2); } { typedef int T; typedef test_allocator<T> A; typedef std::forward_list<T, A> C; - C c1(A(1)); + C c1(A(1, 1)); const T t2[] = {10, 11, 12}; - C c2(std::begin(t2), std::end(t2), A(2)); + C c2(std::begin(t2), std::end(t2), A(1, 2)); c1.swap(c2); assert(distance(c1.begin(), c1.end()) == 3); assert(*next(c1.begin(), 0) == 10); assert(*next(c1.begin(), 1) == 11); assert(*next(c1.begin(), 2) == 12); - assert(c1.get_allocator() == A(1)); + assert(c1.get_allocator().get_id() == 1); assert(distance(c2.begin(), c2.end()) == 0); - assert(c2.get_allocator() == A(2)); + assert(c2.get_allocator().get_id() == 2); } { typedef int T; typedef test_allocator<T> A; typedef std::forward_list<T, A> C; - C c1(A(1)); - C c2(A(2)); + C c1(A(1, 1)); + C c2(A(1, 2)); c1.swap(c2); assert(distance(c1.begin(), c1.end()) == 0); - assert(c1.get_allocator() == A(1)); + assert(c1.get_allocator().get_id() == 1); assert(distance(c2.begin(), c2.end()) == 0); - assert(c2.get_allocator() == A(2)); + assert(c2.get_allocator().get_id() == 2); } { diff --git a/test/std/containers/sequences/forwardlist/forwardlist.spec/non_member_swap.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.spec/non_member_swap.pass.cpp index 983d8140571b..44820d9d304e 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.spec/non_member_swap.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.spec/non_member_swap.pass.cpp @@ -25,16 +25,16 @@ int main() typedef test_allocator<T> A; typedef std::forward_list<T, A> C; const T t1[] = {0, 1, 2, 3, 4, 5}; - C c1(std::begin(t1), std::end(t1), A(1)); + C c1(std::begin(t1), std::end(t1), A(1, 1)); const T t2[] = {10, 11, 12}; - C c2(std::begin(t2), std::end(t2), A(2)); + C c2(std::begin(t2), std::end(t2), A(1, 2)); swap(c1, c2); assert(distance(c1.begin(), c1.end()) == 3); assert(*next(c1.begin(), 0) == 10); assert(*next(c1.begin(), 1) == 11); assert(*next(c1.begin(), 2) == 12); - assert(c1.get_allocator() == A(1)); + assert(c1.get_allocator().get_id() == 1); assert(distance(c2.begin(), c2.end()) == 6); assert(*next(c2.begin(), 0) == 0); @@ -43,19 +43,19 @@ int main() assert(*next(c2.begin(), 3) == 3); assert(*next(c2.begin(), 4) == 4); assert(*next(c2.begin(), 5) == 5); - assert(c2.get_allocator() == A(2)); + assert(c2.get_allocator().get_id() == 2); } { typedef int T; typedef test_allocator<T> A; typedef std::forward_list<T, A> C; const T t1[] = {0, 1, 2, 3, 4, 5}; - C c1(std::begin(t1), std::end(t1), A(1)); - C c2(A(2)); + C c1(std::begin(t1), std::end(t1), A(1, 1)); + C c2(A(1, 2)); swap(c1, c2); assert(distance(c1.begin(), c1.end()) == 0); - assert(c1.get_allocator() == A(1)); + assert(c1.get_allocator().get_id() == 1); assert(distance(c2.begin(), c2.end()) == 6); assert(*next(c2.begin(), 0) == 0); @@ -64,39 +64,39 @@ int main() assert(*next(c2.begin(), 3) == 3); assert(*next(c2.begin(), 4) == 4); assert(*next(c2.begin(), 5) == 5); - assert(c2.get_allocator() == A(2)); + assert(c2.get_allocator().get_id() == 2); } { typedef int T; typedef test_allocator<T> A; typedef std::forward_list<T, A> C; - C c1(A(1)); + C c1(A(1, 1)); const T t2[] = {10, 11, 12}; - C c2(std::begin(t2), std::end(t2), A(2)); + C c2(std::begin(t2), std::end(t2), A(1, 2)); swap(c1, c2); assert(distance(c1.begin(), c1.end()) == 3); assert(*next(c1.begin(), 0) == 10); assert(*next(c1.begin(), 1) == 11); assert(*next(c1.begin(), 2) == 12); - assert(c1.get_allocator() == A(1)); + assert(c1.get_allocator().get_id() == 1); assert(distance(c2.begin(), c2.end()) == 0); - assert(c2.get_allocator() == A(2)); + assert(c2.get_allocator().get_id() == 2); } { typedef int T; typedef test_allocator<T> A; typedef std::forward_list<T, A> C; - C c1(A(1)); - C c2(A(2)); + C c1(A(1, 1)); + C c2(A(1, 2)); swap(c1, c2); assert(distance(c1.begin(), c1.end()) == 0); - assert(c1.get_allocator() == A(1)); + assert(c1.get_allocator().get_id() == 1); assert(distance(c2.begin(), c2.end()) == 0); - assert(c2.get_allocator() == A(2)); + assert(c2.get_allocator().get_id() == 2); } { diff --git a/test/std/containers/sequences/forwardlist/forwardlist.spec/swap_noexcept.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.spec/swap_noexcept.pass.cpp index 5f8cf95aa737..c63194f7ee64 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.spec/swap_noexcept.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.spec/swap_noexcept.pass.cpp @@ -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 } diff --git a/test/std/containers/sequences/forwardlist/max_size.pass.cpp b/test/std/containers/sequences/forwardlist/max_size.pass.cpp index a7f39bf90fb8..916d12a9f67c 100644 --- a/test/std/containers/sequences/forwardlist/max_size.pass.cpp +++ b/test/std/containers/sequences/forwardlist/max_size.pass.cpp @@ -11,25 +11,38 @@ // size_type max_size() const; -#include <forward_list> #include <cassert> +#include <forward_list> +#include <limits> +#include <type_traits> -#include "min_allocator.h" +#include "test_allocator.h" +#include "test_macros.h" int main() { { - typedef int T; - typedef std::forward_list<T> C; - C c; - assert(c.max_size() > 0); + typedef limited_allocator<int, 10> A; + typedef std::forward_list<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::forward_list<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); } -#if TEST_STD_VER >= 11 { - typedef int T; - typedef std::forward_list<T, min_allocator<T>> C; - C c; - assert(c.max_size() > 0); + typedef std::forward_list<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())); } -#endif } diff --git a/test/std/containers/sequences/list/iterators.pass.cpp b/test/std/containers/sequences/list/iterators.pass.cpp index fe0ac0799687..8103b2435462 100644 --- a/test/std/containers/sequences/list/iterators.pass.cpp +++ b/test/std/containers/sequences/list/iterators.pass.cpp @@ -20,6 +20,7 @@ #include <cassert> #include <iterator> +#include "test_macros.h" #include "min_allocator.h" struct A @@ -135,9 +136,8 @@ int main() assert(j->first == 3); } #endif -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 { - std::list<int> c; std::list<int>::iterator ii1{}, ii2{}; std::list<int>::iterator ii4 = ii1; std::list<int>::const_iterator cii{}; @@ -150,9 +150,6 @@ int main() assert ( (cii == ii1 )); assert (!(ii1 != cii )); assert (!(cii != ii1 )); - - assert ( ii1 != c.cbegin()); - assert ( cii != c.begin()); } #endif diff --git a/test/std/containers/sequences/list/list.capacity/max_size.pass.cpp b/test/std/containers/sequences/list/list.capacity/max_size.pass.cpp new file mode 100644 index 000000000000..bd1b65e63d70 --- /dev/null +++ b/test/std/containers/sequences/list/list.capacity/max_size.pass.cpp @@ -0,0 +1,47 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <list> + +// size_type max_size() const noexcept + +#include <cassert> +#include <limits> +#include <list> +#include <type_traits> + +#include "test_allocator.h" +#include "test_macros.h" + +int main() { + { + typedef limited_allocator<int, 10> A; + typedef std::list<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::list<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::list<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/list/list.cons/copy.pass.cpp b/test/std/containers/sequences/list/list.cons/copy.pass.cpp index a6abd1f3c30b..fb583a5dd85d 100644 --- a/test/std/containers/sequences/list/list.cons/copy.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/copy.pass.cpp @@ -13,6 +13,8 @@ #include <list> #include <cassert> + +#include "test_macros.h" #include "DefaultOnly.h" #include "test_allocator.h" #include "min_allocator.h" @@ -30,15 +32,13 @@ int main() assert(l2 == l); assert(l2.get_allocator() == l.get_allocator()); } -#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE +#if TEST_STD_VER >= 11 { std::list<int, other_allocator<int> > l(3, 2, other_allocator<int>(5)); std::list<int, other_allocator<int> > l2 = l; assert(l2 == l); assert(l2.get_allocator() == other_allocator<int>(-2)); } -#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE -#if TEST_STD_VER >= 11 { std::list<int, min_allocator<int>> l(3, 2); std::list<int, min_allocator<int>> l2 = l; diff --git a/test/std/containers/sequences/list/list.cons/default_stack_alloc.pass.cpp b/test/std/containers/sequences/list/list.cons/default_stack_alloc.pass.cpp index 4b88580e12ca..a5ff2b0c215b 100644 --- a/test/std/containers/sequences/list/list.cons/default_stack_alloc.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/default_stack_alloc.pass.cpp @@ -13,7 +13,7 @@ #include <list> #include <cassert> -#include "../../../stack_allocator.h" +#include "test_allocator.h" #include "min_allocator.h" int main() @@ -29,7 +29,7 @@ int main() assert(std::distance(l.begin(), l.end()) == 0); } { - std::list<int, stack_allocator<int, 4> > l; + std::list<int, limited_allocator<int, 4> > l; assert(l.size() == 0); assert(std::distance(l.begin(), l.end()) == 0); } diff --git a/test/std/containers/sequences/list/list.cons/dtor_noexcept.pass.cpp b/test/std/containers/sequences/list/list.cons/dtor_noexcept.pass.cpp index 3d11f13358b5..66e40a30d1f1 100644 --- a/test/std/containers/sequences/list/list.cons/dtor_noexcept.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/dtor_noexcept.pass.cpp @@ -16,6 +16,7 @@ #include <list> #include <cassert> +#include "test_macros.h" #include "MoveOnly.h" #include "test_allocator.h" @@ -43,6 +44,6 @@ int main() } { typedef std::list<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/list/list.cons/initializer_list_alloc.pass.cpp b/test/std/containers/sequences/list/list.cons/initializer_list_alloc.pass.cpp index 72add79f6670..6040c648e547 100644 --- a/test/std/containers/sequences/list/list.cons/initializer_list_alloc.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/initializer_list_alloc.pass.cpp @@ -24,7 +24,7 @@ int main() std::list<int, test_allocator<int>> d({3, 4, 5, 6}, test_allocator<int>(3)); assert(d.get_allocator() == test_allocator<int>(3)); assert(d.size() == 4); - std::list<int>::iterator i = d.begin(); + std::list<int, test_allocator<int>>::iterator i = d.begin(); assert(*i++ == 3); assert(*i++ == 4); assert(*i++ == 5); diff --git a/test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp b/test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp index 0dd71d70f85b..3b3c2f7ef1ab 100644 --- a/test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp @@ -15,7 +15,7 @@ #include <list> #include <cassert> #include "test_iterators.h" -#include "../../../stack_allocator.h" +#include "test_allocator.h" #include "min_allocator.h" int main() @@ -43,7 +43,8 @@ int main() } { int a[] = {0, 1, 2, 3}; - std::list<int, stack_allocator<int, sizeof(a)/sizeof(a[0])> > l(input_iterator<const int*>(a), + // Add 2 for implementations that dynamically allocate a sentinel node and container proxy. + std::list<int, limited_allocator<int, sizeof(a)/sizeof(a[0]) + 2> > l(input_iterator<const int*>(a), input_iterator<const int*>(a + sizeof(a)/sizeof(a[0]))); assert(l.size() == sizeof(a)/sizeof(a[0])); assert(std::distance(l.begin(), l.end()) == sizeof(a)/sizeof(a[0])); diff --git a/test/std/containers/sequences/list/list.cons/move_assign_noexcept.pass.cpp b/test/std/containers/sequences/list/list.cons/move_assign_noexcept.pass.cpp index d4f8fde2c8ff..81f78116af2e 100644 --- a/test/std/containers/sequences/list/list.cons/move_assign_noexcept.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/move_assign_noexcept.pass.cpp @@ -21,6 +21,7 @@ #include <list> #include <cassert> +#include "test_macros.h" #include "MoveOnly.h" #include "test_allocator.h" @@ -43,10 +44,10 @@ int main() } { typedef std::list<MoveOnly, other_allocator<MoveOnly>> C; - static_assert(std::is_nothrow_move_assignable<C>::value, ""); + LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable<C>::value, ""); } { typedef std::list<MoveOnly, some_alloc<MoveOnly>> C; - static_assert(!std::is_nothrow_move_assignable<C>::value, ""); + LIBCPP_STATIC_ASSERT(!std::is_nothrow_move_assignable<C>::value, ""); } } diff --git a/test/std/containers/sequences/list/list.cons/move_noexcept.pass.cpp b/test/std/containers/sequences/list/list.cons/move_noexcept.pass.cpp index da2b6a36cef5..b40cb718a3f1 100644 --- a/test/std/containers/sequences/list/list.cons/move_noexcept.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/move_noexcept.pass.cpp @@ -19,6 +19,7 @@ #include <list> #include <cassert> +#include "test_macros.h" #include "MoveOnly.h" #include "test_allocator.h" @@ -33,15 +34,15 @@ int main() { { 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; - 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; - 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; diff --git a/test/std/containers/sequences/list/list.cons/size_type.pass.cpp b/test/std/containers/sequences/list/list.cons/size_type.pass.cpp index 07b4f14dc3a2..95cdeb0c8539 100644 --- a/test/std/containers/sequences/list/list.cons/size_type.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/size_type.pass.cpp @@ -13,23 +13,28 @@ #include <list> #include <cassert> +#include <cstddef> +#include "test_macros.h" #include "DefaultOnly.h" -#include "../../../stack_allocator.h" +#include "test_allocator.h" #include "min_allocator.h" template <class T, class Allocator> void test3(unsigned n, Allocator const &alloc = Allocator()) { -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 typedef std::list<T, Allocator> C; typedef typename C::const_iterator const_iterator; { C d(n, alloc); assert(d.size() == n); - assert(std::distance(d.begin(), d.end()) == n); + assert(static_cast<std::size_t>(std::distance(d.begin(), d.end())) == n); assert(d.get_allocator() == alloc); } +#else + ((void)n); + ((void)alloc); #endif } @@ -48,7 +53,8 @@ int main() assert(*i == 0); } { - std::list<int, stack_allocator<int, 3> > l(3); + // Add 2 for implementations that dynamically allocate a sentinel node and container proxy. + std::list<int, limited_allocator<int, 3 + 2> > l(3); assert(l.size() == 3); assert(std::distance(l.begin(), l.end()) == 3); std::list<int>::const_iterator i = l.begin(); @@ -58,7 +64,7 @@ int main() ++i; assert(*i == 0); } -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 { typedef std::list<int, min_allocator<int> > C; C l(3, min_allocator<int> ()); @@ -73,14 +79,12 @@ int main() test3<int, min_allocator<int>> (3); } #endif -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if TEST_STD_VER >= 11 { std::list<DefaultOnly> l(3); assert(l.size() == 3); assert(std::distance(l.begin(), l.end()) == 3); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -#if TEST_STD_VER >= 11 { std::list<int, min_allocator<int>> l(3); assert(l.size() == 3); @@ -92,12 +96,10 @@ int main() ++i; assert(*i == 0); } -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { std::list<DefaultOnly, min_allocator<DefaultOnly>> l(3); assert(l.size() == 3); assert(std::distance(l.begin(), l.end()) == 3); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif } diff --git a/test/std/containers/sequences/list/list.cons/size_value_alloc.pass.cpp b/test/std/containers/sequences/list/list.cons/size_value_alloc.pass.cpp index ac7b18ea4990..d590626d50f9 100644 --- a/test/std/containers/sequences/list/list.cons/size_value_alloc.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/size_value_alloc.pass.cpp @@ -14,7 +14,7 @@ #include <list> #include <cassert> #include "DefaultOnly.h" -#include "../../../stack_allocator.h" +#include "test_allocator.h" #include "min_allocator.h" int main() @@ -42,7 +42,8 @@ int main() assert(*i == 2); } { - std::list<int, stack_allocator<int, 3> > l(3, 2); + // Add 2 for implementations that dynamically allocate a sentinel node and container proxy. + std::list<int, limited_allocator<int, 3 + 2> > l(3, 2); assert(l.size() == 3); assert(std::distance(l.begin(), l.end()) == 3); std::list<int>::const_iterator i = l.begin(); diff --git a/test/std/containers/sequences/list/list.modifiers/emplace_back.pass.cpp b/test/std/containers/sequences/list/list.modifiers/emplace_back.pass.cpp index 2ff01f1676f2..2aae2b9b09eb 100644 --- a/test/std/containers/sequences/list/list.modifiers/emplace_back.pass.cpp +++ b/test/std/containers/sequences/list/list.modifiers/emplace_back.pass.cpp @@ -7,9 +7,11 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <list> -// template <class... Args> void emplace_back(Args&&... args); +// template <class... Args> reference emplace_back(Args&&... args); #include <list> #include <cassert> @@ -33,34 +35,34 @@ public: int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { std::list<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); - 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); } -#if TEST_STD_VER >= 11 { std::list<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); - 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); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/list/list.modifiers/emplace_front.pass.cpp b/test/std/containers/sequences/list/list.modifiers/emplace_front.pass.cpp index 8a3df46a31e2..994dac258f8c 100644 --- a/test/std/containers/sequences/list/list.modifiers/emplace_front.pass.cpp +++ b/test/std/containers/sequences/list/list.modifiers/emplace_front.pass.cpp @@ -7,9 +7,11 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <list> -// template <class... Args> void emplace_front(Args&&... args); +// template <class... Args> reference emplace_front(Args&&... args); #include <list> #include <cassert> @@ -33,34 +35,34 @@ public: int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { std::list<A> c; - c.emplace_front(2, 3.5); + A& r1 = c.emplace_front(2, 3.5); assert(c.size() == 1); + assert(&r1 == &c.front()); assert(c.front().geti() == 2); assert(c.front().getd() == 3.5); - c.emplace_front(3, 4.5); + A& r2 = c.emplace_front(3, 4.5); assert(c.size() == 2); + assert(&r2 == &c.front()); assert(c.front().geti() == 3); assert(c.front().getd() == 4.5); assert(c.back().geti() == 2); assert(c.back().getd() == 3.5); } -#if TEST_STD_VER >= 11 { std::list<A, min_allocator<A>> c; - c.emplace_front(2, 3.5); + A& r1 = c.emplace_front(2, 3.5); assert(c.size() == 1); + assert(&r1 == &c.front()); assert(c.front().geti() == 2); assert(c.front().getd() == 3.5); - c.emplace_front(3, 4.5); + A& r2 = c.emplace_front(3, 4.5); assert(c.size() == 2); + assert(&r2 == &c.front()); assert(c.front().geti() == 3); assert(c.front().getd() == 4.5); assert(c.back().geti() == 2); assert(c.back().getd() == 3.5); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp b/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp index d85c1f4b9987..9b923696592f 100644 --- a/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp +++ b/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // <list> // iterator insert(const_iterator position, size_type n, const value_type& x); @@ -20,6 +19,7 @@ #include "min_allocator.h" #include "count_new.hpp" +#include "test_macros.h" template <class List> void test() { @@ -29,6 +29,7 @@ void test() { typename List::iterator i = l1.insert(next(l1.cbegin()), 5, 4); assert(i == next(l1.begin())); assert(l1 == List(a2, a2+8)); +#ifndef TEST_HAS_NO_EXCEPTIONS globalMemCounter.throw_after = 4; int save_count = globalMemCounter.outstanding_new; try @@ -41,6 +42,7 @@ void test() { } assert(globalMemCounter.checkOutstandingNewEq(save_count)); assert(l1 == List(a2, a2+8)); +#endif } int main() diff --git a/test/std/containers/sequences/list/list.modifiers/push_back_exception_safety.pass.cpp b/test/std/containers/sequences/list/list.modifiers/push_back_exception_safety.pass.cpp index 8d16142defc0..a644955c8236 100644 --- a/test/std/containers/sequences/list/list.modifiers/push_back_exception_safety.pass.cpp +++ b/test/std/containers/sequences/list/list.modifiers/push_back_exception_safety.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions +// UNSUPPORTED: libcpp-no-exceptions // <list> // void push_back(const value_type& x); diff --git a/test/std/containers/sequences/list/list.modifiers/push_front_exception_safety.pass.cpp b/test/std/containers/sequences/list/list.modifiers/push_front_exception_safety.pass.cpp index aafcceecd471..14379b66913f 100644 --- a/test/std/containers/sequences/list/list.modifiers/push_front_exception_safety.pass.cpp +++ b/test/std/containers/sequences/list/list.modifiers/push_front_exception_safety.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions +// UNSUPPORTED: libcpp-no-exceptions // <list> // void push_front(const value_type& x); diff --git a/test/std/containers/sequences/list/list.ops/remove.pass.cpp b/test/std/containers/sequences/list/list.ops/remove.pass.cpp index fed28e442e12..425070ce29d6 100644 --- a/test/std/containers/sequences/list/list.ops/remove.pass.cpp +++ b/test/std/containers/sequences/list/list.ops/remove.pass.cpp @@ -14,56 +14,70 @@ #include <list> #include <cassert> +#include "test_macros.h" #include "min_allocator.h" struct S { - S(int i) : i_(new int(i)) {} - S(const S &rhs) : i_(new int(*rhs.i_)) {} - S& operator = (const S &rhs) { *i_ = *rhs.i_; return *this; } - ~S () { delete i_; i_ = NULL; } - bool operator == (const S &rhs) const { return *i_ == *rhs.i_; } - int get () const { return *i_; } - int *i_; - }; + S(int i) : i_(new int(i)) {} + S(const S &rhs) : i_(new int(*rhs.i_)) {} + S &operator=(const S &rhs) { + *i_ = *rhs.i_; + return *this; + } + ~S() { + delete i_; + i_ = NULL; + } + bool operator==(const S &rhs) const { return *i_ == *rhs.i_; } + int get() const { return *i_; } + int *i_; +}; - -int main() -{ - { +int main() { + { int a1[] = {1, 2, 3, 4}; int a2[] = {1, 2, 4}; - std::list<int> c(a1, a1+4); + std::list<int> c(a1, a1 + 4); c.remove(3); - assert(c == std::list<int>(a2, a2+3)); - } - { // LWG issue #526 + assert(c == std::list<int>(a2, a2 + 3)); + } + { // LWG issue #526 int a1[] = {1, 2, 1, 3, 5, 8, 11}; - int a2[] = { 2, 3, 5, 8, 11}; - std::list<int> c(a1, a1+7); + int a2[] = {2, 3, 5, 8, 11}; + std::list<int> c(a1, a1 + 7); c.remove(c.front()); - assert(c == std::list<int>(a2, a2+5)); - } - { + assert(c == std::list<int>(a2, a2 + 5)); + } + { int a1[] = {1, 2, 1, 3, 5, 8, 11, 1}; - int a2[] = { 2, 3, 5, 8, 11 }; + int a2[] = {2, 3, 5, 8, 11}; std::list<S> c; - for(int *ip = a1; ip < a1+8; ++ip) - c.push_back(S(*ip)); + for (int *ip = a1; ip < a1 + 8; ++ip) + c.push_back(S(*ip)); c.remove(c.front()); std::list<S>::const_iterator it = c.begin(); - for(int *ip = a2; ip < a2+5; ++ip, ++it) { - assert ( it != c.end()); - assert ( *ip == it->get()); - } - assert ( it == c.end ()); + for (int *ip = a2; ip < a2 + 5; ++ip, ++it) { + assert(it != c.end()); + assert(*ip == it->get()); } + assert(it == c.end()); + } + { + typedef no_default_allocator<int> Alloc; + typedef std::list<int, Alloc> List; + int a1[] = {1, 2, 3, 4}; + int a2[] = {1, 2, 4}; + List c(a1, a1 + 4, Alloc::create()); + c.remove(3); + assert(c == List(a2, a2 + 3, Alloc::create())); + } #if TEST_STD_VER >= 11 - { + { int a1[] = {1, 2, 3, 4}; int a2[] = {1, 2, 4}; - std::list<int, min_allocator<int>> c(a1, a1+4); + std::list<int, min_allocator<int>> c(a1, a1 + 4); c.remove(3); - assert((c == std::list<int, min_allocator<int>>(a2, a2+3))); - } + assert((c == std::list<int, min_allocator<int>>(a2, a2 + 3))); + } #endif } diff --git a/test/std/containers/sequences/list/list.special/swap_noexcept.pass.cpp b/test/std/containers/sequences/list/list.special/swap_noexcept.pass.cpp index 820da4c78f81..512635359c5d 100644 --- a/test/std/containers/sequences/list/list.special/swap_noexcept.pass.cpp +++ b/test/std/containers/sequences/list/list.special/swap_noexcept.pass.cpp @@ -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 diff --git a/test/std/containers/sequences/vector.bool/construct_iter_iter.pass.cpp b/test/std/containers/sequences/vector.bool/construct_iter_iter.pass.cpp index 3d11239702c9..bad80c279d4d 100644 --- a/test/std/containers/sequences/vector.bool/construct_iter_iter.pass.cpp +++ b/test/std/containers/sequences/vector.bool/construct_iter_iter.pass.cpp @@ -14,6 +14,7 @@ #include <vector> #include <cassert> +#include <cstddef> #include "test_macros.h" #include "test_iterators.h" @@ -25,7 +26,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))); for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i, ++first) assert(*i == *first); } diff --git a/test/std/containers/sequences/vector.bool/construct_iter_iter_alloc.pass.cpp b/test/std/containers/sequences/vector.bool/construct_iter_iter_alloc.pass.cpp index 196694d73998..dd4a5c757cb5 100644 --- a/test/std/containers/sequences/vector.bool/construct_iter_iter_alloc.pass.cpp +++ b/test/std/containers/sequences/vector.bool/construct_iter_iter_alloc.pass.cpp @@ -15,6 +15,7 @@ #include <vector> #include <cassert> +#include <cstddef> #include "test_macros.h" #include "test_iterators.h" @@ -26,7 +27,7 @@ test(Iterator first, Iterator last, const typename C::allocator_type& 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))); for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i, ++first) assert(*i == *first); } diff --git a/test/std/containers/sequences/vector.bool/construct_size.pass.cpp b/test/std/containers/sequences/vector.bool/construct_size.pass.cpp index 271e4ee33aa4..1fb86a24ab57 100644 --- a/test/std/containers/sequences/vector.bool/construct_size.pass.cpp +++ b/test/std/containers/sequences/vector.bool/construct_size.pass.cpp @@ -31,6 +31,9 @@ test2(typename C::size_type n, assert(c.get_allocator() == a); 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.bool/copy.pass.cpp b/test/std/containers/sequences/vector.bool/copy.pass.cpp index b3cf9b551f96..7e2efad51894 100644 --- a/test/std/containers/sequences/vector.bool/copy.pass.cpp +++ b/test/std/containers/sequences/vector.bool/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.bool/copy_alloc.pass.cpp b/test/std/containers/sequences/vector.bool/copy_alloc.pass.cpp index aa8646a9b819..56ffb7d52dd7 100644 --- a/test/std/containers/sequences/vector.bool/copy_alloc.pass.cpp +++ b/test/std/containers/sequences/vector.bool/copy_alloc.pass.cpp @@ -22,7 +22,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.bool/dtor_noexcept.pass.cpp b/test/std/containers/sequences/vector.bool/dtor_noexcept.pass.cpp index bd2534ad3de7..b8ff33c5d2e8 100644 --- a/test/std/containers/sequences/vector.bool/dtor_noexcept.pass.cpp +++ b/test/std/containers/sequences/vector.bool/dtor_noexcept.pass.cpp @@ -16,6 +16,7 @@ #include <vector> #include <cassert> +#include "test_macros.h" #include "test_allocator.h" template <class T> @@ -42,6 +43,6 @@ int main() } { typedef std::vector<bool, some_alloc<bool>> 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.bool/emplace_back.pass.cpp b/test/std/containers/sequences/vector.bool/emplace_back.pass.cpp index 2950ee3882f1..24005bec82df 100644 --- a/test/std/containers/sequences/vector.bool/emplace_back.pass.cpp +++ b/test/std/containers/sequences/vector.bool/emplace_back.pass.cpp @@ -11,42 +11,57 @@ // <vector> // vector.bool -// template <class... Args> void emplace_back(Args&&... args); +// template <class... Args> reference emplace_back(Args&&... args); #include <vector> #include <cassert> #include "min_allocator.h" - int main() { { typedef std::vector<bool> C; + typedef C::reference Ref; C c; - c.emplace_back(); + Ref r1 = c.emplace_back(); assert(c.size() == 1); assert(c.front() == false); - c.emplace_back(true); + r1 = true; + assert(c.front() == true); + r1 = false; + Ref r2 = c.emplace_back(true); assert(c.size() == 2); assert(c.front() == false); assert(c.back() == true); - c.emplace_back(1 == 1); + r2 = false; + assert(c.back() == false); + r2 = true; + Ref r3 = c.emplace_back(1 == 1); assert(c.size() == 3); assert(c.front() == false); assert(c[1] == true); assert(c.back() == true); + r3 = false; + assert(c.back() == false); } { typedef std::vector<bool, min_allocator<bool>> C; + typedef C::reference Ref; C c; - c.emplace_back(); + Ref r1 = c.emplace_back(); assert(c.size() == 1); assert(c.front() == false); - c.emplace_back(true); + r1 = true; + assert(c.front() == true); + r1 = false; + Ref r2 = c.emplace_back(true); assert(c.size() == 2); assert(c.front() == false); assert(c.back() == true); + r2 = false; + assert(c.back() == false); + r2 = true; c.emplace_back(1 == 1); assert(c.size() == 3); assert(c.front() == false); diff --git a/test/std/containers/sequences/vector.bool/find.pass.cpp b/test/std/containers/sequences/vector.bool/find.pass.cpp index a4b5537d2949..ffe844e0079c 100644 --- a/test/std/containers/sequences/vector.bool/find.pass.cpp +++ b/test/std/containers/sequences/vector.bool/find.pass.cpp @@ -17,6 +17,7 @@ #include <vector> #include <algorithm> #include <cassert> +#include <cstddef> int main() { @@ -25,7 +26,7 @@ int main() { std::vector<bool> b(i,true); std::vector<bool>::iterator j = std::find(b.begin()+1, b.end(), false); - assert(j-b.begin() == i); + assert(static_cast<std::size_t>(j-b.begin()) == i); assert(b.end() == j); } } @@ -34,7 +35,7 @@ int main() { std::vector<bool> b(i,false); std::vector<bool>::iterator j = std::find(b.begin()+1, b.end(), true); - assert(j-b.begin() == i); + assert(static_cast<std::size_t>(j-b.begin()) == i); assert(b.end() == j); } } diff --git a/test/std/containers/sequences/vector.bool/insert_iter_iter_iter.pass.cpp b/test/std/containers/sequences/vector.bool/insert_iter_iter_iter.pass.cpp index 89fe7a76d409..dc4fe44d5a39 100644 --- a/test/std/containers/sequences/vector.bool/insert_iter_iter_iter.pass.cpp +++ b/test/std/containers/sequences/vector.bool/insert_iter_iter_iter.pass.cpp @@ -15,6 +15,9 @@ #include <vector> #include <cassert> +#include <cstddef> + +#include "test_macros.h" #include "test_iterators.h" #include "min_allocator.h" @@ -28,10 +31,10 @@ int main() input_iterator<const bool*>(a+N)); assert(v.size() == 100 + 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); @@ -47,7 +50,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); @@ -62,10 +65,10 @@ int main() forward_iterator<const bool*>(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); @@ -81,10 +84,10 @@ int main() forward_iterator<const bool*>(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); @@ -98,10 +101,10 @@ int main() input_iterator<const bool*>(a+N)); assert(v.size() == 100 + 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); @@ -114,10 +117,10 @@ int main() forward_iterator<const bool*>(a+N)); assert(v.size() == 100 + 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); diff --git a/test/std/containers/sequences/vector.bool/insert_iter_size_value.pass.cpp b/test/std/containers/sequences/vector.bool/insert_iter_size_value.pass.cpp index 35c57cbd8e42..3ec8952ff150 100644 --- a/test/std/containers/sequences/vector.bool/insert_iter_size_value.pass.cpp +++ b/test/std/containers/sequences/vector.bool/insert_iter_size_value.pass.cpp @@ -14,6 +14,7 @@ #include <vector> #include <cassert> +#include <cstddef> #include "min_allocator.h" @@ -24,7 +25,7 @@ int main() std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, 5, 1); assert(v.size() == 105); 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) @@ -39,7 +40,7 @@ int main() std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, 5, 1); assert(v.size() == sz + 5); 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) @@ -55,7 +56,7 @@ int main() std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, 5, 1); assert(v.size() == sz + 5); 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) @@ -69,7 +70,7 @@ int main() std::vector<bool, min_allocator<bool>>::iterator i = v.insert(v.cbegin() + 10, 5, 1); assert(v.size() == 105); 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) diff --git a/test/std/containers/sequences/vector.bool/insert_iter_value.pass.cpp b/test/std/containers/sequences/vector.bool/insert_iter_value.pass.cpp index 78ffe7ba73cd..6a4a6d4bcb70 100644 --- a/test/std/containers/sequences/vector.bool/insert_iter_value.pass.cpp +++ b/test/std/containers/sequences/vector.bool/insert_iter_value.pass.cpp @@ -14,6 +14,7 @@ #include <vector> #include <cassert> +#include <cstddef> #include "min_allocator.h" @@ -24,7 +25,7 @@ int main() std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, 1); assert(v.size() == 101); 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); @@ -38,7 +39,7 @@ int main() std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, 1); assert(v.size() == sz + 1); 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); @@ -53,7 +54,7 @@ int main() std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, 1); assert(v.size() == sz + 1); 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); @@ -66,7 +67,7 @@ int main() std::vector<bool, min_allocator<bool>>::iterator i = v.insert(v.cbegin() + 10, 1); assert(v.size() == 101); 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); diff --git a/test/std/containers/sequences/vector.bool/iterators.pass.cpp b/test/std/containers/sequences/vector.bool/iterators.pass.cpp index 882ac9be4a5d..10b96480a51b 100644 --- a/test/std/containers/sequences/vector.bool/iterators.pass.cpp +++ b/test/std/containers/sequences/vector.bool/iterators.pass.cpp @@ -20,6 +20,7 @@ #include <cassert> #include <iterator> +#include "test_macros.h" #include "min_allocator.h" int main() @@ -94,7 +95,7 @@ int main() C::const_iterator j; } #endif -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 { // N3644 testing std::vector<bool>::iterator ii1{}, ii2{}; std::vector<bool>::iterator ii4 = ii1; diff --git a/test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp b/test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp index fe53fbfc17e0..dd4bf9e01ea9 100644 --- a/test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp +++ b/test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp @@ -21,6 +21,7 @@ #include <vector> #include <cassert> +#include "test_macros.h" #include "test_allocator.h" template <class T> @@ -60,7 +61,7 @@ int main() { { typedef std::vector<bool> C; - static_assert(std::is_nothrow_move_assignable<C>::value, ""); + LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable<C>::value, ""); } { typedef std::vector<bool, test_allocator<bool>> C; @@ -68,12 +69,12 @@ int main() } { typedef std::vector<bool, other_allocator<bool>> C; - static_assert(std::is_nothrow_move_assignable<C>::value, ""); + LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable<C>::value, ""); } { typedef std::vector<bool, some_alloc<bool>> C; #if TEST_STD_VER > 14 - static_assert( std::is_nothrow_move_assignable<C>::value, ""); + LIBCPP_STATIC_ASSERT( std::is_nothrow_move_assignable<C>::value, ""); #else static_assert(!std::is_nothrow_move_assignable<C>::value, ""); #endif @@ -81,7 +82,7 @@ int main() #if TEST_STD_VER > 14 { // POCMA false, is_always_equal true typedef std::vector<bool, some_alloc2<bool>> C; - static_assert( std::is_nothrow_move_assignable<C>::value, ""); + LIBCPP_STATIC_ASSERT( std::is_nothrow_move_assignable<C>::value, ""); } { // POCMA false, is_always_equal false typedef std::vector<bool, some_alloc3<bool>> C; diff --git a/test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp b/test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp index 2153c7956bfc..3305d95e1ab8 100644 --- a/test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp +++ b/test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp @@ -19,6 +19,7 @@ #include <vector> #include <cassert> +#include "test_macros.h" #include "test_allocator.h" template <class T> @@ -32,21 +33,21 @@ int main() { { 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; - 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; - 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; // In C++17, move constructors for allocators are not allowed to throw #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 static_assert(!std::is_nothrow_move_constructible<C>::value, ""); #endif diff --git a/test/std/containers/sequences/vector.bool/push_back.pass.cpp b/test/std/containers/sequences/vector.bool/push_back.pass.cpp index 3897a438b445..c482f49454be 100644 --- a/test/std/containers/sequences/vector.bool/push_back.pass.cpp +++ b/test/std/containers/sequences/vector.bool/push_back.pass.cpp @@ -14,6 +14,7 @@ #include <vector> #include <cassert> +#include <cstddef> #include "min_allocator.h" @@ -27,7 +28,7 @@ int main() { c.push_back(a[i]); assert(c.size() == i+1); - for (int j = 0; j < c.size(); ++j) + for (std::size_t j = 0; j < c.size(); ++j) assert(c[j] == a[j]); } } @@ -40,7 +41,7 @@ int main() { c.push_back(a[i]); assert(c.size() == i+1); - for (int j = 0; j < c.size(); ++j) + for (std::size_t j = 0; j < c.size(); ++j) assert(c[j] == a[j]); } } diff --git a/test/std/containers/sequences/vector.bool/swap.pass.cpp b/test/std/containers/sequences/vector.bool/swap.pass.cpp index 81af528f2a9a..60b612ae4f90 100644 --- a/test/std/containers/sequences/vector.bool/swap.pass.cpp +++ b/test/std/containers/sequences/vector.bool/swap.pass.cpp @@ -30,15 +30,15 @@ int main() } { typedef test_allocator<bool> A; - std::vector<bool, A> v1(100, true, A(1)); - std::vector<bool, A> v2(200, false, A(2)); + std::vector<bool, A> v1(100, true, A(1, 1)); + std::vector<bool, A> v2(200, false, A(1, 2)); swap(v1, v2); assert(v1.size() == 200); assert(v1.capacity() >= 200); assert(v2.size() == 100); assert(v2.capacity() >= 100); - assert(v1.get_allocator() == A(1)); - assert(v2.get_allocator() == A(2)); + assert(v1.get_allocator().get_id() == 1); + assert(v2.get_allocator().get_id() == 2); } { typedef other_allocator<bool> A; diff --git a/test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp b/test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp index 7ba44453b371..1b68eda2757b 100644 --- a/test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp +++ b/test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp @@ -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 } 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 } |