1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // <vector>
11 // vector<bool>
12 
13 // iterator erase(const_iterator first, const_iterator last);
14 
15 #include <vector>
16 #include <cassert>
17 
18 #include "min_allocator.h"
19 
main()20 int main()
21 {
22     bool a1[] = {1, 0, 1};
23     {
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());
29     }
30     {
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));
37     }
38     {
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));
45     }
46     {
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());
52     }
53 #if __cplusplus >= 201103L
54     {
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());
60     }
61     {
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)));
68     }
69     {
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)));
76     }
77     {
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());
83     }
84 #endif
85 }
86