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"
22 #include "is_transparent.h"
26 typedef std::pair
<const int, double> V
;
28 typedef std::multimap
<int, double> M
;
30 typedef M::iterator R
;
43 M
m(ar
, ar
+sizeof(ar
)/sizeof(ar
[0]));
45 assert(r
== m
.begin());
49 assert(r
== std::next(m
.begin(), 3));
53 assert(r
== std::next(m
.begin(), 6));
58 typedef M::const_iterator R
;
71 const M
m(ar
, ar
+sizeof(ar
)/sizeof(ar
[0]));
73 assert(r
== m
.begin());
77 assert(r
== std::next(m
.begin(), 3));
81 assert(r
== std::next(m
.begin(), 6));
86 #if TEST_STD_VER >= 11
88 typedef std::multimap
<int, double, std::less
<int>, min_allocator
<std::pair
<const int, double>>> M
;
90 typedef M::iterator R
;
103 M
m(ar
, ar
+sizeof(ar
)/sizeof(ar
[0]));
105 assert(r
== m
.begin());
107 assert(r
== m
.end());
109 assert(r
== std::next(m
.begin(), 3));
111 assert(r
== m
.end());
113 assert(r
== std::next(m
.begin(), 6));
115 assert(r
== m
.end());
118 typedef M::const_iterator R
;
131 const M
m(ar
, ar
+sizeof(ar
)/sizeof(ar
[0]));
133 assert(r
== m
.begin());
135 assert(r
== m
.end());
137 assert(r
== std::next(m
.begin(), 3));
139 assert(r
== m
.end());
141 assert(r
== std::next(m
.begin(), 6));
143 assert(r
== m
.end());
147 #if TEST_STD_VER > 11
149 typedef std::multimap
<int, double, std::less
<>> M
;
150 typedef M::iterator R
;
164 M
m(ar
, ar
+sizeof(ar
)/sizeof(ar
[0]));
166 assert(r
== m
.begin());
168 assert(r
== m
.end());
170 assert(r
== std::next(m
.begin(), 3));
172 assert(r
== m
.end());
174 assert(r
== std::next(m
.begin(), 6));
176 assert(r
== m
.end());
178 r
= m
.find(C2Int(5));
179 assert(r
== m
.begin());
180 r
= m
.find(C2Int(6));
181 assert(r
== m
.end());
182 r
= m
.find(C2Int(7));
183 assert(r
== std::next(m
.begin(), 3));
184 r
= m
.find(C2Int(8));
185 assert(r
== m
.end());
186 r
= m
.find(C2Int(9));
187 assert(r
== std::next(m
.begin(), 6));
188 r
= m
.find(C2Int(10));
189 assert(r
== m
.end());
193 typedef PrivateConstructor PC
;
194 typedef std::multimap
<PC
, double, std::less
<>> M
;
195 typedef M::iterator R
;
198 m
.insert ( std::make_pair
<PC
, double> ( PC::make(5), 1 ));
199 m
.insert ( std::make_pair
<PC
, double> ( PC::make(5), 2 ));
200 m
.insert ( std::make_pair
<PC
, double> ( PC::make(5), 3 ));
201 m
.insert ( std::make_pair
<PC
, double> ( PC::make(7), 1 ));
202 m
.insert ( std::make_pair
<PC
, double> ( PC::make(7), 2 ));
203 m
.insert ( std::make_pair
<PC
, double> ( PC::make(7), 3 ));
204 m
.insert ( std::make_pair
<PC
, double> ( PC::make(9), 1 ));
205 m
.insert ( std::make_pair
<PC
, double> ( PC::make(9), 2 ));
206 m
.insert ( std::make_pair
<PC
, double> ( PC::make(9), 3 ));
209 assert(r
== m
.begin());
211 assert(r
== m
.end());
213 assert(r
== std::next(m
.begin(), 3));
215 assert(r
== m
.end());
217 assert(r
== std::next(m
.begin(), 6));
219 assert(r
== m
.end());