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 // iterator find(const key_type& k);
14 // const_iterator find(const key_type& k) const;
19 #include "test_macros.h"
20 #include "min_allocator.h"
21 #include "private_constructor.h"
27 typedef std::set
<int> M
;
29 typedef M::iterator R
;
41 M
m(ar
, ar
+sizeof(ar
)/sizeof(ar
[0]));
43 assert(r
== m
.begin());
45 assert(r
== std::next(m
.begin()));
47 assert(r
== std::next(m
.begin(), 2));
49 assert(r
== std::next(m
.begin(), 3));
51 assert(r
== std::next(m
.begin(), 4));
53 assert(r
== std::next(m
.begin(), 5));
55 assert(r
== std::next(m
.begin(), 6));
57 assert(r
== std::next(m
.begin(), 7));
59 assert(r
== std::next(m
.begin(), 8));
62 typedef M::const_iterator R
;
74 const M
m(ar
, ar
+sizeof(ar
)/sizeof(ar
[0]));
76 assert(r
== m
.begin());
78 assert(r
== std::next(m
.begin()));
80 assert(r
== std::next(m
.begin(), 2));
82 assert(r
== std::next(m
.begin(), 3));
84 assert(r
== std::next(m
.begin(), 4));
86 assert(r
== std::next(m
.begin(), 5));
88 assert(r
== std::next(m
.begin(), 6));
90 assert(r
== std::next(m
.begin(), 7));
92 assert(r
== std::next(m
.begin(), 8));
95 #if TEST_STD_VER >= 11
98 typedef std::set
<int, std::less
<int>, min_allocator
<int>> M
;
100 typedef M::iterator R
;
112 M
m(ar
, ar
+sizeof(ar
)/sizeof(ar
[0]));
114 assert(r
== m
.begin());
116 assert(r
== std::next(m
.begin()));
118 assert(r
== std::next(m
.begin(), 2));
120 assert(r
== std::next(m
.begin(), 3));
122 assert(r
== std::next(m
.begin(), 4));
124 assert(r
== std::next(m
.begin(), 5));
126 assert(r
== std::next(m
.begin(), 6));
128 assert(r
== std::next(m
.begin(), 7));
130 assert(r
== std::next(m
.begin(), 8));
133 typedef M::const_iterator R
;
145 const M
m(ar
, ar
+sizeof(ar
)/sizeof(ar
[0]));
147 assert(r
== m
.begin());
149 assert(r
== std::next(m
.begin()));
151 assert(r
== std::next(m
.begin(), 2));
153 assert(r
== std::next(m
.begin(), 3));
155 assert(r
== std::next(m
.begin(), 4));
157 assert(r
== std::next(m
.begin(), 5));
159 assert(r
== std::next(m
.begin(), 6));
161 assert(r
== std::next(m
.begin(), 7));
163 assert(r
== std::next(m
.begin(), 8));
167 #if TEST_STD_VER > 11
170 typedef std::set
<V
, std::less
<>> M
;
171 typedef M::iterator R
;
184 M
m(ar
, ar
+sizeof(ar
)/sizeof(ar
[0]));
186 assert(r
== m
.begin());
188 assert(r
== std::next(m
.begin()));
190 assert(r
== std::next(m
.begin(), 2));
192 assert(r
== std::next(m
.begin(), 3));
194 assert(r
== std::next(m
.begin(), 4));
196 assert(r
== std::next(m
.begin(), 5));
198 assert(r
== std::next(m
.begin(), 6));
200 assert(r
== std::next(m
.begin(), 7));
202 assert(r
== std::next(m
.begin(), 8));
206 typedef PrivateConstructor V
;
207 typedef std::set
<V
, std::less
<>> M
;
208 typedef M::iterator R
;
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 ));
221 assert(r
== m
.begin());
223 assert(r
== std::next(m
.begin()));
225 assert(r
== std::next(m
.begin(), 2));
227 assert(r
== std::next(m
.begin(), 3));
229 assert(r
== std::next(m
.begin(), 4));
231 assert(r
== std::next(m
.begin(), 5));
233 assert(r
== std::next(m
.begin(), 6));
235 assert(r
== std::next(m
.begin(), 7));
237 assert(r
== std::next(m
.begin(), 8));