[mlir][acc] Introduce MappableType interface (#122146)
[llvm-project.git] / libcxx / test / std / containers / associative / multiset / find.pass.cpp
blobda75b5b00f28625eb4a1a8de26488f4b206b97db
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 // <set>
11 // class multiset
13 // iterator find(const key_type& k);
14 // const_iterator find(const key_type& k) const;
16 #include <set>
17 #include <cassert>
19 #include "test_macros.h"
20 #include "min_allocator.h"
21 #include "private_constructor.h"
23 int main(int, char**)
26 typedef int V;
27 typedef std::multiset<int> M;
29 typedef M::iterator R;
30 V ar[] =
37 10,
38 11,
41 M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
42 R r = m.find(5);
43 assert(r == m.begin());
44 r = m.find(6);
45 assert(r == std::next(m.begin()));
46 r = m.find(7);
47 assert(r == std::next(m.begin(), 2));
48 r = m.find(8);
49 assert(r == std::next(m.begin(), 3));
50 r = m.find(9);
51 assert(r == std::next(m.begin(), 4));
52 r = m.find(10);
53 assert(r == std::next(m.begin(), 5));
54 r = m.find(11);
55 assert(r == std::next(m.begin(), 6));
56 r = m.find(12);
57 assert(r == std::next(m.begin(), 7));
58 r = m.find(4);
59 assert(r == std::next(m.begin(), 8));
62 typedef M::const_iterator R;
63 V ar[] =
70 10,
71 11,
74 const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
75 R r = m.find(5);
76 assert(r == m.begin());
77 r = m.find(6);
78 assert(r == std::next(m.begin()));
79 r = m.find(7);
80 assert(r == std::next(m.begin(), 2));
81 r = m.find(8);
82 assert(r == std::next(m.begin(), 3));
83 r = m.find(9);
84 assert(r == std::next(m.begin(), 4));
85 r = m.find(10);
86 assert(r == std::next(m.begin(), 5));
87 r = m.find(11);
88 assert(r == std::next(m.begin(), 6));
89 r = m.find(12);
90 assert(r == std::next(m.begin(), 7));
91 r = m.find(4);
92 assert(r == std::next(m.begin(), 8));
95 #if TEST_STD_VER >= 11
97 typedef int V;
98 typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
100 typedef M::iterator R;
101 V ar[] =
112 M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
113 R r = m.find(5);
114 assert(r == m.begin());
115 r = m.find(6);
116 assert(r == std::next(m.begin()));
117 r = m.find(7);
118 assert(r == std::next(m.begin(), 2));
119 r = m.find(8);
120 assert(r == std::next(m.begin(), 3));
121 r = m.find(9);
122 assert(r == std::next(m.begin(), 4));
123 r = m.find(10);
124 assert(r == std::next(m.begin(), 5));
125 r = m.find(11);
126 assert(r == std::next(m.begin(), 6));
127 r = m.find(12);
128 assert(r == std::next(m.begin(), 7));
129 r = m.find(4);
130 assert(r == std::next(m.begin(), 8));
133 typedef M::const_iterator R;
134 V ar[] =
145 const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
146 R r = m.find(5);
147 assert(r == m.begin());
148 r = m.find(6);
149 assert(r == std::next(m.begin()));
150 r = m.find(7);
151 assert(r == std::next(m.begin(), 2));
152 r = m.find(8);
153 assert(r == std::next(m.begin(), 3));
154 r = m.find(9);
155 assert(r == std::next(m.begin(), 4));
156 r = m.find(10);
157 assert(r == std::next(m.begin(), 5));
158 r = m.find(11);
159 assert(r == std::next(m.begin(), 6));
160 r = m.find(12);
161 assert(r == std::next(m.begin(), 7));
162 r = m.find(4);
163 assert(r == std::next(m.begin(), 8));
166 #endif
167 #if TEST_STD_VER > 11
169 typedef int V;
170 typedef std::multiset<V, std::less<>> M;
171 typedef M::iterator R;
173 V ar[] =
184 M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
185 R r = m.find(5);
186 assert(r == m.begin());
187 r = m.find(6);
188 assert(r == std::next(m.begin()));
189 r = m.find(7);
190 assert(r == std::next(m.begin(), 2));
191 r = m.find(8);
192 assert(r == std::next(m.begin(), 3));
193 r = m.find(9);
194 assert(r == std::next(m.begin(), 4));
195 r = m.find(10);
196 assert(r == std::next(m.begin(), 5));
197 r = m.find(11);
198 assert(r == std::next(m.begin(), 6));
199 r = m.find(12);
200 assert(r == std::next(m.begin(), 7));
201 r = m.find(4);
202 assert(r == std::next(m.begin(), 8));
206 typedef PrivateConstructor V;
207 typedef std::multiset<V, std::less<>> M;
208 typedef M::iterator R;
210 M m;
211 m.insert ( V::make ( 5 ));
212 m.insert ( V::make ( 6 ));
213 m.insert ( V::make ( 7 ));
214 m.insert ( V::make ( 8 ));
215 m.insert ( V::make ( 9 ));
216 m.insert ( V::make ( 10 ));
217 m.insert ( V::make ( 11 ));
218 m.insert ( V::make ( 12 ));
220 R r = m.find(5);
221 assert(r == m.begin());
222 r = m.find(6);
223 assert(r == std::next(m.begin()));
224 r = m.find(7);
225 assert(r == std::next(m.begin(), 2));
226 r = m.find(8);
227 assert(r == std::next(m.begin(), 3));
228 r = m.find(9);
229 assert(r == std::next(m.begin(), 4));
230 r = m.find(10);
231 assert(r == std::next(m.begin(), 5));
232 r = m.find(11);
233 assert(r == std::next(m.begin(), 6));
234 r = m.find(12);
235 assert(r == std::next(m.begin(), 7));
236 r = m.find(4);
237 assert(r == std::next(m.begin(), 8));
239 #endif
241 return 0;