blob: 8b82ea5b2e1a9cbd695d77e4137415bd90003293 [file] [log] [blame]
Howard Hinnant3e519522010-05-11 19:42:161// -*- C++ -*-
Louis Dionneeb8650a2021-11-17 21:25:012//===----------------------------------------------------------------------===//
Howard Hinnant3e519522010-05-11 19:42:163//
Chandler Carruth57b08b02019-01-19 10:56:404// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Howard Hinnant3e519522010-05-11 19:42:167//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP_ALGORITHM
11#define _LIBCPP_ALGORITHM
12
13/*
14 algorithm synopsis
15
16#include <initializer_list>
17
18namespace std
19{
20
Nikolas Klauserd3729bb2022-01-14 01:55:5121namespace ranges {
Nikolas Klauser1e77b392022-02-11 16:01:5822 template <class I, class F>
Nikolas Klauser807766b2022-02-21 21:48:3623 struct in_fun_result; // since C++20
Nikolas Klauser1e77b392022-02-11 16:01:5824
Nikolas Klauserd3729bb2022-01-14 01:55:5125 template <class I1, class I2>
Nikolas Klauser807766b2022-02-21 21:48:3626 struct in_in_result; // since C++20
Nikolas Klauserf3514af2022-01-25 10:21:4727
28 template <class I1, class I2, class O>
Nikolas Klauser807766b2022-02-21 21:48:3629 struct in_in_out_result; // since C++20
Nikolas Klauser610979b2022-02-03 01:17:0330
31 template <class I, class O1, class O2>
32 struct in_out_out_result; // since C++20
Nikolas Klauser1e77b392022-02-11 16:01:5833
Nikolas Klauser807766b2022-02-21 21:48:3634 template <class I1, class I2>
35 struct min_max_result; // since C++20
36
Nikolas Klauser68f41312022-02-21 22:07:0237 template <class I>
38 struct in_found_result; // since C++20
39
Nikolas Klauser3b470d12022-02-11 12:11:5740 template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
41 indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less> // since C++20
42 constexpr I min_element(I first, S last, Comp comp = {}, Proj proj = {});
43
44 template<forward_range R, class Proj = identity,
45 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less> // since C++20
46 constexpr borrowed_iterator_t<R> min_element(R&& r, Comp comp = {}, Proj proj = {});
Nikolas Klauserc2cd15a2022-03-08 22:12:3547
Nikolas Klauser40f7fca32022-05-22 11:43:3748 template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
49 indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
50 constexpr I ranges::max_element(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
51
52 template<forward_range R, class Proj = identity,
53 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
54 constexpr borrowed_iterator_t<R> ranges::max_element(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
55
56
Nikolas Klauserc2cd15a2022-03-08 22:12:3557 template <input_iterator I1, sentinel_for<_I1> S1, input_iterator I2, sentinel_for<_I2> S2,
58 class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
59 requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
60 constexpr mismatch_result<_I1, _I2>
61 mismatch()(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}) // since C++20
62
63 template <input_range R1, input_range R2,
64 class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
65 requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
66 constexpr mismatch_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>>
67 mismatch(R1&& r1, R2&& r2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}) // since C++20
Nikolas Klauseree0f8c42022-03-12 00:45:3568
Nikolas Klauseree0f8c42022-03-12 00:45:3569 requires indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
70 constexpr I find(I first, S last, const T& value, Proj proj = {}); // since C++20
71
72 template<input_range R, class T, class Proj = identity>
73 requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*>
74 constexpr borrowed_iterator_t<R>
75 find(R&& r, const T& value, Proj proj = {}); // since C++20
76
77 template<input_iterator I, sentinel_for<I> S, class Proj = identity,
78 indirect_unary_predicate<projected<I, Proj>> Pred>
79 constexpr I find_if(I first, S last, Pred pred, Proj proj = {}); // since C++20
80
81 template<input_range R, class Proj = identity,
82 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
83 constexpr borrowed_iterator_t<R>
84 find_if(R&& r, Pred pred, Proj proj = {}); // since C++20
85
86 template<input_iterator I, sentinel_for<I> S, class Proj = identity,
87 indirect_unary_predicate<projected<I, Proj>> Pred>
88 constexpr I find_if_not(I first, S last, Pred pred, Proj proj = {}); // since C++20
89
90 template<input_range R, class Proj = identity,
91 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
92 constexpr borrowed_iterator_t<R>
93 find_if_not(R&& r, Pred pred, Proj proj = {}); // since C++20
Nikolas Klauserf83d8332022-03-18 01:57:0894
Nikolas Klausere476df52022-04-03 07:17:0195 template<class T, class Proj = identity,
96 indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
97 constexpr const T& min(const T& a, const T& b, Comp comp = {}, Proj proj = {}); // since C++20
Nikolas Klauserf83d8332022-03-18 01:57:0898
Nikolas Klausere476df52022-04-03 07:17:0199 template<copyable T, class Proj = identity,
100 indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
101 constexpr T min(initializer_list<T> r, Comp comp = {}, Proj proj = {}); // since C++20
Nikolas Klauserf83d8332022-03-18 01:57:08102
103 template<input_range R, class Proj = identity,
104 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
105 requires indirectly_copyable_storable<iterator_t<R>, range_value_t<R>*>
106 constexpr range_value_t<R>
107 min(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
Nikolas Klausere476df52022-04-03 07:17:01108
109 template<class T, class Proj = identity,
110 indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
111 constexpr const T& max(const T& a, const T& b, Comp comp = {}, Proj proj = {}); // since C++20
112
113 template<copyable T, class Proj = identity,
114 indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
115 constexpr T max(initializer_list<T> r, Comp comp = {}, Proj proj = {}); // since C++20
116
117 template<input_range R, class Proj = identity,
118 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
119 requires indirectly_copyable_storable<iterator_t<R>, range_value_t<R>*>
120 constexpr range_value_t<R>
121 max(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
Nikolas Klauser3ba85482022-04-05 09:05:36122
123 template<class I, class O>
124 using unary_transform_result = in_out_result<I, O>; // since C++20
125
126 template<class I1, class I2, class O>
127 using binary_transform_result = in_in_out_result<I1, I2, O>; // since C++20
128
129 template<input_iterator I, sentinel_for<I> S, weakly_incrementable O,
130 copy_constructible F, class Proj = identity>
131 requires indirectly_writable<O, indirect_result_t<F&, projected<I, Proj>>>
132 constexpr ranges::unary_transform_result<I, O>
133 transform(I first1, S last1, O result, F op, Proj proj = {}); // since C++20
134
135 template<input_range R, weakly_incrementable O, copy_constructible F,
136 class Proj = identity>
137 requires indirectly_writable<O, indirect_result_t<F&, projected<iterator_t<R>, Proj>>>
138 constexpr ranges::unary_transform_result<borrowed_iterator_t<R>, O>
139 transform(R&& r, O result, F op, Proj proj = {}); // since C++20
140
141 template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
142 weakly_incrementable O, copy_constructible F, class Proj1 = identity,
143 class Proj2 = identity>
144 requires indirectly_writable<O, indirect_result_t<F&, projected<I1, Proj1>,
145 projected<I2, Proj2>>>
146 constexpr ranges::binary_transform_result<I1, I2, O>
147 transform(I1 first1, S1 last1, I2 first2, S2 last2, O result,
148 F binary_op, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
149
150 template<input_range R1, input_range R2, weakly_incrementable O,
151 copy_constructible F, class Proj1 = identity, class Proj2 = identity>
152 requires indirectly_writable<O, indirect_result_t<F&, projected<iterator_t<R1>, Proj1>,
153 projected<iterator_t<R2>, Proj2>>>
154 constexpr ranges::binary_transform_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>, O>
155 transform(R1&& r1, R2&& r2, O result,
156 F binary_op, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
Nikolas Klauser1306b102022-04-07 11:02:02157
158 template<input_iterator I, sentinel_for<I> S, class T, class Proj = identity>
159 requires indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
160 constexpr iter_difference_t<I>
161 count(I first, S last, const T& value, Proj proj = {}); // since C++20
162
163 template<input_range R, class T, class Proj = identity>
164 requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*>
165 constexpr range_difference_t<R>
166 count(R&& r, const T& value, Proj proj = {}); // since C++20
167
168 template<input_iterator I, sentinel_for<I> S, class Proj = identity,
169 indirect_unary_predicate<projected<I, Proj>> Pred>
170 constexpr iter_difference_t<I>
171 count_if(I first, S last, Pred pred, Proj proj = {}); // since C++20
172
173 template<input_range R, class Proj = identity,
174 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
175 constexpr range_difference_t<R>
176 count_if(R&& r, Pred pred, Proj proj = {}); // since C++20
Nikolas Klauser58d9ab72022-04-13 20:59:09177
178 template<class T, class Proj = identity,
179 indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
180 constexpr ranges::minmax_result<const T&>
181 minmax(const T& a, const T& b, Comp comp = {}, Proj proj = {}); // since C++20
182
183 template<copyable T, class Proj = identity,
184 indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
185 constexpr ranges::minmax_result<T>
186 minmax(initializer_list<T> r, Comp comp = {}, Proj proj = {}); // since C++20
187
188 template<input_range R, class Proj = identity,
189 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
190 requires indirectly_copyable_storable<iterator_t<R>, range_value_t<R>*>
191 constexpr ranges::minmax_result<range_value_t<R>>
192 minmax(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
193
194 template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
195 indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
196 constexpr ranges::minmax_element_result<I>
197 minmax_element(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
198
199 template<forward_range R, class Proj = identity,
200 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
201 constexpr ranges::minmax_element_result<borrowed_iterator_t<R>>
202 minmax_element(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
Nikolas Klauser1d837502022-04-15 11:43:40203
204 template<class I, class O>
205 using copy_result = in_out_result<I, O>; // since C++20
206
207 template<class I, class O>
208 using copy_n_result = in_out_result<I, O>; // since C++20
209
210 template<class I, class O>
211 using copy_if_result = in_out_result<I, O>; // since C++20
212
213 template<class I1, class I2>
214 using copy_backward_result = in_out_result<I1, I2>; // since C++20
215
216 template<input_iterator I, sentinel_for<I> S, weakly_incrementable O>
217 requires indirectly_copyable<I, O>
218 constexpr ranges::copy_result<I, O> ranges::copy(I first, S last, O result); // since C++20
219
220 template<input_range R, weakly_incrementable O>
221 requires indirectly_copyable<iterator_t<R>, O>
222 constexpr ranges::copy_result<borrowed_iterator_t<R>, O> ranges::copy(R&& r, O result); // since C++20
223
224 template<input_iterator I, weakly_incrementable O>
225 requires indirectly_copyable<I, O>
226 constexpr ranges::copy_n_result<I, O>
227 ranges::copy_n(I first, iter_difference_t<I> n, O result); // since C++20
228
229 template<input_iterator I, sentinel_for<I> S, weakly_incrementable O, class Proj = identity,
230 indirect_unary_predicate<projected<I, Proj>> Pred>
231 requires indirectly_copyable<I, O>
232 constexpr ranges::copy_if_result<I, O>
233 ranges::copy_if(I first, S last, O result, Pred pred, Proj proj = {}); // since C++20
234
235 template<input_range R, weakly_incrementable O, class Proj = identity,
236 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
237 requires indirectly_copyable<iterator_t<R>, O>
238 constexpr ranges::copy_if_result<borrowed_iterator_t<R>, O>
239 ranges::copy_if(R&& r, O result, Pred pred, Proj proj = {}); // since C++20
240
241 template<bidirectional_iterator I1, sentinel_for<I1> S1, bidirectional_iterator I2>
242 requires indirectly_copyable<I1, I2>
243 constexpr ranges::copy_backward_result<I1, I2>
244 ranges::copy_backward(I1 first, S1 last, I2 result); // since C++20
245
246 template<bidirectional_range R, bidirectional_iterator I>
247 requires indirectly_copyable<iterator_t<R>, I>
248 constexpr ranges::copy_backward_result<borrowed_iterator_t<R>, I>
249 ranges::copy_backward(R&& r, I result); // since C++20
Nikolas Klauser80045e92022-05-04 18:27:07250
251 template<class I, class F>
252 using for_each_result = in_fun_result<I, F>; // since C++20
253
254 template<input_iterator I, sentinel_for<I> S, class Proj = identity,
255 indirectly_unary_invocable<projected<I, Proj>> Fun>
256 constexpr ranges::for_each_result<I, Fun>
257 ranges::for_each(I first, S last, Fun f, Proj proj = {}); // since C++20
258
259 template<input_range R, class Proj = identity,
260 indirectly_unary_invocable<projected<iterator_t<R>, Proj>> Fun>
261 constexpr ranges::for_each_result<borrowed_iterator_t<R>, Fun>
262 ranges::for_each(R&& r, Fun f, Proj proj = {}); // since C++20
263
264 template<input_iterator I, class Proj = identity,
265 indirectly_unary_invocable<projected<I, Proj>> Fun>
266 constexpr ranges::for_each_n_result<I, Fun>
267 ranges::for_each_n(I first, iter_difference_t<I> n, Fun f, Proj proj = {}); // since C++20
Nikolas Klauser37ba1b92022-05-04 12:19:09268
269 template<input_iterator I, sentinel_for<I> S, class Proj = identity,
270 indirect_unary_predicate<projected<I, Proj>> Pred>
271 constexpr bool ranges::is_partitioned(I first, S last, Pred pred, Proj proj = {}); // since C++20
272
273 template<input_range R, class Proj = identity,
274 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
275 constexpr bool ranges::is_partitioned(R&& r, Pred pred, Proj proj = {}); // since C++20
276
Nikolas Klauser1d1a1912022-05-24 08:32:50277
278 template<bidirectional_iterator I, sentinel_for<I> S>
279 requires permutable<I>
280 constexpr I ranges::reverse(I first, S last); // since C++20
281
282 template<bidirectional_range R>
283 requires permutable<iterator_t<R>>
284 constexpr borrowed_iterator_t<R> ranges::reverse(R&& r); // since C++20
285
Nikolas Klauser7af89a32022-05-21 16:26:29286 template<class T, output_iterator<const T&> O, sentinel_for<O> S>
287 constexpr O ranges::fill(O first, S last, const T& value); // since C++20
288
289 template<class T, output_range<const T&> R>
290 constexpr borrowed_iterator_t<R> ranges::fill(R&& r, const T& value); // since C++20
291
292 template<class T, output_iterator<const T&> O>
293 constexpr O ranges::fill_n(O first, iter_difference_t<O> n, const T& value); // since C++20
Nikolas Klauser569d6632022-05-25 09:09:43294
295 template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
296 class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
297 requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
298 constexpr bool ranges::equal(I1 first1, S1 last1, I2 first2, S2 last2,
299 Pred pred = {},
300 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
301
302 template<input_range R1, input_range R2, class Pred = ranges::equal_to,
303 class Proj1 = identity, class Proj2 = identity>
304 requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
305 constexpr bool ranges::equal(R1&& r1, R2&& r2, Pred pred = {},
306 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
307
Nikolas Klauser0e3dc1a2022-05-26 14:42:46308 template<input_iterator I, sentinel_for<I> S, class Proj = identity,
309 indirect_unary_predicate<projected<I, Proj>> Pred>
310 constexpr bool ranges::all_of(I first, S last, Pred pred, Proj proj = {}); // since C++20
311
312 template<input_range R, class Proj = identity,
313 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
314 constexpr bool ranges::all_of(R&& r, Pred pred, Proj proj = {}); // since C++20
315
316 template<input_iterator I, sentinel_for<I> S, class Proj = identity,
317 indirect_unary_predicate<projected<I, Proj>> Pred>
318 constexpr bool ranges::any_of(I first, S last, Pred pred, Proj proj = {}); // since C++20
319
320 template<input_range R, class Proj = identity,
321 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
322 constexpr bool ranges::any_of(R&& r, Pred pred, Proj proj = {}); // since C++20
323
324 template<input_iterator I, sentinel_for<I> S, class Proj = identity,
325 indirect_unary_predicate<projected<I, Proj>> Pred>
326 constexpr bool ranges::none_of(I first, S last, Pred pred, Proj proj = {}); // since C++20
327
328 template<input_range R, class Proj = identity,
329 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
330 constexpr bool ranges::none_of(R&& r, Pred pred, Proj proj = {}); // since C++20
331
Nikolas Klauser11e3ad22022-05-26 14:08:55332 template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
333 indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
334 constexpr bool ranges::is_sorted(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
335
336 template<forward_range R, class Proj = identity,
337 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
338 constexpr bool ranges::is_sorted(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
339
340 template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
341 indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
342 constexpr I ranges::is_sorted_until(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
343
344 template<forward_range R, class Proj = identity,
345 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
346 constexpr borrowed_iterator_t<R>
347 ranges::is_sorted_until(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
Nikolas Klauser81715862022-06-05 19:15:16348
349 template<forward_iterator I, sentinel_for<I> S, class T, class Proj = identity,
350 indirect_strict_weak_order<const T*, projected<I, Proj>> Comp = ranges::less>
351 constexpr I upper_bound(I first, S last, const T& value, Comp comp = {}, Proj proj = {}); // since C++20
352
353 template<forward_range R, class T, class Proj = identity,
354 indirect_strict_weak_order<const T*, projected<iterator_t<R>, Proj>> Comp =
355 ranges::less>
356 constexpr borrowed_iterator_t<R>
357 upper_bound(R&& r, const T& value, Comp comp = {}, Proj proj = {}); // since C++20
358
359 template<forward_iterator I, sentinel_for<I> S, class T, class Proj = identity,
360 indirect_strict_weak_order<const T*, projected<I, Proj>> Comp = ranges::less>
361 constexpr I lower_bound(I first, S last, const T& value, Comp comp = {},
362 Proj proj = {}); // since C++20
363 template<forward_range R, class T, class Proj = identity,
364 indirect_strict_weak_order<const T*, projected<iterator_t<R>, Proj>> Comp =
365 ranges::less>
366 constexpr borrowed_iterator_t<R>
367 lower_bound(R&& r, const T& value, Comp comp = {}, Proj proj = {}); // since C++20
368
369 template<forward_iterator I, sentinel_for<I> S, class T, class Proj = identity,
370 indirect_strict_weak_order<const T*, projected<I, Proj>> Comp = ranges::less>
371 constexpr bool binary_search(I first, S last, const T& value, Comp comp = {},
372 Proj proj = {}); // since C++20
Nikolas Klauserb79b2b62022-06-06 11:57:34373
Nikolas Klauser81715862022-06-05 19:15:16374 template<forward_range R, class T, class Proj = identity,
375 indirect_strict_weak_order<const T*, projected<iterator_t<R>, Proj>> Comp =
376 ranges::less>
377 constexpr bool binary_search(R&& r, const T& value, Comp comp = {},
378 Proj proj = {}); // since C++20
Nikolas Klauserb79b2b62022-06-06 11:57:34379 template<input_iterator I1, sentinel_for<I1> S1, forward_iterator I2, sentinel_for<I2> S2,
380 class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
381 requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
382 constexpr I1 ranges::find_first_of(I1 first1, S1 last1, I2 first2, S2 last2,
383 Pred pred = {},
384 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
385
386 template<input_range R1, forward_range R2,
387 class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
388 requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
389 constexpr borrowed_iterator_t<R1>
390 ranges::find_first_of(R1&& r1, R2&& r2,
391 Pred pred = {},
392 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
Nikolas Klauser81715862022-06-05 19:15:16393
Nikolas Klauser916e9052022-06-08 10:14:12394 template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
395 indirect_binary_predicate<projected<I, Proj>,
396 projected<I, Proj>> Pred = ranges::equal_to>
397 constexpr I ranges::adjacent_find(I first, S last, Pred pred = {}, Proj proj = {}); // since C+20
398
399 template<forward_range R, class Proj = identity,
400 indirect_binary_predicate<projected<iterator_t<R>, Proj>,
401 projected<iterator_t<R>, Proj>> Pred = ranges::equal_to>
402 constexpr borrowed_iterator_t<R> ranges::adjacent_find(R&& r, Pred pred = {}, Proj proj = {}); // since C++20
403
Nikolas Klauserff6d5de2022-06-07 07:42:10404 template<input_iterator I, sentinel_for<I> S, class T1, class T2, class Proj = identity>
405 requires indirectly_writable<I, const T2&> &&
406 indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T1*>
407 constexpr I
408 ranges::replace(I first, S last, const T1& old_value, const T2& new_value, Proj proj = {}); // since C++20
409
410 template<input_range R, class T1, class T2, class Proj = identity>
411 requires indirectly_writable<iterator_t<R>, const T2&> &&
412 indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T1*>
413 constexpr borrowed_iterator_t<R>
414 ranges::replace(R&& r, const T1& old_value, const T2& new_value, Proj proj = {}); // since C++20
415
416 template<input_iterator I, sentinel_for<I> S, class T, class Proj = identity,
417 indirect_unary_predicate<projected<I, Proj>> Pred>
418 requires indirectly_writable<I, const T&>
419 constexpr I ranges::replace_if(I first, S last, Pred pred, const T& new_value, Proj proj = {}); // since C++20
420
421 template<input_range R, class T, class Proj = identity,
422 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
423 requires indirectly_writable<iterator_t<R>, const T&>
424 constexpr borrowed_iterator_t<R>
425 ranges::replace_if(R&& r, Pred pred, const T& new_value, Proj proj = {}); // since C++20
426
Nikolas Klauserd3729bb2022-01-14 01:55:51427}
428
Marshall Clow706ffef2018-01-15 17:20:36429 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16430 all_of(InputIterator first, InputIterator last, Predicate pred);
431
432template <class InputIterator, class Predicate>
Marshall Clow706ffef2018-01-15 17:20:36433 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16434 any_of(InputIterator first, InputIterator last, Predicate pred);
435
436template <class InputIterator, class Predicate>
Marshall Clow706ffef2018-01-15 17:20:36437 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16438 none_of(InputIterator first, InputIterator last, Predicate pred);
439
440template <class InputIterator, class Function>
Marshall Clow1b9a4ff2018-01-22 20:44:33441 constexpr Function // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16442 for_each(InputIterator first, InputIterator last, Function f);
443
Marshall Clowd5c65ff2017-05-25 02:29:54444template<class InputIterator, class Size, class Function>
Marshall Clow1b9a4ff2018-01-22 20:44:33445 constexpr InputIterator // constexpr in C++20
446 for_each_n(InputIterator first, Size n, Function f); // C++17
Marshall Clowd5c65ff2017-05-25 02:29:54447
Howard Hinnant3e519522010-05-11 19:42:16448template <class InputIterator, class T>
Marshall Clow86944282018-01-15 19:26:05449 constexpr InputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16450 find(InputIterator first, InputIterator last, const T& value);
451
452template <class InputIterator, class Predicate>
Marshall Clow86944282018-01-15 19:26:05453 constexpr InputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16454 find_if(InputIterator first, InputIterator last, Predicate pred);
455
456template<class InputIterator, class Predicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18457 constexpr InputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16458 find_if_not(InputIterator first, InputIterator last, Predicate pred);
459
460template <class ForwardIterator1, class ForwardIterator2>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18461 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16462 find_end(ForwardIterator1 first1, ForwardIterator1 last1,
463 ForwardIterator2 first2, ForwardIterator2 last2);
464
465template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18466 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16467 find_end(ForwardIterator1 first1, ForwardIterator1 last1,
468 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
469
470template <class ForwardIterator1, class ForwardIterator2>
Marshall Clow86944282018-01-15 19:26:05471 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16472 find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
473 ForwardIterator2 first2, ForwardIterator2 last2);
474
475template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow86944282018-01-15 19:26:05476 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16477 find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
478 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
479
480template <class ForwardIterator>
Marshall Clow86944282018-01-15 19:26:05481 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16482 adjacent_find(ForwardIterator first, ForwardIterator last);
483
484template <class ForwardIterator, class BinaryPredicate>
Marshall Clow86944282018-01-15 19:26:05485 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16486 adjacent_find(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
487
488template <class InputIterator, class T>
Marshall Clow056f15e2018-01-15 19:40:34489 constexpr typename iterator_traits<InputIterator>::difference_type // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16490 count(InputIterator first, InputIterator last, const T& value);
491
492template <class InputIterator, class Predicate>
Marshall Clow056f15e2018-01-15 19:40:34493 constexpr typename iterator_traits<InputIterator>::difference_type // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16494 count_if(InputIterator first, InputIterator last, Predicate pred);
495
496template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:10497 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16498 mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
499
Marshall Clow0b0bbd22013-05-09 21:14:23500template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:10501 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Aditya Kumar331fb802016-08-25 11:52:38502 mismatch(InputIterator1 first1, InputIterator1 last1,
Marshall Clow0b0bbd22013-05-09 21:14:23503 InputIterator2 first2, InputIterator2 last2); // **C++14**
504
Howard Hinnant3e519522010-05-11 19:42:16505template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:10506 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16507 mismatch(InputIterator1 first1, InputIterator1 last1,
508 InputIterator2 first2, BinaryPredicate pred);
509
Marshall Clow0b0bbd22013-05-09 21:14:23510template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:10511 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23512 mismatch(InputIterator1 first1, InputIterator1 last1,
513 InputIterator2 first2, InputIterator2 last2,
514 BinaryPredicate pred); // **C++14**
515
Howard Hinnant3e519522010-05-11 19:42:16516template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:10517 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16518 equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
519
Marshall Clow0b0bbd22013-05-09 21:14:23520template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:10521 constexpr bool // constexpr in C++20
Aditya Kumar331fb802016-08-25 11:52:38522 equal(InputIterator1 first1, InputIterator1 last1,
Marshall Clow0b0bbd22013-05-09 21:14:23523 InputIterator2 first2, InputIterator2 last2); // **C++14**
524
Howard Hinnant3e519522010-05-11 19:42:16525template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:10526 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16527 equal(InputIterator1 first1, InputIterator1 last1,
528 InputIterator2 first2, BinaryPredicate pred);
529
Marshall Clow0b0bbd22013-05-09 21:14:23530template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:10531 constexpr bool // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23532 equal(InputIterator1 first1, InputIterator1 last1,
533 InputIterator2 first2, InputIterator2 last2,
534 BinaryPredicate pred); // **C++14**
535
Howard Hinnant3e519522010-05-11 19:42:16536template<class ForwardIterator1, class ForwardIterator2>
Marshall Clow49c76432018-01-15 16:16:32537 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16538 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
539 ForwardIterator2 first2);
540
Marshall Clow0b0bbd22013-05-09 21:14:23541template<class ForwardIterator1, class ForwardIterator2>
Marshall Clow49c76432018-01-15 16:16:32542 constexpr bool // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23543 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
544 ForwardIterator2 first2, ForwardIterator2 last2); // **C++14**
545
Howard Hinnant3e519522010-05-11 19:42:16546template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow49c76432018-01-15 16:16:32547 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16548 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
549 ForwardIterator2 first2, BinaryPredicate pred);
550
Marshall Clow0b0bbd22013-05-09 21:14:23551template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow49c76432018-01-15 16:16:32552 constexpr bool // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23553 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
554 ForwardIterator2 first2, ForwardIterator2 last2,
555 BinaryPredicate pred); // **C++14**
556
Howard Hinnant3e519522010-05-11 19:42:16557template <class ForwardIterator1, class ForwardIterator2>
Marshall Clow12f0a772018-01-16 15:48:27558 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16559 search(ForwardIterator1 first1, ForwardIterator1 last1,
560 ForwardIterator2 first2, ForwardIterator2 last2);
561
562template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow12f0a772018-01-16 15:48:27563 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16564 search(ForwardIterator1 first1, ForwardIterator1 last1,
565 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
566
567template <class ForwardIterator, class Size, class T>
Marshall Clow12f0a772018-01-16 15:48:27568 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16569 search_n(ForwardIterator first, ForwardIterator last, Size count, const T& value);
570
571template <class ForwardIterator, class Size, class T, class BinaryPredicate>
Marshall Clow12f0a772018-01-16 15:48:27572 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16573 search_n(ForwardIterator first, ForwardIterator last,
574 Size count, const T& value, BinaryPredicate pred);
575
576template <class InputIterator, class OutputIterator>
Louis Dionne13c90a52019-11-06 12:02:41577 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16578 copy(InputIterator first, InputIterator last, OutputIterator result);
579
580template<class InputIterator, class OutputIterator, class Predicate>
Louis Dionne13c90a52019-11-06 12:02:41581 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16582 copy_if(InputIterator first, InputIterator last,
583 OutputIterator result, Predicate pred);
584
585template<class InputIterator, class Size, class OutputIterator>
Louis Dionne13c90a52019-11-06 12:02:41586 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16587 copy_n(InputIterator first, Size n, OutputIterator result);
588
589template <class BidirectionalIterator1, class BidirectionalIterator2>
Louis Dionne13c90a52019-11-06 12:02:41590 constexpr BidirectionalIterator2 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16591 copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last,
592 BidirectionalIterator2 result);
593
594template <class ForwardIterator1, class ForwardIterator2>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18595 constexpr ForwardIterator2 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16596 swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2);
597
Nikolas Klauser9d905312022-02-10 12:33:03598template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2>
599 requires indirectly_swappable<I1, I2>
600 constexpr ranges::swap_ranges_result<I1, I2>
601 ranges::swap_ranges(I1 first1, S1 last1, I2 first2, S2 last2);
602
603template<input_range R1, input_range R2>
604 requires indirectly_swappable<iterator_t<R1>, iterator_t<R2>>
605 constexpr ranges::swap_ranges_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>>
606 ranges::swap_ranges(R1&& r1, R2&& r2);
607
Howard Hinnant3e519522010-05-11 19:42:16608template <class ForwardIterator1, class ForwardIterator2>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18609 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16610 iter_swap(ForwardIterator1 a, ForwardIterator2 b);
611
612template <class InputIterator, class OutputIterator, class UnaryOperation>
Marshall Clow99894b62018-01-19 17:45:39613 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16614 transform(InputIterator first, InputIterator last, OutputIterator result, UnaryOperation op);
615
616template <class InputIterator1, class InputIterator2, class OutputIterator, class BinaryOperation>
Marshall Clow99894b62018-01-19 17:45:39617 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16618 transform(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2,
619 OutputIterator result, BinaryOperation binary_op);
620
621template <class ForwardIterator, class T>
Marshall Clow12c74232018-01-19 18:07:29622 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16623 replace(ForwardIterator first, ForwardIterator last, const T& old_value, const T& new_value);
624
625template <class ForwardIterator, class Predicate, class T>
Marshall Clow12c74232018-01-19 18:07:29626 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16627 replace_if(ForwardIterator first, ForwardIterator last, Predicate pred, const T& new_value);
628
629template <class InputIterator, class OutputIterator, class T>
Marshall Clow12c74232018-01-19 18:07:29630 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16631 replace_copy(InputIterator first, InputIterator last, OutputIterator result,
632 const T& old_value, const T& new_value);
633
634template <class InputIterator, class OutputIterator, class Predicate, class T>
Marshall Clow12c74232018-01-19 18:07:29635 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16636 replace_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred, const T& new_value);
637
638template <class ForwardIterator, class T>
Marshall Clow4bfb9312018-01-20 20:14:32639 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16640 fill(ForwardIterator first, ForwardIterator last, const T& value);
641
642template <class OutputIterator, class Size, class T>
Marshall Clow4bfb9312018-01-20 20:14:32643 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16644 fill_n(OutputIterator first, Size n, const T& value);
645
646template <class ForwardIterator, class Generator>
Marshall Clow4bfb9312018-01-20 20:14:32647 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16648 generate(ForwardIterator first, ForwardIterator last, Generator gen);
649
650template <class OutputIterator, class Size, class Generator>
Marshall Clow4bfb9312018-01-20 20:14:32651 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16652 generate_n(OutputIterator first, Size n, Generator gen);
653
654template <class ForwardIterator, class T>
Marshall Clowe8ea8292018-01-22 21:43:04655 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16656 remove(ForwardIterator first, ForwardIterator last, const T& value);
657
658template <class ForwardIterator, class Predicate>
Marshall Clowe8ea8292018-01-22 21:43:04659 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16660 remove_if(ForwardIterator first, ForwardIterator last, Predicate pred);
661
662template <class InputIterator, class OutputIterator, class T>
Marshall Clowe8ea8292018-01-22 21:43:04663 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16664 remove_copy(InputIterator first, InputIterator last, OutputIterator result, const T& value);
665
666template <class InputIterator, class OutputIterator, class Predicate>
Marshall Clowe8ea8292018-01-22 21:43:04667 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16668 remove_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred);
669
670template <class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18671 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16672 unique(ForwardIterator first, ForwardIterator last);
673
674template <class ForwardIterator, class BinaryPredicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18675 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16676 unique(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
677
678template <class InputIterator, class OutputIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18679 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16680 unique_copy(InputIterator first, InputIterator last, OutputIterator result);
681
682template <class InputIterator, class OutputIterator, class BinaryPredicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18683 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16684 unique_copy(InputIterator first, InputIterator last, OutputIterator result, BinaryPredicate pred);
685
686template <class BidirectionalIterator>
Arthur O'Dwyerf851db32020-12-17 05:01:08687 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16688 reverse(BidirectionalIterator first, BidirectionalIterator last);
689
690template <class BidirectionalIterator, class OutputIterator>
Marshall Clowe8ea8292018-01-22 21:43:04691 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16692 reverse_copy(BidirectionalIterator first, BidirectionalIterator last, OutputIterator result);
693
694template <class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18695 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16696 rotate(ForwardIterator first, ForwardIterator middle, ForwardIterator last);
697
698template <class ForwardIterator, class OutputIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18699 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16700 rotate_copy(ForwardIterator first, ForwardIterator middle, ForwardIterator last, OutputIterator result);
701
702template <class RandomAccessIterator>
703 void
Marshall Clow0f37a412017-03-23 13:43:37704 random_shuffle(RandomAccessIterator first, RandomAccessIterator last); // deprecated in C++14, removed in C++17
Howard Hinnant3e519522010-05-11 19:42:16705
706template <class RandomAccessIterator, class RandomNumberGenerator>
707 void
Marshall Clow06965c12014-03-03 06:14:19708 random_shuffle(RandomAccessIterator first, RandomAccessIterator last,
Marshall Clow0f37a412017-03-23 13:43:37709 RandomNumberGenerator& rand); // deprecated in C++14, removed in C++17
Howard Hinnant3e519522010-05-11 19:42:16710
Eric Fiseliere7154702016-08-28 22:14:37711template<class PopulationIterator, class SampleIterator,
712 class Distance, class UniformRandomBitGenerator>
713 SampleIterator sample(PopulationIterator first, PopulationIterator last,
714 SampleIterator out, Distance n,
715 UniformRandomBitGenerator&& g); // C++17
716
Howard Hinnantf9d540b2010-05-26 17:49:34717template<class RandomAccessIterator, class UniformRandomNumberGenerator>
718 void shuffle(RandomAccessIterator first, RandomAccessIterator last,
Howard Hinnantfb340102010-11-18 01:47:02719 UniformRandomNumberGenerator&& g);
Howard Hinnantf9d540b2010-05-26 17:49:34720
Arthur O'Dwyer3fbd3ea2020-12-26 06:39:03721template<class ForwardIterator>
722 constexpr ForwardIterator
723 shift_left(ForwardIterator first, ForwardIterator last,
724 typename iterator_traits<ForwardIterator>::difference_type n); // C++20
725
726template<class ForwardIterator>
727 constexpr ForwardIterator
728 shift_right(ForwardIterator first, ForwardIterator last,
729 typename iterator_traits<ForwardIterator>::difference_type n); // C++20
730
Howard Hinnant3e519522010-05-11 19:42:16731template <class InputIterator, class Predicate>
Marshall Clow49c76432018-01-15 16:16:32732 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16733 is_partitioned(InputIterator first, InputIterator last, Predicate pred);
734
735template <class ForwardIterator, class Predicate>
Arthur O'Dwyerf851db32020-12-17 05:01:08736 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16737 partition(ForwardIterator first, ForwardIterator last, Predicate pred);
738
739template <class InputIterator, class OutputIterator1,
740 class OutputIterator2, class Predicate>
Marshall Clow1b9a4ff2018-01-22 20:44:33741 constexpr pair<OutputIterator1, OutputIterator2> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16742 partition_copy(InputIterator first, InputIterator last,
743 OutputIterator1 out_true, OutputIterator2 out_false,
744 Predicate pred);
745
746template <class ForwardIterator, class Predicate>
747 ForwardIterator
748 stable_partition(ForwardIterator first, ForwardIterator last, Predicate pred);
749
750template<class ForwardIterator, class Predicate>
Marshall Clowd57c03d2018-01-16 02:34:41751 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16752 partition_point(ForwardIterator first, ForwardIterator last, Predicate pred);
753
754template <class ForwardIterator>
Marshall Clow49c76432018-01-15 16:16:32755 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16756 is_sorted(ForwardIterator first, ForwardIterator last);
757
758template <class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18759 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16760 is_sorted(ForwardIterator first, ForwardIterator last, Compare comp);
761
762template<class ForwardIterator>
Marshall Clow056f15e2018-01-15 19:40:34763 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16764 is_sorted_until(ForwardIterator first, ForwardIterator last);
765
766template <class ForwardIterator, class Compare>
Marshall Clow056f15e2018-01-15 19:40:34767 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16768 is_sorted_until(ForwardIterator first, ForwardIterator last, Compare comp);
769
770template <class RandomAccessIterator>
Arthur O'Dwyer493f1402020-12-20 20:21:42771 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16772 sort(RandomAccessIterator first, RandomAccessIterator last);
773
774template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer493f1402020-12-20 20:21:42775 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16776 sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
777
778template <class RandomAccessIterator>
779 void
780 stable_sort(RandomAccessIterator first, RandomAccessIterator last);
781
782template <class RandomAccessIterator, class Compare>
783 void
784 stable_sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
785
786template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18787 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16788 partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last);
789
790template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18791 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16792 partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last, Compare comp);
793
794template <class InputIterator, class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18795 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16796 partial_sort_copy(InputIterator first, InputIterator last,
797 RandomAccessIterator result_first, RandomAccessIterator result_last);
798
799template <class InputIterator, class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18800 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16801 partial_sort_copy(InputIterator first, InputIterator last,
802 RandomAccessIterator result_first, RandomAccessIterator result_last, Compare comp);
803
804template <class RandomAccessIterator>
Arthur O'Dwyer5d956562021-02-04 23:12:52805 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16806 nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last);
807
808template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5d956562021-02-04 23:12:52809 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16810 nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last, Compare comp);
811
812template <class ForwardIterator, class T>
Marshall Clowd57c03d2018-01-16 02:34:41813 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16814 lower_bound(ForwardIterator first, ForwardIterator last, const T& value);
815
816template <class ForwardIterator, class T, class Compare>
Marshall Clowd57c03d2018-01-16 02:34:41817 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16818 lower_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
819
820template <class ForwardIterator, class T>
Marshall Clowd57c03d2018-01-16 02:34:41821 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16822 upper_bound(ForwardIterator first, ForwardIterator last, const T& value);
823
824template <class ForwardIterator, class T, class Compare>
Marshall Clowd57c03d2018-01-16 02:34:41825 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16826 upper_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
827
828template <class ForwardIterator, class T>
Marshall Clowd57c03d2018-01-16 02:34:41829 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16830 equal_range(ForwardIterator first, ForwardIterator last, const T& value);
831
832template <class ForwardIterator, class T, class Compare>
Marshall Clowd57c03d2018-01-16 02:34:41833 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16834 equal_range(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
835
836template <class ForwardIterator, class T>
Marshall Clowd57c03d2018-01-16 02:34:41837 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16838 binary_search(ForwardIterator first, ForwardIterator last, const T& value);
839
840template <class ForwardIterator, class T, class Compare>
Marshall Clow8da1a482018-01-22 23:10:40841 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16842 binary_search(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
843
844template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer14098cf2020-12-04 18:47:12845 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16846 merge(InputIterator1 first1, InputIterator1 last1,
847 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
848
849template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer14098cf2020-12-04 18:47:12850 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16851 merge(InputIterator1 first1, InputIterator1 last1,
852 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
853
854template <class BidirectionalIterator>
855 void
856 inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last);
857
858template <class BidirectionalIterator, class Compare>
859 void
860 inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last, Compare comp);
861
862template <class InputIterator1, class InputIterator2>
Marshall Clow8da1a482018-01-22 23:10:40863 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16864 includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
865
866template <class InputIterator1, class InputIterator2, class Compare>
Marshall Clow8da1a482018-01-22 23:10:40867 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16868 includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, Compare comp);
869
870template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer14098cf2020-12-04 18:47:12871 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16872 set_union(InputIterator1 first1, InputIterator1 last1,
873 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
874
875template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer14098cf2020-12-04 18:47:12876 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16877 set_union(InputIterator1 first1, InputIterator1 last1,
878 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
879
880template <class InputIterator1, class InputIterator2, class OutputIterator>
Marshall Clow8da1a482018-01-22 23:10:40881 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16882 set_intersection(InputIterator1 first1, InputIterator1 last1,
883 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
884
885template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Marshall Clow8da1a482018-01-22 23:10:40886 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16887 set_intersection(InputIterator1 first1, InputIterator1 last1,
888 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
889
890template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer14098cf2020-12-04 18:47:12891 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16892 set_difference(InputIterator1 first1, InputIterator1 last1,
893 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
894
895template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer14098cf2020-12-04 18:47:12896 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16897 set_difference(InputIterator1 first1, InputIterator1 last1,
898 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
899
900template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer14098cf2020-12-04 18:47:12901 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16902 set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
903 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
904
905template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer14098cf2020-12-04 18:47:12906 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16907 set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
908 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
909
910template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18911 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16912 push_heap(RandomAccessIterator first, RandomAccessIterator last);
913
914template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18915 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16916 push_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
917
918template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18919 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16920 pop_heap(RandomAccessIterator first, RandomAccessIterator last);
921
922template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18923 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16924 pop_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
925
926template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18927 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16928 make_heap(RandomAccessIterator first, RandomAccessIterator last);
929
930template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18931 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16932 make_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
933
934template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18935 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16936 sort_heap(RandomAccessIterator first, RandomAccessIterator last);
937
938template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18939 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16940 sort_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
941
Howard Hinnantb3371f62010-08-22 00:02:43942template <class RandomAccessIterator>
Marshall Clow49c76432018-01-15 16:16:32943 constexpr bool // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43944 is_heap(RandomAccessIterator first, RandomAccessiterator last);
Howard Hinnant3e519522010-05-11 19:42:16945
Howard Hinnantb3371f62010-08-22 00:02:43946template <class RandomAccessIterator, class Compare>
Marshall Clow49c76432018-01-15 16:16:32947 constexpr bool // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43948 is_heap(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16949
Howard Hinnantb3371f62010-08-22 00:02:43950template <class RandomAccessIterator>
Marshall Clow49c76432018-01-15 16:16:32951 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43952 is_heap_until(RandomAccessIterator first, RandomAccessiterator last);
Howard Hinnant3e519522010-05-11 19:42:16953
Howard Hinnantb3371f62010-08-22 00:02:43954template <class RandomAccessIterator, class Compare>
Marshall Clow49c76432018-01-15 16:16:32955 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43956 is_heap_until(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16957
Howard Hinnant4eb27b72010-08-21 20:10:01958template <class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18959 constexpr ForwardIterator // constexpr in C++14
960 min_element(ForwardIterator first, ForwardIterator last);
Howard Hinnant4eb27b72010-08-21 20:10:01961
962template <class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18963 constexpr ForwardIterator // constexpr in C++14
964 min_element(ForwardIterator first, ForwardIterator last, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01965
Howard Hinnant3e519522010-05-11 19:42:16966template <class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18967 constexpr const T& // constexpr in C++14
968 min(const T& a, const T& b);
Howard Hinnant3e519522010-05-11 19:42:16969
970template <class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18971 constexpr const T& // constexpr in C++14
972 min(const T& a, const T& b, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16973
Howard Hinnant4eb27b72010-08-21 20:10:01974template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18975 constexpr T // constexpr in C++14
976 min(initializer_list<T> t);
Howard Hinnant4eb27b72010-08-21 20:10:01977
978template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18979 constexpr T // constexpr in C++14
980 min(initializer_list<T> t, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01981
Marshall Clow146c14a2016-03-07 22:43:49982template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18983 constexpr const T& clamp(const T& v, const T& lo, const T& hi); // C++17
Marshall Clow146c14a2016-03-07 22:43:49984
985template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18986 constexpr const T& clamp(const T& v, const T& lo, const T& hi, Compare comp); // C++17
Marshall Clow146c14a2016-03-07 22:43:49987
Howard Hinnant4eb27b72010-08-21 20:10:01988template <class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18989 constexpr ForwardIterator // constexpr in C++14
990 max_element(ForwardIterator first, ForwardIterator last);
Howard Hinnant4eb27b72010-08-21 20:10:01991
992template <class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18993 constexpr ForwardIterator // constexpr in C++14
994 max_element(ForwardIterator first, ForwardIterator last, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01995
Howard Hinnant3e519522010-05-11 19:42:16996template <class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18997 constexpr const T& // constexpr in C++14
998 max(const T& a, const T& b);
Howard Hinnant3e519522010-05-11 19:42:16999
1000template <class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:181001 constexpr const T& // constexpr in C++14
1002 max(const T& a, const T& b, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:161003
Howard Hinnant4eb27b72010-08-21 20:10:011004template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:181005 constexpr T // constexpr in C++14
1006 max(initializer_list<T> t);
Howard Hinnant3e519522010-05-11 19:42:161007
Howard Hinnant4eb27b72010-08-21 20:10:011008template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:181009 constexpr T // constexpr in C++14
1010 max(initializer_list<T> t, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:161011
Howard Hinnant4eb27b72010-08-21 20:10:011012template<class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:181013 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++14
1014 minmax_element(ForwardIterator first, ForwardIterator last);
Howard Hinnant3e519522010-05-11 19:42:161015
Howard Hinnant4eb27b72010-08-21 20:10:011016template<class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:181017 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++14
1018 minmax_element(ForwardIterator first, ForwardIterator last, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:011019
1020template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:181021 constexpr pair<const T&, const T&> // constexpr in C++14
1022 minmax(const T& a, const T& b);
Howard Hinnant4eb27b72010-08-21 20:10:011023
1024template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:181025 constexpr pair<const T&, const T&> // constexpr in C++14
1026 minmax(const T& a, const T& b, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:011027
1028template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:181029 constexpr pair<T, T> // constexpr in C++14
1030 minmax(initializer_list<T> t);
Howard Hinnant4eb27b72010-08-21 20:10:011031
1032template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:181033 constexpr pair<T, T> // constexpr in C++14
1034 minmax(initializer_list<T> t, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:161035
1036template <class InputIterator1, class InputIterator2>
Marshall Clow1b9a4ff2018-01-22 20:44:331037 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:161038 lexicographical_compare(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
1039
1040template <class InputIterator1, class InputIterator2, class Compare>
Marshall Clow1b9a4ff2018-01-22 20:44:331041 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:161042 lexicographical_compare(InputIterator1 first1, InputIterator1 last1,
1043 InputIterator2 first2, InputIterator2 last2, Compare comp);
1044
1045template <class BidirectionalIterator>
Arthur O'Dwyerf851db32020-12-17 05:01:081046 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:161047 next_permutation(BidirectionalIterator first, BidirectionalIterator last);
1048
1049template <class BidirectionalIterator, class Compare>
Arthur O'Dwyerf851db32020-12-17 05:01:081050 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:161051 next_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
1052
1053template <class BidirectionalIterator>
Arthur O'Dwyerf851db32020-12-17 05:01:081054 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:161055 prev_permutation(BidirectionalIterator first, BidirectionalIterator last);
1056
1057template <class BidirectionalIterator, class Compare>
Arthur O'Dwyerf851db32020-12-17 05:01:081058 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:161059 prev_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:161060} // std
1061
1062*/
1063
Louis Dionne385cc252022-03-25 16:55:361064#include <__assert> // all public C++ headers provide the assertion handler
Arthur O'Dwyerea2206d2022-02-04 18:09:301065#include <__bits>
Howard Hinnant3e519522010-05-11 19:42:161066#include <__config>
Louis Dionne134723e2021-06-17 15:30:111067#include <__debug>
Howard Hinnanta1d07d52012-07-26 17:09:091068#include <cstddef>
Arthur O'Dwyerbfbd73f2021-05-19 15:57:041069#include <cstring>
Arthur O'Dwyerbfbd73f2021-05-19 15:57:041070#include <initializer_list>
Arthur O'Dwyerbfbd73f2021-05-19 15:57:041071#include <memory>
1072#include <type_traits>
Marshall Clowf56972e2018-09-12 19:41:401073#include <version>
Howard Hinnant5d1a7012013-08-14 18:00:201074
Louis Dionne134723e2021-06-17 15:30:111075#include <__algorithm/adjacent_find.h>
1076#include <__algorithm/all_of.h>
1077#include <__algorithm/any_of.h>
1078#include <__algorithm/binary_search.h>
1079#include <__algorithm/clamp.h>
1080#include <__algorithm/comp.h>
1081#include <__algorithm/comp_ref_type.h>
1082#include <__algorithm/copy.h>
1083#include <__algorithm/copy_backward.h>
1084#include <__algorithm/copy_if.h>
1085#include <__algorithm/copy_n.h>
1086#include <__algorithm/count.h>
1087#include <__algorithm/count_if.h>
1088#include <__algorithm/equal.h>
1089#include <__algorithm/equal_range.h>
Louis Dionne134723e2021-06-17 15:30:111090#include <__algorithm/fill.h>
Arthur O'Dwyer4d81a462022-01-07 14:45:051091#include <__algorithm/fill_n.h>
Louis Dionne134723e2021-06-17 15:30:111092#include <__algorithm/find.h>
1093#include <__algorithm/find_end.h>
1094#include <__algorithm/find_first_of.h>
1095#include <__algorithm/find_if.h>
1096#include <__algorithm/find_if_not.h>
1097#include <__algorithm/for_each.h>
1098#include <__algorithm/for_each_n.h>
Louis Dionne134723e2021-06-17 15:30:111099#include <__algorithm/generate.h>
Arthur O'Dwyer4d81a462022-01-07 14:45:051100#include <__algorithm/generate_n.h>
Louis Dionne134723e2021-06-17 15:30:111101#include <__algorithm/half_positive.h>
Nikolas Klauser68f41312022-02-21 22:07:021102#include <__algorithm/in_found_result.h>
Nikolas Klauser1e77b392022-02-11 16:01:581103#include <__algorithm/in_fun_result.h>
Nikolas Klauserf3514af2022-01-25 10:21:471104#include <__algorithm/in_in_out_result.h>
Nikolas Klauserd3729bb2022-01-14 01:55:511105#include <__algorithm/in_in_result.h>
Nikolas Klauser610979b2022-02-03 01:17:031106#include <__algorithm/in_out_out_result.h>
Konstantin Varlamov8d23b742022-01-11 06:49:371107#include <__algorithm/in_out_result.h>
Louis Dionne134723e2021-06-17 15:30:111108#include <__algorithm/includes.h>
1109#include <__algorithm/inplace_merge.h>
1110#include <__algorithm/is_heap.h>
1111#include <__algorithm/is_heap_until.h>
1112#include <__algorithm/is_partitioned.h>
1113#include <__algorithm/is_permutation.h>
1114#include <__algorithm/is_sorted.h>
1115#include <__algorithm/is_sorted_until.h>
Christopher Di Bella6adbc832021-06-05 02:47:471116#include <__algorithm/iter_swap.h>
Louis Dionne134723e2021-06-17 15:30:111117#include <__algorithm/lexicographical_compare.h>
1118#include <__algorithm/lower_bound.h>
1119#include <__algorithm/make_heap.h>
1120#include <__algorithm/max.h>
1121#include <__algorithm/max_element.h>
1122#include <__algorithm/merge.h>
1123#include <__algorithm/min.h>
1124#include <__algorithm/min_element.h>
Nikolas Klauser807766b2022-02-21 21:48:361125#include <__algorithm/min_max_result.h>
Louis Dionne134723e2021-06-17 15:30:111126#include <__algorithm/minmax.h>
1127#include <__algorithm/minmax_element.h>
1128#include <__algorithm/mismatch.h>
1129#include <__algorithm/move.h>
1130#include <__algorithm/move_backward.h>
1131#include <__algorithm/next_permutation.h>
1132#include <__algorithm/none_of.h>
1133#include <__algorithm/nth_element.h>
1134#include <__algorithm/partial_sort.h>
1135#include <__algorithm/partial_sort_copy.h>
1136#include <__algorithm/partition.h>
1137#include <__algorithm/partition_copy.h>
1138#include <__algorithm/partition_point.h>
1139#include <__algorithm/pop_heap.h>
1140#include <__algorithm/prev_permutation.h>
1141#include <__algorithm/push_heap.h>
Nikolas Klauser916e9052022-06-08 10:14:121142#include <__algorithm/ranges_adjacent_find.h>
Nikolas Klauser0e3dc1a2022-05-26 14:42:461143#include <__algorithm/ranges_all_of.h>
1144#include <__algorithm/ranges_any_of.h>
Nikolas Klauser81715862022-06-05 19:15:161145#include <__algorithm/ranges_binary_search.h>
Nikolas Klauser1d837502022-04-15 11:43:401146#include <__algorithm/ranges_copy.h>
1147#include <__algorithm/ranges_copy_backward.h>
1148#include <__algorithm/ranges_copy_if.h>
1149#include <__algorithm/ranges_copy_n.h>
Nikolas Klauser1306b102022-04-07 11:02:021150#include <__algorithm/ranges_count.h>
1151#include <__algorithm/ranges_count_if.h>
Nikolas Klauser569d6632022-05-25 09:09:431152#include <__algorithm/ranges_equal.h>
Nikolas Klauser7af89a32022-05-21 16:26:291153#include <__algorithm/ranges_fill.h>
1154#include <__algorithm/ranges_fill_n.h>
Nikolas Klauseree0f8c42022-03-12 00:45:351155#include <__algorithm/ranges_find.h>
Nikolas Klauserb79b2b62022-06-06 11:57:341156#include <__algorithm/ranges_find_first_of.h>
Nikolas Klauseree0f8c42022-03-12 00:45:351157#include <__algorithm/ranges_find_if.h>
1158#include <__algorithm/ranges_find_if_not.h>
Nikolas Klauser80045e92022-05-04 18:27:071159#include <__algorithm/ranges_for_each.h>
1160#include <__algorithm/ranges_for_each_n.h>
Nikolas Klauser37ba1b92022-05-04 12:19:091161#include <__algorithm/ranges_is_partitioned.h>
Nikolas Klauser11e3ad22022-05-26 14:08:551162#include <__algorithm/ranges_is_sorted.h>
1163#include <__algorithm/ranges_is_sorted_until.h>
Nikolas Klauser81715862022-06-05 19:15:161164#include <__algorithm/ranges_lower_bound.h>
Nikolas Klausere476df52022-04-03 07:17:011165#include <__algorithm/ranges_max.h>
Nikolas Klauser205557c2022-03-07 16:01:521166#include <__algorithm/ranges_max_element.h>
Nikolas Klauserf83d8332022-03-18 01:57:081167#include <__algorithm/ranges_min.h>
Nikolas Klauser3b470d12022-02-11 12:11:571168#include <__algorithm/ranges_min_element.h>
Nikolas Klauser58d9ab72022-04-13 20:59:091169#include <__algorithm/ranges_minmax.h>
1170#include <__algorithm/ranges_minmax_element.h>
Nikolas Klauserc2cd15a2022-03-08 22:12:351171#include <__algorithm/ranges_mismatch.h>
Nikolas Klauser0e3dc1a2022-05-26 14:42:461172#include <__algorithm/ranges_none_of.h>
Nikolas Klauserff6d5de2022-06-07 07:42:101173#include <__algorithm/ranges_replace.h>
1174#include <__algorithm/ranges_replace_if.h>
Nikolas Klauser1d1a1912022-05-24 08:32:501175#include <__algorithm/ranges_reverse.h>
Nikolas Klauser9d905312022-02-10 12:33:031176#include <__algorithm/ranges_swap_ranges.h>
Nikolas Klauser3ba85482022-04-05 09:05:361177#include <__algorithm/ranges_transform.h>
Nikolas Klauser81715862022-06-05 19:15:161178#include <__algorithm/ranges_upper_bound.h>
Louis Dionne134723e2021-06-17 15:30:111179#include <__algorithm/remove.h>
1180#include <__algorithm/remove_copy.h>
1181#include <__algorithm/remove_copy_if.h>
1182#include <__algorithm/remove_if.h>
1183#include <__algorithm/replace.h>
1184#include <__algorithm/replace_copy.h>
1185#include <__algorithm/replace_copy_if.h>
1186#include <__algorithm/replace_if.h>
1187#include <__algorithm/reverse.h>
1188#include <__algorithm/reverse_copy.h>
1189#include <__algorithm/rotate.h>
1190#include <__algorithm/rotate_copy.h>
1191#include <__algorithm/sample.h>
1192#include <__algorithm/search.h>
1193#include <__algorithm/search_n.h>
1194#include <__algorithm/set_difference.h>
1195#include <__algorithm/set_intersection.h>
1196#include <__algorithm/set_symmetric_difference.h>
1197#include <__algorithm/set_union.h>
1198#include <__algorithm/shift_left.h>
1199#include <__algorithm/shift_right.h>
1200#include <__algorithm/shuffle.h>
1201#include <__algorithm/sift_down.h>
1202#include <__algorithm/sort.h>
1203#include <__algorithm/sort_heap.h>
1204#include <__algorithm/stable_partition.h>
1205#include <__algorithm/stable_sort.h>
Christopher Di Bella6adbc832021-06-05 02:47:471206#include <__algorithm/swap_ranges.h>
Louis Dionne134723e2021-06-17 15:30:111207#include <__algorithm/transform.h>
Louis Dionne134723e2021-06-17 15:30:111208#include <__algorithm/unique.h>
Arthur O'Dwyer4d81a462022-01-07 14:45:051209#include <__algorithm/unique_copy.h>
Louis Dionne134723e2021-06-17 15:30:111210#include <__algorithm/unwrap_iter.h>
1211#include <__algorithm/upper_bound.h>
Eric Fiselierc1bd9192014-08-10 23:53:081212
Howard Hinnant073458b2011-10-17 20:05:101213#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Arthur O'Dwyerfa6b9e42022-02-02 01:16:401214# pragma GCC system_header
Howard Hinnant073458b2011-10-17 20:05:101215#endif
Howard Hinnant3e519522010-05-11 19:42:161216
Louis Dionne0a06eb92019-08-05 18:29:141217#if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17
Louis Dionne95689242019-08-06 21:11:241218# include <__pstl_algorithm>
Louis Dionne0a06eb92019-08-05 18:29:141219#endif
1220
Louis Dionne4cd6ca12021-04-20 16:03:321221#endif // _LIBCPP_ALGORITHM