1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
14 // iterator upper_bound(const key_type& k);
15 // const_iterator upper_bound(const key_type& k) const;
20 #include "test_macros.h"
21 #include "min_allocator.h"
22 #include "private_constructor.hpp"
28 typedef std::multiset<int> M;
30 typedef M::iterator R;
43 M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
44 R r = m.upper_bound(4);
45 assert(r == next(m.begin(), 0));
47 assert(r == next(m.begin(), 3));
49 assert(r == next(m.begin(), 3));
51 assert(r == next(m.begin(), 6));
53 assert(r == next(m.begin(), 6));
55 assert(r == next(m.begin(), 9));
56 r = m.upper_bound(11);
57 assert(r == next(m.begin(), 9));
60 typedef M::const_iterator R;
73 const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
74 R r = m.upper_bound(4);
75 assert(r == next(m.begin(), 0));
77 assert(r == next(m.begin(), 3));
79 assert(r == next(m.begin(), 3));
81 assert(r == next(m.begin(), 6));
83 assert(r == next(m.begin(), 6));
85 assert(r == next(m.begin(), 9));
86 r = m.upper_bound(11);
87 assert(r == next(m.begin(), 9));
90 #if TEST_STD_VER >= 11
93 typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
95 typedef M::iterator R;
108 M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
109 R r = m.upper_bound(4);
110 assert(r == next(m.begin(), 0));
111 r = m.upper_bound(5);
112 assert(r == next(m.begin(), 3));
113 r = m.upper_bound(6);
114 assert(r == next(m.begin(), 3));
115 r = m.upper_bound(7);
116 assert(r == next(m.begin(), 6));
117 r = m.upper_bound(8);
118 assert(r == next(m.begin(), 6));
119 r = m.upper_bound(9);
120 assert(r == next(m.begin(), 9));
121 r = m.upper_bound(11);
122 assert(r == next(m.begin(), 9));
125 typedef M::const_iterator R;
138 const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
139 R r = m.upper_bound(4);
140 assert(r == next(m.begin(), 0));
141 r = m.upper_bound(5);
142 assert(r == next(m.begin(), 3));
143 r = m.upper_bound(6);
144 assert(r == next(m.begin(), 3));
145 r = m.upper_bound(7);
146 assert(r == next(m.begin(), 6));
147 r = m.upper_bound(8);
148 assert(r == next(m.begin(), 6));
149 r = m.upper_bound(9);
150 assert(r == next(m.begin(), 9));
151 r = m.upper_bound(11);
152 assert(r == next(m.begin(), 9));
156 #if TEST_STD_VER > 11
159 typedef std::multiset<V, std::less<>> M;
161 typedef M::iterator R;
174 M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
175 R r = m.upper_bound(4);
176 assert(r == next(m.begin(), 0));
177 r = m.upper_bound(5);
178 assert(r == next(m.begin(), 3));
179 r = m.upper_bound(6);
180 assert(r == next(m.begin(), 3));
181 r = m.upper_bound(7);
182 assert(r == next(m.begin(), 6));
183 r = m.upper_bound(8);
184 assert(r == next(m.begin(), 6));
185 r = m.upper_bound(9);
186 assert(r == next(m.begin(), 9));
187 r = m.upper_bound(11);
188 assert(r == next(m.begin(), 9));
192 typedef PrivateConstructor V;
193 typedef std::multiset<V, std::less<>> M;
195 typedef M::iterator R;
197 m.insert ( V::make ( 5 ));
198 m.insert ( V::make ( 5 ));
199 m.insert ( V::make ( 5 ));
200 m.insert ( V::make ( 7 ));
201 m.insert ( V::make ( 7 ));
202 m.insert ( V::make ( 7 ));
203 m.insert ( V::make ( 9 ));
204 m.insert ( V::make ( 9 ));
205 m.insert ( V::make ( 9 ));
207 R r = m.upper_bound(4);
208 assert(r == next(m.begin(), 0));
209 r = m.upper_bound(5);
210 assert(r == next(m.begin(), 3));
211 r = m.upper_bound(6);
212 assert(r == next(m.begin(), 3));
213 r = m.upper_bound(7);
214 assert(r == next(m.begin(), 6));
215 r = m.upper_bound(8);
216 assert(r == next(m.begin(), 6));
217 r = m.upper_bound(9);
218 assert(r == next(m.begin(), 9));
219 r = m.upper_bound(11);
220 assert(r == next(m.begin(), 9));