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 //===----------------------------------------------------------------------===//
13 // size_type erase(const key_type& k);
18 #include "test_macros.h"
19 #include "min_allocator.h"
24 typedef std::set
<int> M
;
26 typedef M::size_type I
;
38 M
m(ar
, ar
+ sizeof(ar
)/sizeof(ar
[0]));
39 assert(m
.size() == 8);
41 assert(m
.size() == 8);
43 assert(*std::next(m
.begin(), 0) == 1);
44 assert(*std::next(m
.begin(), 1) == 2);
45 assert(*std::next(m
.begin(), 2) == 3);
46 assert(*std::next(m
.begin(), 3) == 4);
47 assert(*std::next(m
.begin(), 4) == 5);
48 assert(*std::next(m
.begin(), 5) == 6);
49 assert(*std::next(m
.begin(), 6) == 7);
50 assert(*std::next(m
.begin(), 7) == 8);
53 assert(m
.size() == 7);
55 assert(*std::next(m
.begin(), 0) == 1);
56 assert(*std::next(m
.begin(), 1) == 2);
57 assert(*std::next(m
.begin(), 2) == 3);
58 assert(*std::next(m
.begin(), 3) == 5);
59 assert(*std::next(m
.begin(), 4) == 6);
60 assert(*std::next(m
.begin(), 5) == 7);
61 assert(*std::next(m
.begin(), 6) == 8);
64 assert(m
.size() == 6);
66 assert(*std::next(m
.begin(), 0) == 2);
67 assert(*std::next(m
.begin(), 1) == 3);
68 assert(*std::next(m
.begin(), 2) == 5);
69 assert(*std::next(m
.begin(), 3) == 6);
70 assert(*std::next(m
.begin(), 4) == 7);
71 assert(*std::next(m
.begin(), 5) == 8);
74 assert(m
.size() == 5);
76 assert(*std::next(m
.begin(), 0) == 2);
77 assert(*std::next(m
.begin(), 1) == 3);
78 assert(*std::next(m
.begin(), 2) == 5);
79 assert(*std::next(m
.begin(), 3) == 6);
80 assert(*std::next(m
.begin(), 4) == 7);
83 assert(m
.size() == 4);
85 assert(*std::next(m
.begin(), 0) == 2);
86 assert(*std::next(m
.begin(), 1) == 5);
87 assert(*std::next(m
.begin(), 2) == 6);
88 assert(*std::next(m
.begin(), 3) == 7);
91 assert(m
.size() == 3);
93 assert(*std::next(m
.begin(), 0) == 2);
94 assert(*std::next(m
.begin(), 1) == 5);
95 assert(*std::next(m
.begin(), 2) == 7);
98 assert(m
.size() == 2);
100 assert(*std::next(m
.begin(), 0) == 2);
101 assert(*std::next(m
.begin(), 1) == 5);
104 assert(m
.size() == 1);
106 assert(*std::next(m
.begin(), 0) == 5);
109 assert(m
.size() == 0);
112 #if TEST_STD_VER >= 11
114 typedef std::set
<int, std::less
<int>, min_allocator
<int>> M
;
116 typedef M::size_type I
;
128 M
m(ar
, ar
+ sizeof(ar
)/sizeof(ar
[0]));
129 assert(m
.size() == 8);
131 assert(m
.size() == 8);
133 assert(*std::next(m
.begin(), 0) == 1);
134 assert(*std::next(m
.begin(), 1) == 2);
135 assert(*std::next(m
.begin(), 2) == 3);
136 assert(*std::next(m
.begin(), 3) == 4);
137 assert(*std::next(m
.begin(), 4) == 5);
138 assert(*std::next(m
.begin(), 5) == 6);
139 assert(*std::next(m
.begin(), 6) == 7);
140 assert(*std::next(m
.begin(), 7) == 8);
143 assert(m
.size() == 7);
145 assert(*std::next(m
.begin(), 0) == 1);
146 assert(*std::next(m
.begin(), 1) == 2);
147 assert(*std::next(m
.begin(), 2) == 3);
148 assert(*std::next(m
.begin(), 3) == 5);
149 assert(*std::next(m
.begin(), 4) == 6);
150 assert(*std::next(m
.begin(), 5) == 7);
151 assert(*std::next(m
.begin(), 6) == 8);
154 assert(m
.size() == 6);
156 assert(*std::next(m
.begin(), 0) == 2);
157 assert(*std::next(m
.begin(), 1) == 3);
158 assert(*std::next(m
.begin(), 2) == 5);
159 assert(*std::next(m
.begin(), 3) == 6);
160 assert(*std::next(m
.begin(), 4) == 7);
161 assert(*std::next(m
.begin(), 5) == 8);
164 assert(m
.size() == 5);
166 assert(*std::next(m
.begin(), 0) == 2);
167 assert(*std::next(m
.begin(), 1) == 3);
168 assert(*std::next(m
.begin(), 2) == 5);
169 assert(*std::next(m
.begin(), 3) == 6);
170 assert(*std::next(m
.begin(), 4) == 7);
173 assert(m
.size() == 4);
175 assert(*std::next(m
.begin(), 0) == 2);
176 assert(*std::next(m
.begin(), 1) == 5);
177 assert(*std::next(m
.begin(), 2) == 6);
178 assert(*std::next(m
.begin(), 3) == 7);
181 assert(m
.size() == 3);
183 assert(*std::next(m
.begin(), 0) == 2);
184 assert(*std::next(m
.begin(), 1) == 5);
185 assert(*std::next(m
.begin(), 2) == 7);
188 assert(m
.size() == 2);
190 assert(*std::next(m
.begin(), 0) == 2);
191 assert(*std::next(m
.begin(), 1) == 5);
194 assert(m
.size() == 1);
196 assert(*std::next(m
.begin(), 0) == 5);
199 assert(m
.size() == 0);