1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
12 // iterator erase(const_iterator first, const_iterator last);
17 #include "test_macros.h"
18 #include "min_allocator.h"
22 bool a1
[] = {1, 0, 1};
24 std::vector
<bool> l1(a1
, a1
+3);
25 std::vector
<bool>::iterator i
= l1
.erase(l1
.cbegin(), l1
.cbegin());
26 assert(l1
.size() == 3);
27 assert(distance(l1
.cbegin(), l1
.cend()) == 3);
28 assert(i
== l1
.begin());
31 std::vector
<bool> l1(a1
, a1
+3);
32 std::vector
<bool>::iterator i
= l1
.erase(l1
.cbegin(), next(l1
.cbegin()));
33 assert(l1
.size() == 2);
34 assert(distance(l1
.cbegin(), l1
.cend()) == 2);
35 assert(i
== l1
.begin());
36 assert(l1
== std::vector
<bool>(a1
+1, a1
+3));
39 std::vector
<bool> l1(a1
, a1
+3);
40 std::vector
<bool>::iterator i
= l1
.erase(l1
.cbegin(), next(l1
.cbegin(), 2));
41 assert(l1
.size() == 1);
42 assert(distance(l1
.cbegin(), l1
.cend()) == 1);
43 assert(i
== l1
.begin());
44 assert(l1
== std::vector
<bool>(a1
+2, a1
+3));
47 std::vector
<bool> l1(a1
, a1
+3);
48 std::vector
<bool>::iterator i
= l1
.erase(l1
.cbegin(), next(l1
.cbegin(), 3));
49 assert(l1
.size() == 0);
50 assert(distance(l1
.cbegin(), l1
.cend()) == 0);
51 assert(i
== l1
.begin());
53 #if TEST_STD_VER >= 11
55 std::vector
<bool, min_allocator
<bool>> l1(a1
, a1
+3);
56 std::vector
<bool, min_allocator
<bool>>::iterator i
= l1
.erase(l1
.cbegin(), l1
.cbegin());
57 assert(l1
.size() == 3);
58 assert(distance(l1
.cbegin(), l1
.cend()) == 3);
59 assert(i
== l1
.begin());
62 std::vector
<bool, min_allocator
<bool>> l1(a1
, a1
+3);
63 std::vector
<bool, min_allocator
<bool>>::iterator i
= l1
.erase(l1
.cbegin(), next(l1
.cbegin()));
64 assert(l1
.size() == 2);
65 assert(distance(l1
.cbegin(), l1
.cend()) == 2);
66 assert(i
== l1
.begin());
67 assert((l1
== std::vector
<bool, min_allocator
<bool>>(a1
+1, a1
+3)));
70 std::vector
<bool, min_allocator
<bool>> l1(a1
, a1
+3);
71 std::vector
<bool, min_allocator
<bool>>::iterator i
= l1
.erase(l1
.cbegin(), next(l1
.cbegin(), 2));
72 assert(l1
.size() == 1);
73 assert(distance(l1
.cbegin(), l1
.cend()) == 1);
74 assert(i
== l1
.begin());
75 assert((l1
== std::vector
<bool, min_allocator
<bool>>(a1
+2, a1
+3)));
78 std::vector
<bool, min_allocator
<bool>> l1(a1
, a1
+3);
79 std::vector
<bool, min_allocator
<bool>>::iterator i
= l1
.erase(l1
.cbegin(), next(l1
.cbegin(), 3));
80 assert(l1
.size() == 0);
81 assert(distance(l1
.cbegin(), l1
.cend()) == 0);
82 assert(i
== l1
.begin());