[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / containers / unord / unord.multimap / local_iterators.compile.fail.cpp
blobf5af791804bddff0a575ad546e5a83f2ba3b82e7
1 //===----------------------------------------------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
9 // <unordered_map>
11 // template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
12 // class Alloc = allocator<pair<const Key, T>>>
13 // class unordered_multimap
15 // local_iterator begin (size_type n);
16 // local_iterator end (size_type n);
17 // const_local_iterator begin (size_type n) const;
18 // const_local_iterator end (size_type n) const;
19 // const_local_iterator cbegin(size_type n) const;
20 // const_local_iterator cend (size_type n) const;
22 #include <unordered_map>
23 #include <string>
24 #include <cassert>
26 #include "test_macros.h"
28 int main(int, char**)
31 typedef std::unordered_multimap<int, std::string> C;
32 typedef std::pair<int, std::string> P;
33 typedef C::local_iterator I;
34 P a[] =
36 P(1, "one"),
37 P(2, "two"),
38 P(3, "three"),
39 P(4, "four"),
40 P(1, "four"),
41 P(2, "four"),
43 C c(a, a + sizeof(a)/sizeof(a[0]));
44 LIBCPP_ASSERT(c.bucket_count() == 7);
45 C::size_type b = c.bucket(0);
46 I i = c.begin(b);
47 I j = c.end(b);
48 assert(std::distance(i, j) == 0);
50 b = c.bucket(1);
51 i = c.begin(b);
52 j = c.end(b);
53 assert(std::distance(i, j) == 2);
54 assert(i->first == 1);
55 assert(i->second == "one");
56 ++i;
57 assert(i->first == 1);
58 assert(i->second == "four");
59 i->first = 2;
61 b = c.bucket(2);
62 i = c.begin(b);
63 j = c.end(b);
64 assert(std::distance(i, j) == 2);
65 assert(i->first == 2);
66 assert(i->second == "two");
67 ++i;
68 assert(i->first == 2);
69 assert(i->second == "four");
71 b = c.bucket(3);
72 i = c.begin(b);
73 j = c.end(b);
74 assert(std::distance(i, j) == 1);
75 assert(i->first == 3);
76 assert(i->second == "three");
78 b = c.bucket(4);
79 i = c.begin(b);
80 j = c.end(b);
81 assert(std::distance(i, j) == 1);
82 assert(i->first == 4);
83 assert(i->second == "four");
85 b = c.bucket(5);
86 i = c.begin(b);
87 j = c.end(b);
88 assert(std::distance(i, j) == 0);
90 b = c.bucket(6);
91 i = c.begin(b);
92 j = c.end(b);
93 assert(std::distance(i, j) == 0);
96 typedef std::unordered_multimap<int, std::string> C;
97 typedef std::pair<int, std::string> P;
98 typedef C::const_local_iterator I;
99 P a[] =
101 P(1, "one"),
102 P(2, "two"),
103 P(3, "three"),
104 P(4, "four"),
105 P(1, "four"),
106 P(2, "four"),
108 const C c(a, a + sizeof(a)/sizeof(a[0]));
109 LIBCPP_ASSERT(c.bucket_count() == 7);
110 C::size_type b = c.bucket(0);
111 I i = c.begin(b);
112 I j = c.end(b);
113 assert(std::distance(i, j) == 0);
115 b = c.bucket(1);
116 i = c.begin(b);
117 j = c.end(b);
118 assert(std::distance(i, j) == 2);
119 assert(i->first == 1);
120 assert(i->second == "one");
121 ++i;
122 assert(i->first == 1);
123 assert(i->second == "four");
125 b = c.bucket(2);
126 i = c.begin(b);
127 j = c.end(b);
128 assert(std::distance(i, j) == 2);
129 assert(i->first == 2);
130 assert(i->second == "two");
131 ++i;
132 assert(i->first == 2);
133 assert(i->second == "four");
135 b = c.bucket(3);
136 i = c.begin(b);
137 j = c.end(b);
138 assert(std::distance(i, j) == 1);
139 assert(i->first == 3);
140 assert(i->second == "three");
142 b = c.bucket(4);
143 i = c.begin(b);
144 j = c.end(b);
145 assert(std::distance(i, j) == 1);
146 assert(i->first == 4);
147 assert(i->second == "four");
149 b = c.bucket(5);
150 i = c.begin(b);
151 j = c.end(b);
152 assert(std::distance(i, j) == 0);
154 b = c.bucket(6);
155 i = c.begin(b);
156 j = c.end(b);
157 assert(std::distance(i, j) == 0);
160 typedef std::unordered_multimap<int, std::string> C;
161 typedef std::pair<int, std::string> P;
162 typedef C::const_local_iterator I;
163 P a[] =
165 P(1, "one"),
166 P(2, "two"),
167 P(3, "three"),
168 P(4, "four"),
169 P(1, "four"),
170 P(2, "four"),
172 C c(a, a + sizeof(a)/sizeof(a[0]));
173 LIBCPP_ASSERT(c.bucket_count() == 7);
174 C::size_type b = c.bucket(0);
175 I i = c.cbegin(b);
176 I j = c.cend(b);
177 assert(std::distance(i, j) == 0);
179 b = c.bucket(1);
180 i = c.cbegin(b);
181 j = c.cend(b);
182 assert(std::distance(i, j) == 2);
183 assert(i->first == 1);
184 assert(i->second == "one");
185 ++i;
186 assert(i->first == 1);
187 assert(i->second == "four");
189 b = c.bucket(2);
190 i = c.cbegin(b);
191 j = c.cend(b);
192 assert(std::distance(i, j) == 2);
193 assert(i->first == 2);
194 assert(i->second == "two");
195 ++i;
196 assert(i->first == 2);
197 assert(i->second == "four");
199 b = c.bucket(3);
200 i = c.cbegin(b);
201 j = c.cend(b);
202 assert(std::distance(i, j) == 1);
203 assert(i->first == 3);
204 assert(i->second == "three");
206 b = c.bucket(4);
207 i = c.cbegin(b);
208 j = c.cend(b);
209 assert(std::distance(i, j) == 1);
210 assert(i->first == 4);
211 assert(i->second == "four");
213 b = c.bucket(5);
214 i = c.cbegin(b);
215 j = c.cend(b);
216 assert(std::distance(i, j) == 0);
218 b = c.bucket(6);
219 i = c.cbegin(b);
220 j = c.cend(b);
221 assert(std::distance(i, j) == 0);
224 typedef std::unordered_multimap<int, std::string> C;
225 typedef std::pair<int, std::string> P;
226 typedef C::const_local_iterator I;
227 P a[] =
229 P(1, "one"),
230 P(2, "two"),
231 P(3, "three"),
232 P(4, "four"),
233 P(1, "four"),
234 P(2, "four"),
236 const C c(a, a + sizeof(a)/sizeof(a[0]));
237 LIBCPP_ASSERT(c.bucket_count() == 7);
238 C::size_type b = c.bucket(0);
239 I i = c.cbegin(b);
240 I j = c.cend(b);
241 assert(std::distance(i, j) == 0);
243 b = c.bucket(1);
244 i = c.cbegin(b);
245 j = c.cend(b);
246 assert(std::distance(i, j) == 2);
247 assert(i->first == 1);
248 assert(i->second == "one");
249 ++i;
250 assert(i->first == 1);
251 assert(i->second == "four");
253 b = c.bucket(2);
254 i = c.cbegin(b);
255 j = c.cend(b);
256 assert(std::distance(i, j) == 2);
257 assert(i->first == 2);
258 assert(i->second == "two");
259 ++i;
260 assert(i->first == 2);
261 assert(i->second == "four");
263 b = c.bucket(3);
264 i = c.cbegin(b);
265 j = c.cend(b);
266 assert(std::distance(i, j) == 1);
267 assert(i->first == 3);
268 assert(i->second == "three");
270 b = c.bucket(4);
271 i = c.cbegin(b);
272 j = c.cend(b);
273 assert(std::distance(i, j) == 1);
274 assert(i->first == 4);
275 assert(i->second == "four");
277 b = c.bucket(5);
278 i = c.cbegin(b);
279 j = c.cend(b);
280 assert(std::distance(i, j) == 0);
282 b = c.bucket(6);
283 i = c.cbegin(b);
284 j = c.cend(b);
285 assert(std::distance(i, j) == 0);
288 return 0;