1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// 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
7//
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
21namespace ranges {
22
23 // [algorithms.results], algorithm result types
24 template <class I, class F>
25 struct in_fun_result; // since C++20
26
27 template <class I1, class I2>
28 struct in_in_result; // since C++20
29
30 template <class I, class O>
31 struct in_out_result; // since C++20
32
33 template <class I1, class I2, class O>
34 struct in_in_out_result; // since C++20
35
36 template <class I, class O1, class O2>
37 struct in_out_out_result; // since C++20
38
39 template <class I1, class I2>
40 struct min_max_result; // since C++20
41
42 template <class I>
43 struct in_found_result; // since C++20
44
45 template <class I, class T>
46 struct in_value_result; // since C++23
47
48 template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
49 indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less> // since C++20
50 constexpr I min_element(I first, S last, Comp comp = {}, Proj proj = {});
51
52 template<forward_range R, class Proj = identity,
53 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less> // since C++20
54 constexpr borrowed_iterator_t<R> min_element(R&& r, Comp comp = {}, Proj proj = {});
55
56 template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
57 indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
58 constexpr I ranges::max_element(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
59
60 template<forward_range R, class Proj = identity,
61 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
62 constexpr borrowed_iterator_t<R> ranges::max_element(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
63
64 template<class I1, class I2>
65 using mismatch_result = in_in_result<I1, I2>;
66
67 template <input_iterator I1, sentinel_for<_I1> S1, input_iterator I2, sentinel_for<_I2> S2,
68 class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
69 requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
70 constexpr mismatch_result<_I1, _I2> // since C++20
71 mismatch()(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {})
72
73 template <input_range R1, input_range R2,
74 class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
75 requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
76 constexpr mismatch_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>>
77 mismatch(R1&& r1, R2&& r2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}) // since C++20
78
79 requires indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
80 constexpr I find(I first, S last, const T& value, Proj proj = {}); // since C++20
81
82 template<input_range R, class T, class Proj = identity>
83 requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*>
84 constexpr borrowed_iterator_t<R>
85 find(R&& r, const T& value, Proj proj = {}); // since C++20
86
87 template<input_iterator I, sentinel_for<I> S, class Proj = identity,
88 indirect_unary_predicate<projected<I, Proj>> Pred>
89 constexpr I find_if(I first, S last, Pred pred, Proj proj = {}); // since C++20
90
91 template<input_range R, class Proj = identity,
92 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
93 constexpr borrowed_iterator_t<R>
94 find_if(R&& r, Pred pred, Proj proj = {}); // since C++20
95
96 template<input_iterator I, sentinel_for<I> S, class Proj = identity,
97 indirect_unary_predicate<projected<I, Proj>> Pred>
98 constexpr I find_if_not(I first, S last, Pred pred, Proj proj = {}); // since C++20
99
100 template<input_range R, class Proj = identity,
101 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
102 constexpr borrowed_iterator_t<R>
103 find_if_not(R&& r, Pred pred, Proj proj = {}); // since C++20
104
105 template<forward_iterator I, sentinel_for<I> S, class T, class Proj = identity>
106 requires indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
107 constexpr subrange<I> find_last(I first, S last, const T& value, Proj proj = {}); // since C++23
108
109 template<forward_range R, class T, class Proj = identity>
110 requires
111 indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*>
112 constexpr borrowed_subrange_t<R> find_last(R&& r, const T& value, Proj proj = {}); // since C++23
113
114 template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
115 indirect_unary_predicate<projected<I, Proj>> Pred>
116 constexpr subrange<I> find_last_if(I first, S last, Pred pred, Proj proj = {}); // since C++23
117
118 template<forward_range R, class Proj = identity,
119 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
120 constexpr borrowed_subrange_t<R> find_last_if(R&& r, Pred pred, Proj proj = {}); // since C++23
121
122 template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
123 indirect_unary_predicate<projected<I, Proj>> Pred>
124 constexpr subrange<I> find_last_if_not(I first, S last, Pred pred, Proj proj = {}); // since C++23
125
126 template<forward_range R, class Proj = identity,
127 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
128 constexpr borrowed_subrange_t<R> find_last_if_not(R&& r, Pred pred, Proj proj = {}); // since C++23
129
130 template<class T, class Proj = identity,
131 indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
132 constexpr const T& min(const T& a, const T& b, Comp comp = {}, Proj proj = {}); // since C++20
133
134 template<copyable T, class Proj = identity,
135 indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
136 constexpr T min(initializer_list<T> r, Comp comp = {}, Proj proj = {}); // since C++20
137
138 template<input_range R, class Proj = identity,
139 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
140 requires indirectly_copyable_storable<iterator_t<R>, range_value_t<R>*>
141 constexpr range_value_t<R>
142 min(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
143
144 template<class T, class Proj = identity,
145 indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
146 constexpr const T& max(const T& a, const T& b, Comp comp = {}, Proj proj = {}); // since C++20
147
148 template<copyable T, class Proj = identity,
149 indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
150 constexpr T max(initializer_list<T> r, Comp comp = {}, Proj proj = {}); // since C++20
151
152 template<input_range R, class Proj = identity,
153 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
154 requires indirectly_copyable_storable<iterator_t<R>, range_value_t<R>*>
155 constexpr range_value_t<R>
156 max(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
157
158 template<class I, class O>
159 using unary_transform_result = in_out_result<I, O>; // since C++20
160
161 template<class I1, class I2, class O>
162 using binary_transform_result = in_in_out_result<I1, I2, O>; // since C++20
163
164 template<input_iterator I, sentinel_for<I> S, weakly_incrementable O,
165 copy_constructible F, class Proj = identity>
166 requires indirectly_writable<O, indirect_result_t<F&, projected<I, Proj>>>
167 constexpr ranges::unary_transform_result<I, O>
168 transform(I first1, S last1, O result, F op, Proj proj = {}); // since C++20
169
170 template<input_range R, weakly_incrementable O, copy_constructible F,
171 class Proj = identity>
172 requires indirectly_writable<O, indirect_result_t<F&, projected<iterator_t<R>, Proj>>>
173 constexpr ranges::unary_transform_result<borrowed_iterator_t<R>, O>
174 transform(R&& r, O result, F op, Proj proj = {}); // since C++20
175
176 template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
177 weakly_incrementable O, copy_constructible F, class Proj1 = identity,
178 class Proj2 = identity>
179 requires indirectly_writable<O, indirect_result_t<F&, projected<I1, Proj1>,
180 projected<I2, Proj2>>>
181 constexpr ranges::binary_transform_result<I1, I2, O>
182 transform(I1 first1, S1 last1, I2 first2, S2 last2, O result,
183 F binary_op, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
184
185 template<input_range R1, input_range R2, weakly_incrementable O,
186 copy_constructible F, class Proj1 = identity, class Proj2 = identity>
187 requires indirectly_writable<O, indirect_result_t<F&, projected<iterator_t<R1>, Proj1>,
188 projected<iterator_t<R2>, Proj2>>>
189 constexpr ranges::binary_transform_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>, O>
190 transform(R1&& r1, R2&& r2, O result,
191 F binary_op, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
192
193 template<input_iterator I, sentinel_for<I> S, class T, class Proj = identity>
194 requires indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
195 constexpr iter_difference_t<I>
196 count(I first, S last, const T& value, Proj proj = {}); // since C++20
197
198 template<input_range R, class T, class Proj = identity>
199 requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*>
200 constexpr range_difference_t<R>
201 count(R&& r, const T& value, Proj proj = {}); // since C++20
202
203 template<input_iterator I, sentinel_for<I> S, class Proj = identity,
204 indirect_unary_predicate<projected<I, Proj>> Pred>
205 constexpr iter_difference_t<I>
206 count_if(I first, S last, Pred pred, Proj proj = {}); // since C++20
207
208 template<input_range R, class Proj = identity,
209 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
210 constexpr range_difference_t<R>
211 count_if(R&& r, Pred pred, Proj proj = {}); // since C++20
212
213 template<class T>
214 using minmax_result = min_max_result<T>;
215
216 template<class T, class Proj = identity,
217 indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
218 constexpr ranges::minmax_result<const T&>
219 minmax(const T& a, const T& b, Comp comp = {}, Proj proj = {}); // since C++20
220
221 template<copyable T, class Proj = identity,
222 indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
223 constexpr ranges::minmax_result<T>
224 minmax(initializer_list<T> r, Comp comp = {}, Proj proj = {}); // since C++20
225
226 template<input_range R, class Proj = identity,
227 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
228 requires indirectly_copyable_storable<iterator_t<R>, range_value_t<R>*>
229 constexpr ranges::minmax_result<range_value_t<R>>
230 minmax(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
231
232 template<class I>
233 using minmax_element_result = min_max_result<I>;
234
235 template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
236 indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
237 constexpr ranges::minmax_element_result<I>
238 minmax_element(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
239
240 template<forward_range R, class Proj = identity,
241 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
242 constexpr ranges::minmax_element_result<borrowed_iterator_t<R>>
243 minmax_element(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
244
245 template<forward_iterator I1, sentinel_for<I1> S1,
246 forward_iterator I2, sentinel_for<I2> S2,
247 class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
248 requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
249 constexpr bool contains_subrange(I1 first1, S1 last1, I2 first2, S2 last2,
250 Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++23
251
252 template<forward_range R1, forward_range R2,
253 class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
254 requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
255 constexpr bool contains_subrange(R1&& r1, R2&& r2, Pred pred = {},
256 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++23
257
258 template<class I, class O>
259 using copy_result = in_out_result<I, O>; // since C++20
260
261 template<class I, class O>
262 using copy_n_result = in_out_result<I, O>; // since C++20
263
264 template<class I, class O>
265 using copy_if_result = in_out_result<I, O>; // since C++20
266
267 template<class I1, class I2>
268 using copy_backward_result = in_out_result<I1, I2>; // since C++20
269
270 template<input_iterator I, sentinel_for<I> S, class T, class Proj = identity>
271 requires indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
272 constexpr bool ranges::contains(I first, S last, const T& value, Proj proj = {}); // since C++23
273
274 template<input_range R, class T, class Proj = identity>
275 requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*>
276 constexpr bool ranges::contains(R&& r, const T& value, Proj proj = {}); // since C++23
277
278 template<input_iterator I, sentinel_for<I> S, weakly_incrementable O>
279 requires indirectly_copyable<I, O>
280 constexpr ranges::copy_result<I, O> ranges::copy(I first, S last, O result); // since C++20
281
282 template<input_range R, weakly_incrementable O>
283 requires indirectly_copyable<iterator_t<R>, O>
284 constexpr ranges::copy_result<borrowed_iterator_t<R>, O> ranges::copy(R&& r, O result); // since C++20
285
286 template<input_iterator I, weakly_incrementable O>
287 requires indirectly_copyable<I, O>
288 constexpr ranges::copy_n_result<I, O>
289 ranges::copy_n(I first, iter_difference_t<I> n, O result); // since C++20
290
291 template<input_iterator I, sentinel_for<I> S, weakly_incrementable O, class Proj = identity,
292 indirect_unary_predicate<projected<I, Proj>> Pred>
293 requires indirectly_copyable<I, O>
294 constexpr ranges::copy_if_result<I, O>
295 ranges::copy_if(I first, S last, O result, Pred pred, Proj proj = {}); // since C++20
296
297 template<input_range R, weakly_incrementable O, class Proj = identity,
298 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
299 requires indirectly_copyable<iterator_t<R>, O>
300 constexpr ranges::copy_if_result<borrowed_iterator_t<R>, O>
301 ranges::copy_if(R&& r, O result, Pred pred, Proj proj = {}); // since C++20
302
303 template<bidirectional_iterator I1, sentinel_for<I1> S1, bidirectional_iterator I2>
304 requires indirectly_copyable<I1, I2>
305 constexpr ranges::copy_backward_result<I1, I2>
306 ranges::copy_backward(I1 first, S1 last, I2 result); // since C++20
307
308 template<bidirectional_range R, bidirectional_iterator I>
309 requires indirectly_copyable<iterator_t<R>, I>
310 constexpr ranges::copy_backward_result<borrowed_iterator_t<R>, I>
311 ranges::copy_backward(R&& r, I result); // since C++20
312
313 template<class I, class F>
314 using for_each_result = in_fun_result<I, F>; // since C++20
315
316 template<input_iterator I, sentinel_for<I> S, class Proj = identity,
317 indirectly_unary_invocable<projected<I, Proj>> Fun>
318 constexpr ranges::for_each_result<I, Fun>
319 ranges::for_each(I first, S last, Fun f, Proj proj = {}); // since C++20
320
321 template<input_range R, class Proj = identity,
322 indirectly_unary_invocable<projected<iterator_t<R>, Proj>> Fun>
323 constexpr ranges::for_each_result<borrowed_iterator_t<R>, Fun>
324 ranges::for_each(R&& r, Fun f, Proj proj = {}); // since C++20
325
326 template<input_iterator I, class Proj = identity,
327 indirectly_unary_invocable<projected<I, Proj>> Fun>
328 constexpr ranges::for_each_n_result<I, Fun>
329 ranges::for_each_n(I first, iter_difference_t<I> n, Fun f, Proj proj = {}); // since C++20
330
331 template<input_iterator I, sentinel_for<I> S, class Proj = identity,
332 indirect_unary_predicate<projected<I, Proj>> Pred>
333 constexpr bool ranges::is_partitioned(I first, S last, Pred pred, Proj proj = {}); // since C++20
334
335 template<input_range R, class Proj = identity,
336 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
337 constexpr bool ranges::is_partitioned(R&& r, Pred pred, Proj proj = {}); // since C++20
338
339 template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less,
340 class Proj = identity>
341 requires sortable<I, Comp, Proj>
342 constexpr I
343 ranges::push_heap(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
344
345 template<random_access_range R, class Comp = ranges::less, class Proj = identity>
346 requires sortable<iterator_t<R>, Comp, Proj>
347 constexpr borrowed_iterator_t<R>
348 ranges::push_heap(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
349
350 template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less,
351 class Proj = identity>
352 requires sortable<I, Comp, Proj>
353 constexpr I
354 ranges::pop_heap(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
355
356 template<random_access_range R, class Comp = ranges::less, class Proj = identity>
357 requires sortable<iterator_t<R>, Comp, Proj>
358 constexpr borrowed_iterator_t<R>
359 ranges::pop_heap(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
360
361 template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less,
362 class Proj = identity>
363 requires sortable<I, Comp, Proj>
364 constexpr I
365 ranges::make_heap(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
366
367 template<random_access_range R, class Comp = ranges::less, class Proj = identity>
368 requires sortable<iterator_t<R>, Comp, Proj>
369 constexpr borrowed_iterator_t<R>
370 ranges::make_heap(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
371
372 template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less,
373 class Proj = identity>
374 requires sortable<I, Comp, Proj>
375 constexpr I
376 ranges::sort_heap(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
377
378 template<random_access_range R, class Comp = ranges::less, class Proj = identity>
379 requires sortable<iterator_t<R>, Comp, Proj>
380 constexpr borrowed_iterator_t<R>
381 ranges::sort_heap(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
382
383 template<random_access_iterator I, sentinel_for<I> S, class Proj = identity,
384 indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
385 constexpr bool is_heap(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
386
387 template<random_access_range R, class Proj = identity,
388 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
389 constexpr bool is_heap(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
390
391 template<random_access_iterator I, sentinel_for<I> S, class Proj = identity,
392 indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
393 constexpr I is_heap_until(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
394
395 template<random_access_range R, class Proj = identity,
396 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
397 constexpr borrowed_iterator_t<R>
398 is_heap_until(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
399
400 template<bidirectional_iterator I, sentinel_for<I> S>
401 requires permutable<I>
402 constexpr I ranges::reverse(I first, S last); // since C++20
403
404 template<bidirectional_range R>
405 requires permutable<iterator_t<R>>
406 constexpr borrowed_iterator_t<R> ranges::reverse(R&& r); // since C++20
407
408 template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less,
409 class Proj = identity>
410 requires sortable<I, Comp, Proj>
411 constexpr I
412 ranges::sort(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
413
414 template<random_access_range R, class Comp = ranges::less, class Proj = identity>
415 requires sortable<iterator_t<R>, Comp, Proj>
416 constexpr borrowed_iterator_t<R>
417 ranges::sort(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
418
419 template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less,
420 class Proj = identity>
421 requires sortable<I, Comp, Proj>
422 I ranges::stable_sort(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
423
424 template<random_access_range R, class Comp = ranges::less, class Proj = identity>
425 requires sortable<iterator_t<R>, Comp, Proj>
426 borrowed_iterator_t<R>
427 ranges::stable_sort(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
428
429 template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less,
430 class Proj = identity>
431 requires sortable<I, Comp, Proj>
432 constexpr I
433 ranges::partial_sort(I first, I middle, S last, Comp comp = {}, Proj proj = {}); // since C++20
434
435 template<random_access_range R, class Comp = ranges::less, class Proj = identity>
436 requires sortable<iterator_t<R>, Comp, Proj>
437 constexpr borrowed_iterator_t<R>
438 ranges::partial_sort(R&& r, iterator_t<R> middle, Comp comp = {}, Proj proj = {}); // since C++20
439
440 template<class T, output_iterator<const T&> O, sentinel_for<O> S>
441 constexpr O ranges::fill(O first, S last, const T& value); // since C++20
442
443 template<class T, output_range<const T&> R>
444 constexpr borrowed_iterator_t<R> ranges::fill(R&& r, const T& value); // since C++20
445
446 template<class T, output_iterator<const T&> O>
447 constexpr O ranges::fill_n(O first, iter_difference_t<O> n, const T& value); // since C++20
448
449 template<input_or_output_iterator O, sentinel_for<O> S, copy_constructible F>
450 requires invocable<F&> && indirectly_writable<O, invoke_result_t<F&>>
451 constexpr O generate(O first, S last, F gen); // since C++20
452
453 template<class ExecutionPolicy, class ForwardIterator, class Generator>
454 void generate(ExecutionPolicy&& exec,
455 ForwardIterator first, ForwardIterator last,
456 Generator gen); // since C++17
457
458 template<class R, copy_constructible F>
459 requires invocable<F&> && output_range<R, invoke_result_t<F&>>
460 constexpr borrowed_iterator_t<R> generate(R&& r, F gen); // since C++20
461
462 template<input_or_output_iterator O, copy_constructible F>
463 requires invocable<F&> && indirectly_writable<O, invoke_result_t<F&>>
464 constexpr O generate_n(O first, iter_difference_t<O> n, F gen); // since C++20
465
466 template<class ExecutionPolicy, class ForwardIterator, class Size, class Generator>
467 ForwardIterator generate_n(ExecutionPolicy&& exec,
468 ForwardIterator first, Size n, Generator gen); // since C++17
469
470 template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
471 class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
472 requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
473 constexpr bool ranges::equal(I1 first1, S1 last1, I2 first2, S2 last2,
474 Pred pred = {},
475 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
476
477 template<input_range R1, input_range R2, class Pred = ranges::equal_to,
478 class Proj1 = identity, class Proj2 = identity>
479 requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
480 constexpr bool ranges::equal(R1&& r1, R2&& r2, Pred pred = {},
481 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
482
483 template<input_iterator I, sentinel_for<I> S, class Proj = identity,
484 indirect_unary_predicate<projected<I, Proj>> Pred>
485 constexpr bool ranges::all_of(I first, S last, Pred pred, Proj proj = {}); // since C++20
486
487 template<input_range R, class Proj = identity,
488 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
489 constexpr bool ranges::all_of(R&& r, Pred pred, Proj proj = {}); // since C++20
490
491 template<input_iterator I, sentinel_for<I> S, class Proj = identity,
492 indirect_unary_predicate<projected<I, Proj>> Pred>
493 constexpr bool ranges::any_of(I first, S last, Pred pred, Proj proj = {}); // since C++20
494
495 template<input_range R, class Proj = identity,
496 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
497 constexpr bool ranges::any_of(R&& r, Pred pred, Proj proj = {}); // since C++20
498
499 template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
500 class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
501 requires (forward_iterator<I1> || sized_sentinel_for<S1, I1>) &&
502 (forward_iterator<I2> || sized_sentinel_for<S2, I2>) &&
503 indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
504 constexpr bool ranges::ends_with(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {},
505 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++23
506
507 template<input_range R1, input_range R2, class Pred = ranges::equal_to, class Proj1 = identity,
508 class Proj2 = identity>
509 requires (forward_range<R1> || sized_range<R1>) &&
510 (forward_range<R2> || sized_range<R2>) &&
511 indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
512 constexpr bool ranges::ends_with(R1&& r1, R2&& r2, Pred pred = {},
513 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++23
514
515 template<input_iterator I, sentinel_for<I> S, class Proj = identity,
516 indirect_unary_predicate<projected<I, Proj>> Pred>
517 constexpr bool ranges::none_of(I first, S last, Pred pred, Proj proj = {}); // since C++20
518
519 template<input_range R, class Proj = identity,
520 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
521 constexpr bool ranges::none_of(R&& r, Pred pred, Proj proj = {}); // since C++20
522
523 template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
524 class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
525 requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
526 constexpr bool ranges::starts_with(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {},
527 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++23
528
529 template<input_range R1, input_range R2, class Pred = ranges::equal_to, class Proj1 = identity,
530 class Proj2 = identity>
531 requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
532 constexpr bool ranges::starts_with(R1&& r1, R2&& r2, Pred pred = {},
533 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++23
534
535 template<input_iterator I1, sentinel_for<I1> S1,
536 random_access_iterator I2, sentinel_for<I2> S2,
537 class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity>
538 requires indirectly_copyable<I1, I2> && sortable<I2, Comp, Proj2> &&
539 indirect_strict_weak_order<Comp, projected<I1, Proj1>, projected<I2, Proj2>>
540 constexpr partial_sort_copy_result<I1, I2>
541 partial_sort_copy(I1 first, S1 last, I2 result_first, S2 result_last,
542 Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
543
544 template<input_range R1, random_access_range R2, class Comp = ranges::less,
545 class Proj1 = identity, class Proj2 = identity>
546 requires indirectly_copyable<iterator_t<R1>, iterator_t<R2>> &&
547 sortable<iterator_t<R2>, Comp, Proj2> &&
548 indirect_strict_weak_order<Comp, projected<iterator_t<R1>, Proj1>,
549 projected<iterator_t<R2>, Proj2>>
550 constexpr partial_sort_copy_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>>
551 partial_sort_copy(R1&& r, R2&& result_r, Comp comp = {},
552 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
553
554 template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
555 indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
556 constexpr bool ranges::is_sorted(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
557
558 template<forward_range R, class Proj = identity,
559 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
560 constexpr bool ranges::is_sorted(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
561
562 template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
563 indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
564 constexpr I ranges::is_sorted_until(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
565
566 template<forward_range R, class Proj = identity,
567 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
568 constexpr borrowed_iterator_t<R>
569 ranges::is_sorted_until(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
570
571 template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less,
572 class Proj = identity>
573 requires sortable<I, Comp, Proj>
574 constexpr I
575 ranges::nth_element(I first, I nth, S last, Comp comp = {}, Proj proj = {}); // since C++20
576
577 template<random_access_range R, class Comp = ranges::less, class Proj = identity>
578 requires sortable<iterator_t<R>, Comp, Proj>
579 constexpr borrowed_iterator_t<R>
580 ranges::nth_element(R&& r, iterator_t<R> nth, Comp comp = {}, Proj proj = {}); // since C++20
581
582 template<forward_iterator I, sentinel_for<I> S, class T, class Proj = identity,
583 indirect_strict_weak_order<const T*, projected<I, Proj>> Comp = ranges::less> // since C++20
584 constexpr I upper_bound(I first, S last, const T& value, Comp comp = {}, Proj proj = {});
585
586 template<forward_range R, class T, class Proj = identity,
587 indirect_strict_weak_order<const T*, projected<iterator_t<R>, Proj>> Comp =
588 ranges::less>
589 constexpr borrowed_iterator_t<R>
590 upper_bound(R&& r, const T& value, Comp comp = {}, Proj proj = {}); // since C++20
591
592 template<forward_iterator I, sentinel_for<I> S, class T, class Proj = identity,
593 indirect_strict_weak_order<const T*, projected<I, Proj>> Comp = ranges::less>
594 constexpr I lower_bound(I first, S last, const T& value, Comp comp = {},
595 Proj proj = {}); // since C++20
596 template<forward_range R, class T, class Proj = identity,
597 indirect_strict_weak_order<const T*, projected<iterator_t<R>, Proj>> Comp =
598 ranges::less>
599 constexpr borrowed_iterator_t<R>
600 lower_bound(R&& r, const T& value, Comp comp = {}, Proj proj = {}); // since C++20
601
602 template<forward_iterator I, sentinel_for<I> S, class T, class Proj = identity,
603 indirect_strict_weak_order<const T*, projected<I, Proj>> Comp = ranges::less>
604 constexpr bool binary_search(I first, S last, const T& value, Comp comp = {},
605 Proj proj = {}); // since C++20
606
607 template<forward_range R, class T, class Proj = identity,
608 indirect_strict_weak_order<const T*, projected<iterator_t<R>, Proj>> Comp =
609 ranges::less>
610 constexpr bool binary_search(R&& r, const T& value, Comp comp = {},
611 Proj proj = {}); // since C++20
612
613 template<permutable I, sentinel_for<I> S, class Proj = identity,
614 indirect_unary_predicate<projected<I, Proj>> Pred>
615 constexpr subrange<I>
616 partition(I first, S last, Pred pred, Proj proj = {}); // since C++20
617
618 template<forward_range R, class Proj = identity,
619 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
620 requires permutable<iterator_t<R>>
621 constexpr borrowed_subrange_t<R>
622 partition(R&& r, Pred pred, Proj proj = {}); // since C++20
623
624 template<bidirectional_iterator I, sentinel_for<I> S, class Proj = identity,
625 indirect_unary_predicate<projected<I, Proj>> Pred>
626 requires permutable<I>
627 subrange<I> stable_partition(I first, S last, Pred pred, Proj proj = {}); // since C++20
628
629 template<bidirectional_range R, class Proj = identity,
630 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
631 requires permutable<iterator_t<R>>
632 borrowed_subrange_t<R> stable_partition(R&& r, Pred pred, Proj proj = {}); // since C++20
633
634 template<input_iterator I1, sentinel_for<I1> S1, forward_iterator I2, sentinel_for<I2> S2,
635 class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
636 requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
637 constexpr I1 ranges::find_first_of(I1 first1, S1 last1, I2 first2, S2 last2,
638 Pred pred = {},
639 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
640
641 template<input_range R1, forward_range R2,
642 class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
643 requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
644 constexpr borrowed_iterator_t<R1>
645 ranges::find_first_of(R1&& r1, R2&& r2,
646 Pred pred = {},
647 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
648
649 template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
650 indirect_binary_predicate<projected<I, Proj>,
651 projected<I, Proj>> Pred = ranges::equal_to>
652 constexpr I ranges::adjacent_find(I first, S last, Pred pred = {}, Proj proj = {}); // since C++20
653
654 template<forward_range R, class Proj = identity,
655 indirect_binary_predicate<projected<iterator_t<R>, Proj>,
656 projected<iterator_t<R>, Proj>> Pred = ranges::equal_to>
657 constexpr borrowed_iterator_t<R> ranges::adjacent_find(R&& r, Pred pred = {}, Proj proj = {}); // since C++20
658
659 template<input_iterator I, sentinel_for<I> S, class T1, class T2, class Proj = identity>
660 requires indirectly_writable<I, const T2&> &&
661 indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T1*>
662 constexpr I
663 ranges::replace(I first, S last, const T1& old_value, const T2& new_value, Proj proj = {}); // since C++20
664
665 template<input_range R, class T1, class T2, class Proj = identity>
666 requires indirectly_writable<iterator_t<R>, const T2&> &&
667 indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T1*>
668 constexpr borrowed_iterator_t<R>
669 ranges::replace(R&& r, const T1& old_value, const T2& new_value, Proj proj = {}); // since C++20
670
671 template<input_iterator I, sentinel_for<I> S, class T, class Proj = identity,
672 indirect_unary_predicate<projected<I, Proj>> Pred>
673 requires indirectly_writable<I, const T&>
674 constexpr I ranges::replace_if(I first, S last, Pred pred, const T& new_value, Proj proj = {}); // since C++20
675
676 template<input_range R, class T, class Proj = identity,
677 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
678 requires indirectly_writable<iterator_t<R>, const T&>
679 constexpr borrowed_iterator_t<R>
680 ranges::replace_if(R&& r, Pred pred, const T& new_value, Proj proj = {}); // since C++20
681
682 template<class T, class Proj = identity,
683 indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
684 constexpr const T&
685 ranges::clamp(const T& v, const T& lo, const T& hi, Comp comp = {}, Proj proj = {}); // since C++20
686
687 template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
688 class Proj1 = identity, class Proj2 = identity,
689 indirect_strict_weak_order<projected<I1, Proj1>,
690 projected<I2, Proj2>> Comp = ranges::less>
691 constexpr bool
692 ranges::lexicographical_compare(I1 first1, S1 last1, I2 first2, S2 last2,
693 Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
694
695 template<input_range R1, input_range R2, class Proj1 = identity,
696 class Proj2 = identity,
697 indirect_strict_weak_order<projected<iterator_t<R1>, Proj1>,
698 projected<iterator_t<R2>, Proj2>> Comp = ranges::less>
699 constexpr bool
700 ranges::lexicographical_compare(R1&& r1, R2&& r2, Comp comp = {},
701 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
702
703 template<bidirectional_iterator I1, sentinel_for<I1> S1, bidirectional_iterator I2>
704 requires indirectly_movable<I1, I2>
705 constexpr ranges::move_backward_result<I1, I2>
706 ranges::move_backward(I1 first, S1 last, I2 result); // since C++20
707
708 template<bidirectional_range R, bidirectional_iterator I>
709 requires indirectly_movable<iterator_t<R>, I>
710 constexpr ranges::move_backward_result<borrowed_iterator_t<R>, I>
711 ranges::move_backward(R&& r, I result); // since C++20
712
713 template<input_iterator I, sentinel_for<I> S, weakly_incrementable O>
714 requires indirectly_movable<I, O>
715 constexpr ranges::move_result<I, O>
716 ranges::move(I first, S last, O result); // since C++20
717
718 template<input_range R, weakly_incrementable O>
719 requires indirectly_movable<iterator_t<R>, O>
720 constexpr ranges::move_result<borrowed_iterator_t<R>, O>
721 ranges::move(R&& r, O result); // since C++20
722
723 template<class I, class O1, class O2>
724 using partition_copy_result = in_out_out_result<I, O1, O2>; // since C++20
725
726 template<input_iterator I, sentinel_for<I> S,
727 weakly_incrementable O1, weakly_incrementable O2,
728 class Proj = identity, indirect_unary_predicate<projected<I, Proj>> Pred>
729 requires indirectly_copyable<I, O1> && indirectly_copyable<I, O2>
730 constexpr partition_copy_result<I, O1, O2>
731 partition_copy(I first, S last, O1 out_true, O2 out_false, Pred pred,
732 Proj proj = {}); // since C++20
733
734 template<input_range R, weakly_incrementable O1, weakly_incrementable O2,
735 class Proj = identity,
736 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
737 requires indirectly_copyable<iterator_t<R>, O1> &&
738 indirectly_copyable<iterator_t<R>, O2>
739 constexpr partition_copy_result<borrowed_iterator_t<R>, O1, O2>
740 partition_copy(R&& r, O1 out_true, O2 out_false, Pred pred, Proj proj = {}); // since C++20
741
742 template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
743 indirect_unary_predicate<projected<I, Proj>> Pred>
744 constexpr I partition_point(I first, S last, Pred pred, Proj proj = {}); // since C++20
745
746 template<forward_range R, class Proj = identity,
747 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
748 constexpr borrowed_iterator_t<R>
749 partition_point(R&& r, Pred pred, Proj proj = {}); // since C++20
750
751 template<class I1, class I2, class O>
752 using merge_result = in_in_out_result<I1, I2, O>; // since C++20
753
754 template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
755 weakly_incrementable O, class Comp = ranges::less, class Proj1 = identity,
756 class Proj2 = identity>
757 requires mergeable<I1, I2, O, Comp, Proj1, Proj2>
758 constexpr merge_result<I1, I2, O>
759 merge(I1 first1, S1 last1, I2 first2, S2 last2, O result,
760 Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
761
762 template<input_range R1, input_range R2, weakly_incrementable O, class Comp = ranges::less,
763 class Proj1 = identity, class Proj2 = identity>
764 requires mergeable<iterator_t<R1>, iterator_t<R2>, O, Comp, Proj1, Proj2>
765 constexpr merge_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>, O>
766 merge(R1&& r1, R2&& r2, O result,
767 Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
768
769 template<permutable I, sentinel_for<I> S, class T, class Proj = identity>
770 requires indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
771 constexpr subrange<I> ranges::remove(I first, S last, const T& value, Proj proj = {}); // since C++20
772
773 template<forward_range R, class T, class Proj = identity>
774 requires permutable<iterator_t<R>> &&
775 indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*>
776 constexpr borrowed_subrange_t<R>
777 ranges::remove(R&& r, const T& value, Proj proj = {}); // since C++20
778
779 template<permutable I, sentinel_for<I> S, class Proj = identity,
780 indirect_unary_predicate<projected<I, Proj>> Pred>
781 constexpr subrange<I> ranges::remove_if(I first, S last, Pred pred, Proj proj = {}); // since C++20
782
783 template<forward_range R, class Proj = identity,
784 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
785 requires permutable<iterator_t<R>>
786 constexpr borrowed_subrange_t<R>
787 ranges::remove_if(R&& r, Pred pred, Proj proj = {}); // since C++20
788
789 template<class I, class O>
790 using set_difference_result = in_out_result<I, O>; // since C++20
791
792 template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
793 weakly_incrementable O, class Comp = ranges::less,
794 class Proj1 = identity, class Proj2 = identity>
795 requires mergeable<I1, I2, O, Comp, Proj1, Proj2>
796 constexpr set_difference_result<I1, O>
797 set_difference(I1 first1, S1 last1, I2 first2, S2 last2, O result,
798 Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
799
800 template<input_range R1, input_range R2, weakly_incrementable O,
801 class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity>
802 requires mergeable<iterator_t<R1>, iterator_t<R2>, O, Comp, Proj1, Proj2>
803 constexpr set_difference_result<borrowed_iterator_t<R1>, O>
804 set_difference(R1&& r1, R2&& r2, O result,
805 Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
806
807 template<class I1, class I2, class O>
808 using set_intersection_result = in_in_out_result<I1, I2, O>; // since C++20
809
810 template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
811 weakly_incrementable O, class Comp = ranges::less,
812 class Proj1 = identity, class Proj2 = identity>
813 requires mergeable<I1, I2, O, Comp, Proj1, Proj2>
814 constexpr set_intersection_result<I1, I2, O>
815 set_intersection(I1 first1, S1 last1, I2 first2, S2 last2, O result,
816 Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
817
818 template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
819 weakly_incrementable O, class Comp = ranges::less,
820 class Proj1 = identity, class Proj2 = identity>
821 requires mergeable<I1, I2, O, Comp, Proj1, Proj2>
822 constexpr set_intersection_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>, O>
823 set_intersection(R1&& r1, R2&& r2, O result,
824 Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
825
826 template <class _InIter, class _OutIter>
827 using reverse_copy_result = in_out_result<_InIter, _OutIter>; // since C++20
828
829 template<bidirectional_iterator I, sentinel_for<I> S, weakly_incrementable O>
830 requires indirectly_copyable<I, O>
831 constexpr ranges::reverse_copy_result<I, O>
832 ranges::reverse_copy(I first, S last, O result); // since C++20
833
834 template<bidirectional_range R, weakly_incrementable O>
835 requires indirectly_copyable<iterator_t<R>, O>
836 constexpr ranges::reverse_copy_result<borrowed_iterator_t<R>, O>
837 ranges::reverse_copy(R&& r, O result); // since C++20
838
839 template<permutable I, sentinel_for<I> S>
840 constexpr subrange<I> rotate(I first, I middle, S last); // since C++20
841
842 template<forward_range R>
843 requires permutable<iterator_t<R>>
844 constexpr borrowed_subrange_t<R> rotate(R&& r, iterator_t<R> middle); // since C++20
845
846 template <class _InIter, class _OutIter>
847 using rotate_copy_result = in_out_result<_InIter, _OutIter>; // since C++20
848
849 template<forward_iterator I, sentinel_for<I> S, weakly_incrementable O>
850 requires indirectly_copyable<I, O>
851 constexpr ranges::rotate_copy_result<I, O>
852 ranges::rotate_copy(I first, I middle, S last, O result); // since C++20
853
854 template<forward_range R, weakly_incrementable O>
855 requires indirectly_copyable<iterator_t<R>, O>
856 constexpr ranges::rotate_copy_result<borrowed_iterator_t<R>, O>
857 ranges::rotate_copy(R&& r, iterator_t<R> middle, O result); // since C++20
858
859 template<input_iterator I, sentinel_for<I> S, weakly_incrementable O, class Gen>
860 requires (forward_iterator<I> || random_access_iterator<O>) &&
861 indirectly_copyable<I, O> &&
862 uniform_random_bit_generator<remove_reference_t<Gen>>
863 O sample(I first, S last, O out, iter_difference_t<I> n, Gen&& g); // since C++20
864
865 template<input_range R, weakly_incrementable O, class Gen>
866 requires (forward_range<R> || random_access_iterator<O>) &&
867 indirectly_copyable<iterator_t<R>, O> &&
868 uniform_random_bit_generator<remove_reference_t<Gen>>
869 O sample(R&& r, O out, range_difference_t<R> n, Gen&& g); // since C++20
870
871 template<random_access_iterator I, sentinel_for<I> S, class Gen>
872 requires permutable<I> &&
873 uniform_random_bit_generator<remove_reference_t<Gen>>
874 I shuffle(I first, S last, Gen&& g); // since C++20
875
876 template<random_access_range R, class Gen>
877 requires permutable<iterator_t<R>> &&
878 uniform_random_bit_generator<remove_reference_t<Gen>>
879 borrowed_iterator_t<R> shuffle(R&& r, Gen&& g); // since C++20
880
881 template<forward_iterator I1, sentinel_for<I1> S1, forward_iterator I2,
882 sentinel_for<I2> S2, class Proj1 = identity, class Proj2 = identity,
883 indirect_equivalence_relation<projected<I1, Proj1>,
884 projected<I2, Proj2>> Pred = ranges::equal_to>
885 constexpr bool ranges::is_permutation(I1 first1, S1 last1, I2 first2, S2 last2,
886 Pred pred = {},
887 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
888
889 template<forward_range R1, forward_range R2,
890 class Proj1 = identity, class Proj2 = identity,
891 indirect_equivalence_relation<projected<iterator_t<R1>, Proj1>,
892 projected<iterator_t<R2>, Proj2>> Pred = ranges::equal_to>
893 constexpr bool ranges::is_permutation(R1&& r1, R2&& r2, Pred pred = {},
894 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
895
896 template<forward_iterator I1, sentinel_for<I1> S1, forward_iterator I2,
897 sentinel_for<I2> S2, class Pred = ranges::equal_to,
898 class Proj1 = identity, class Proj2 = identity>
899 requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
900 constexpr subrange<I1>
901 ranges::search(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {},
902 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
903
904 template<forward_range R1, forward_range R2, class Pred = ranges::equal_to,
905 class Proj1 = identity, class Proj2 = identity>
906 requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
907 constexpr borrowed_subrange_t<R1>
908 ranges::search(R1&& r1, R2&& r2, Pred pred = {},
909 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
910
911 template<forward_iterator I, sentinel_for<I> S, class T,
912 class Pred = ranges::equal_to, class Proj = identity>
913 requires indirectly_comparable<I, const T*, Pred, Proj>
914 constexpr subrange<I>
915 ranges::search_n(I first, S last, iter_difference_t<I> count,
916 const T& value, Pred pred = {}, Proj proj = {}); // since C++20
917
918 template<forward_range R, class T, class Pred = ranges::equal_to,
919 class Proj = identity>
920 requires indirectly_comparable<iterator_t<R>, const T*, Pred, Proj>
921 constexpr borrowed_subrange_t<R>
922 ranges::search_n(R&& r, range_difference_t<R> count,
923 const T& value, Pred pred = {}, Proj proj = {}); // since C++20
924
925 template<input_iterator I, sentinel_for<I> S, class T,
926 indirectly-binary-left-foldable<T, I> F>
927 constexpr auto ranges::fold_left(I first, S last, T init, F f); // since C++23
928
929 template<input_range R, class T, indirectly-binary-left-foldable<T, iterator_t<R>> F>
930 constexpr auto fold_left(R&& r, T init, F f); // since C++23
931
932 template<class I, class T>
933 using fold_left_with_iter_result = in_value_result<I, T>; // since C++23
934
935 template<input_iterator I, sentinel_for<I> S, class T,
936 indirectly-binary-left-foldable<T, I> F>
937 constexpr see below fold_left_with_iter(I first, S last, T init, F f); // since C++23
938
939 template<input_range R, class T, indirectly-binary-left-foldable<T, iterator_t<R>> F>
940 constexpr see below fold_left_with_iter(R&& r, T init, F f); // since C++23
941
942 template<forward_iterator I1, sentinel_for<I1> S1, forward_iterator I2, sentinel_for<I2> S2,
943 class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
944 requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
945 constexpr subrange<I1>
946 ranges::find_end(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {},
947 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
948
949 template<forward_range R1, forward_range R2,
950 class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
951 requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
952 constexpr borrowed_subrange_t<R1>
953 ranges::find_end(R1&& r1, R2&& r2, Pred pred = {},
954 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
955
956 template<class I1, class I2, class O>
957 using set_symmetric_difference_result = in_in_out_result<I1, I2, O>; // since C++20
958
959 template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
960 weakly_incrementable O, class Comp = ranges::less,
961 class Proj1 = identity, class Proj2 = identity>
962 requires mergeable<I1, I2, O, Comp, Proj1, Proj2>
963 constexpr set_symmetric_difference_result<I1, I2, O>
964 set_symmetric_difference(I1 first1, S1 last1, I2 first2, S2 last2, O result,
965 Comp comp = {}, Proj1 proj1 = {},
966 Proj2 proj2 = {}); // since C++20
967
968 template<input_range R1, input_range R2, weakly_incrementable O,
969 class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity>
970 requires mergeable<iterator_t<R1>, iterator_t<R2>, O, Comp, Proj1, Proj2>
971 constexpr set_symmetric_difference_result<borrowed_iterator_t<R1>,
972 borrowed_iterator_t<R2>, O>
973 set_symmetric_difference(R1&& r1, R2&& r2, O result, Comp comp = {},
974 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
975
976 template<forward_iterator I, sentinel_for<I> S, class T, class Proj = identity,
977 indirect_strict_weak_order<const T*, projected<I, Proj>> Comp = ranges::less>
978 constexpr subrange<I>
979 equal_range(I first, S last, const T& value, Comp comp = {}, Proj proj = {}); // since C++20
980
981 template<forward_range R, class T, class Proj = identity,
982 indirect_strict_weak_order<const T*, projected<iterator_t<R>, Proj>> Comp =
983 ranges::less>
984 constexpr borrowed_subrange_t<R>
985 equal_range(R&& r, const T& value, Comp comp = {}, Proj proj = {}); // since C++20
986
987 template<class I1, class I2, class O>
988 using set_union_result = in_in_out_result<I1, I2, O>; // since C++20
989
990 template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
991 weakly_incrementable O, class Comp = ranges::less,
992 class Proj1 = identity, class Proj2 = identity>
993 requires mergeable<I1, I2, O, Comp, Proj1, Proj2>
994 constexpr set_union_result<I1, I2, O>
995 set_union(I1 first1, S1 last1, I2 first2, S2 last2, O result, Comp comp = {},
996 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
997
998 template<input_range R1, input_range R2, weakly_incrementable O,
999 class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity>
1000 requires mergeable<iterator_t<R1>, iterator_t<R2>, O, Comp, Proj1, Proj2>
1001 constexpr set_union_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>, O>
1002 set_union(R1&& r1, R2&& r2, O result, Comp comp = {},
1003 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
1004
1005 template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
1006 class Proj1 = identity, class Proj2 = identity,
1007 indirect_strict_weak_order<projected<I1, Proj1>, projected<I2, Proj2>> Comp =
1008 ranges::less>
1009 constexpr bool includes(I1 first1, S1 last1, I2 first2, S2 last2, Comp comp = {},
1010 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
1011
1012 template<input_range R1, input_range R2, class Proj1 = identity,
1013 class Proj2 = identity,
1014 indirect_strict_weak_order<projected<iterator_t<R1>, Proj1>,
1015 projected<iterator_t<R2>, Proj2>> Comp = ranges::less>
1016 constexpr bool includes(R1&& r1, R2&& r2, Comp comp = {},
1017 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
1018
1019 template<bidirectional_iterator I, sentinel_for<I> S, class Comp = ranges::less,
1020 class Proj = identity>
1021 requires sortable<I, Comp, Proj>
1022 I inplace_merge(I first, I middle, S last, Comp comp = {}, Proj proj = {}); // since C++20
1023
1024 template<bidirectional_range R, class Comp = ranges::less, class Proj = identity>
1025 requires sortable<iterator_t<R>, Comp, Proj>
1026 borrowed_iterator_t<R>
1027 inplace_merge(R&& r, iterator_t<R> middle, Comp comp = {},
1028 Proj proj = {}); // since C++20
1029
1030 template<permutable I, sentinel_for<I> S, class Proj = identity,
1031 indirect_equivalence_relation<projected<I, Proj>> C = ranges::equal_to>
1032 constexpr subrange<I> unique(I first, S last, C comp = {}, Proj proj = {}); // since C++20
1033
1034 template<forward_range R, class Proj = identity,
1035 indirect_equivalence_relation<projected<iterator_t<R>, Proj>> C = ranges::equal_to>
1036 requires permutable<iterator_t<R>>
1037 constexpr borrowed_subrange_t<R>
1038 unique(R&& r, C comp = {}, Proj proj = {}); // since C++20
1039
1040 template<input_iterator I, sentinel_for<I> S, weakly_incrementable O, class Proj = identity,
1041 indirect_equivalence_relation<projected<I, Proj>> C = ranges::equal_to>
1042 requires indirectly_copyable<I, O> &&
1043 (forward_iterator<I> ||
1044 (input_iterator<O> && same_as<iter_value_t<I>, iter_value_t<O>>) ||
1045 indirectly_copyable_storable<I, O>)
1046 constexpr unique_copy_result<I, O>
1047 unique_copy(I first, S last, O result, C comp = {}, Proj proj = {}); // since C++20
1048
1049 template<input_range R, weakly_incrementable O, class Proj = identity,
1050 indirect_equivalence_relation<projected<iterator_t<R>, Proj>> C = ranges::equal_to>
1051 requires indirectly_copyable<iterator_t<R>, O> &&
1052 (forward_iterator<iterator_t<R>> ||
1053 (input_iterator<O> && same_as<range_value_t<R>, iter_value_t<O>>) ||
1054 indirectly_copyable_storable<iterator_t<R>, O>)
1055 constexpr unique_copy_result<borrowed_iterator_t<R>, O>
1056 unique_copy(R&& r, O result, C comp = {}, Proj proj = {}); // since C++20
1057
1058 template<class I, class O>
1059 using remove_copy_result = in_out_result<I, O>; // since C++20
1060
1061 template<input_iterator I, sentinel_for<I> S, weakly_incrementable O, class T,
1062 class Proj = identity>
1063 indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
1064 constexpr remove_copy_result<I, O>
1065 remove_copy(I first, S last, O result, const T& value, Proj proj = {}); // since C++20
1066
1067 template<input_range R, weakly_incrementable O, class T, class Proj = identity>
1068 requires indirectly_copyable<iterator_t<R>, O> &&
1069 indirect_binary_predicate<ranges::equal_to,
1070 projected<iterator_t<R>, Proj>, const T*>
1071 constexpr remove_copy_result<borrowed_iterator_t<R>, O>
1072 remove_copy(R&& r, O result, const T& value, Proj proj = {}); // since C++20
1073
1074 template<class I, class O>
1075 using remove_copy_if_result = in_out_result<I, O>; // since C++20
1076
1077 template<input_iterator I, sentinel_for<I> S, weakly_incrementable O,
1078 class Proj = identity, indirect_unary_predicate<projected<I, Proj>> Pred>
1079 requires indirectly_copyable<I, O>
1080 constexpr remove_copy_if_result<I, O>
1081 remove_copy_if(I first, S last, O result, Pred pred, Proj proj = {}); // since C++20
1082
1083 template<input_range R, weakly_incrementable O, class Proj = identity,
1084 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
1085 requires indirectly_copyable<iterator_t<R>, O>
1086 constexpr remove_copy_if_result<borrowed_iterator_t<R>, O>
1087 remove_copy_if(R&& r, O result, Pred pred, Proj proj = {}); // since C++20
1088
1089 template<class I, class O>
1090 using replace_copy_result = in_out_result<I, O>; // since C++20
1091
1092 template<input_iterator I, sentinel_for<I> S, class T1, class T2,
1093 output_iterator<const T2&> O, class Proj = identity>
1094 requires indirectly_copyable<I, O> &&
1095 indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T1*>
1096 constexpr replace_copy_result<I, O>
1097 replace_copy(I first, S last, O result, const T1& old_value, const T2& new_value,
1098 Proj proj = {}); // since C++20
1099
1100 template<input_range R, class T1, class T2, output_iterator<const T2&> O,
1101 class Proj = identity>
1102 requires indirectly_copyable<iterator_t<R>, O> &&
1103 indirect_binary_predicate<ranges::equal_to,
1104 projected<iterator_t<R>, Proj>, const T1*>
1105 constexpr replace_copy_result<borrowed_iterator_t<R>, O>
1106 replace_copy(R&& r, O result, const T1& old_value, const T2& new_value,
1107 Proj proj = {}); // since C++20
1108
1109 template<class I, class O>
1110 using replace_copy_if_result = in_out_result<I, O>; // since C++20
1111
1112 template<input_iterator I, sentinel_for<I> S, class T, output_iterator<const T&> O,
1113 class Proj = identity, indirect_unary_predicate<projected<I, Proj>> Pred>
1114 requires indirectly_copyable<I, O>
1115 constexpr replace_copy_if_result<I, O>
1116 replace_copy_if(I first, S last, O result, Pred pred, const T& new_value,
1117 Proj proj = {}); // since C++20
1118
1119 template<input_range R, class T, output_iterator<const T&> O, class Proj = identity,
1120 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
1121 requires indirectly_copyable<iterator_t<R>, O>
1122 constexpr replace_copy_if_result<borrowed_iterator_t<R>, O>
1123 replace_copy_if(R&& r, O result, Pred pred, const T& new_value,
1124 Proj proj = {}); // since C++20
1125
1126 template<class I>
1127 using prev_permutation_result = in_found_result<I>; // since C++20
1128
1129 template<bidirectional_iterator I, sentinel_for<I> S, class Comp = ranges::less,
1130 class Proj = identity>
1131 requires sortable<I, Comp, Proj>
1132 constexpr ranges::prev_permutation_result<I>
1133 ranges::prev_permutation(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
1134
1135 template<bidirectional_range R, class Comp = ranges::less,
1136 class Proj = identity>
1137 requires sortable<iterator_t<R>, Comp, Proj>
1138 constexpr ranges::prev_permutation_result<borrowed_iterator_t<R>>
1139 ranges::prev_permutation(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
1140
1141 template<class I>
1142 using next_permutation_result = in_found_result<I>; // since C++20
1143
1144 template<bidirectional_iterator I, sentinel_for<I> S, class Comp = ranges::less,
1145 class Proj = identity>
1146 requires sortable<I, Comp, Proj>
1147 constexpr ranges::next_permutation_result<I>
1148 ranges::next_permutation(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
1149
1150 template<bidirectional_range R, class Comp = ranges::less,
1151 class Proj = identity>
1152 requires sortable<iterator_t<R>, Comp, Proj>
1153 constexpr ranges::next_permutation_result<borrowed_iterator_t<R>>
1154 ranges::next_permutation(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
1155
1156}
1157
1158template <class InputIterator, class Predicate>
1159 constexpr bool // constexpr in C++20
1160 all_of(InputIterator first, InputIterator last, Predicate pred);
1161
1162template <class InputIterator, class Predicate>
1163 constexpr bool // constexpr in C++20
1164 any_of(InputIterator first, InputIterator last, Predicate pred);
1165
1166template <class InputIterator, class Predicate>
1167 constexpr bool // constexpr in C++20
1168 none_of(InputIterator first, InputIterator last, Predicate pred);
1169
1170template <class InputIterator, class Function>
1171 constexpr Function // constexpr in C++20
1172 for_each(InputIterator first, InputIterator last, Function f);
1173
1174template<class InputIterator, class Size, class Function>
1175 constexpr InputIterator // constexpr in C++20
1176 for_each_n(InputIterator first, Size n, Function f); // C++17
1177
1178template <class InputIterator, class T>
1179 constexpr InputIterator // constexpr in C++20
1180 find(InputIterator first, InputIterator last, const T& value);
1181
1182template <class InputIterator, class Predicate>
1183 constexpr InputIterator // constexpr in C++20
1184 find_if(InputIterator first, InputIterator last, Predicate pred);
1185
1186template<class InputIterator, class Predicate>
1187 constexpr InputIterator // constexpr in C++20
1188 find_if_not(InputIterator first, InputIterator last, Predicate pred);
1189
1190template <class ForwardIterator1, class ForwardIterator2>
1191 constexpr ForwardIterator1 // constexpr in C++20
1192 find_end(ForwardIterator1 first1, ForwardIterator1 last1,
1193 ForwardIterator2 first2, ForwardIterator2 last2);
1194
1195template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
1196 constexpr ForwardIterator1 // constexpr in C++20
1197 find_end(ForwardIterator1 first1, ForwardIterator1 last1,
1198 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
1199
1200template <class ForwardIterator1, class ForwardIterator2>
1201 constexpr ForwardIterator1 // constexpr in C++20
1202 find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
1203 ForwardIterator2 first2, ForwardIterator2 last2);
1204
1205template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
1206 constexpr ForwardIterator1 // constexpr in C++20
1207 find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
1208 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
1209
1210template <class ForwardIterator>
1211 constexpr ForwardIterator // constexpr in C++20
1212 adjacent_find(ForwardIterator first, ForwardIterator last);
1213
1214template <class ForwardIterator, class BinaryPredicate>
1215 constexpr ForwardIterator // constexpr in C++20
1216 adjacent_find(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
1217
1218template <class InputIterator, class T>
1219 constexpr typename iterator_traits<InputIterator>::difference_type // constexpr in C++20
1220 count(InputIterator first, InputIterator last, const T& value);
1221
1222template <class InputIterator, class Predicate>
1223 constexpr typename iterator_traits<InputIterator>::difference_type // constexpr in C++20
1224 count_if(InputIterator first, InputIterator last, Predicate pred);
1225
1226template <class InputIterator1, class InputIterator2>
1227 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
1228 mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
1229
1230template <class InputIterator1, class InputIterator2>
1231 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
1232 mismatch(InputIterator1 first1, InputIterator1 last1,
1233 InputIterator2 first2, InputIterator2 last2); // **C++14**
1234
1235template <class InputIterator1, class InputIterator2, class BinaryPredicate>
1236 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
1237 mismatch(InputIterator1 first1, InputIterator1 last1,
1238 InputIterator2 first2, BinaryPredicate pred);
1239
1240template <class InputIterator1, class InputIterator2, class BinaryPredicate>
1241 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
1242 mismatch(InputIterator1 first1, InputIterator1 last1,
1243 InputIterator2 first2, InputIterator2 last2,
1244 BinaryPredicate pred); // **C++14**
1245
1246template <class InputIterator1, class InputIterator2>
1247 constexpr bool // constexpr in C++20
1248 equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
1249
1250template <class InputIterator1, class InputIterator2>
1251 constexpr bool // constexpr in C++20
1252 equal(InputIterator1 first1, InputIterator1 last1,
1253 InputIterator2 first2, InputIterator2 last2); // **C++14**
1254
1255template <class InputIterator1, class InputIterator2, class BinaryPredicate>
1256 constexpr bool // constexpr in C++20
1257 equal(InputIterator1 first1, InputIterator1 last1,
1258 InputIterator2 first2, BinaryPredicate pred);
1259
1260template <class InputIterator1, class InputIterator2, class BinaryPredicate>
1261 constexpr bool // constexpr in C++20
1262 equal(InputIterator1 first1, InputIterator1 last1,
1263 InputIterator2 first2, InputIterator2 last2,
1264 BinaryPredicate pred); // **C++14**
1265
1266template<class ForwardIterator1, class ForwardIterator2>
1267 constexpr bool // constexpr in C++20
1268 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
1269 ForwardIterator2 first2);
1270
1271template<class ForwardIterator1, class ForwardIterator2>
1272 constexpr bool // constexpr in C++20
1273 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
1274 ForwardIterator2 first2, ForwardIterator2 last2); // **C++14**
1275
1276template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
1277 constexpr bool // constexpr in C++20
1278 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
1279 ForwardIterator2 first2, BinaryPredicate pred);
1280
1281template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
1282 constexpr bool // constexpr in C++20
1283 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
1284 ForwardIterator2 first2, ForwardIterator2 last2,
1285 BinaryPredicate pred); // **C++14**
1286
1287template <class ForwardIterator1, class ForwardIterator2>
1288 constexpr ForwardIterator1 // constexpr in C++20
1289 search(ForwardIterator1 first1, ForwardIterator1 last1,
1290 ForwardIterator2 first2, ForwardIterator2 last2);
1291
1292template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
1293 constexpr ForwardIterator1 // constexpr in C++20
1294 search(ForwardIterator1 first1, ForwardIterator1 last1,
1295 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
1296
1297template <class ForwardIterator, class Size, class T>
1298 constexpr ForwardIterator // constexpr in C++20
1299 search_n(ForwardIterator first, ForwardIterator last, Size count, const T& value);
1300
1301template <class ForwardIterator, class Size, class T, class BinaryPredicate>
1302 constexpr ForwardIterator // constexpr in C++20
1303 search_n(ForwardIterator first, ForwardIterator last,
1304 Size count, const T& value, BinaryPredicate pred);
1305
1306template <class InputIterator, class OutputIterator>
1307 constexpr OutputIterator // constexpr in C++20
1308 copy(InputIterator first, InputIterator last, OutputIterator result);
1309
1310template<class InputIterator, class OutputIterator, class Predicate>
1311 constexpr OutputIterator // constexpr in C++20
1312 copy_if(InputIterator first, InputIterator last,
1313 OutputIterator result, Predicate pred);
1314
1315template<class InputIterator, class Size, class OutputIterator>
1316 constexpr OutputIterator // constexpr in C++20
1317 copy_n(InputIterator first, Size n, OutputIterator result);
1318
1319template <class BidirectionalIterator1, class BidirectionalIterator2>
1320 constexpr BidirectionalIterator2 // constexpr in C++20
1321 copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last,
1322 BidirectionalIterator2 result);
1323
1324// [alg.move], move
1325template<class InputIterator, class OutputIterator>
1326 constexpr OutputIterator move(InputIterator first, InputIterator last,
1327 OutputIterator result);
1328
1329template<class BidirectionalIterator1, class BidirectionalIterator2>
1330 constexpr BidirectionalIterator2
1331 move_backward(BidirectionalIterator1 first, BidirectionalIterator1 last,
1332 BidirectionalIterator2 result);
1333
1334template <class ForwardIterator1, class ForwardIterator2>
1335 constexpr ForwardIterator2 // constexpr in C++20
1336 swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2);
1337
1338namespace ranges {
1339 template<class I1, class I2>
1340 using swap_ranges_result = in_in_result<I1, I2>;
1341
1342template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2>
1343 requires indirectly_swappable<I1, I2>
1344 constexpr ranges::swap_ranges_result<I1, I2>
1345 swap_ranges(I1 first1, S1 last1, I2 first2, S2 last2);
1346
1347template<input_range R1, input_range R2>
1348 requires indirectly_swappable<iterator_t<R1>, iterator_t<R2>>
1349 constexpr ranges::swap_ranges_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>>
1350 swap_ranges(R1&& r1, R2&& r2);
1351}
1352
1353template <class ForwardIterator1, class ForwardIterator2>
1354 constexpr void // constexpr in C++20
1355 iter_swap(ForwardIterator1 a, ForwardIterator2 b);
1356
1357template <class InputIterator, class OutputIterator, class UnaryOperation>
1358 constexpr OutputIterator // constexpr in C++20
1359 transform(InputIterator first, InputIterator last, OutputIterator result, UnaryOperation op);
1360
1361template <class InputIterator1, class InputIterator2, class OutputIterator, class BinaryOperation>
1362 constexpr OutputIterator // constexpr in C++20
1363 transform(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2,
1364 OutputIterator result, BinaryOperation binary_op);
1365
1366template <class ForwardIterator, class T>
1367 constexpr void // constexpr in C++20
1368 replace(ForwardIterator first, ForwardIterator last, const T& old_value, const T& new_value);
1369
1370template <class ForwardIterator, class Predicate, class T>
1371 constexpr void // constexpr in C++20
1372 replace_if(ForwardIterator first, ForwardIterator last, Predicate pred, const T& new_value);
1373
1374template <class InputIterator, class OutputIterator, class T>
1375 constexpr OutputIterator // constexpr in C++20
1376 replace_copy(InputIterator first, InputIterator last, OutputIterator result,
1377 const T& old_value, const T& new_value);
1378
1379template <class InputIterator, class OutputIterator, class Predicate, class T>
1380 constexpr OutputIterator // constexpr in C++20
1381 replace_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred, const T& new_value);
1382
1383template <class ForwardIterator, class T>
1384 constexpr void // constexpr in C++20
1385 fill(ForwardIterator first, ForwardIterator last, const T& value);
1386
1387template <class OutputIterator, class Size, class T>
1388 constexpr OutputIterator // constexpr in C++20
1389 fill_n(OutputIterator first, Size n, const T& value);
1390
1391template <class ForwardIterator, class Generator>
1392 constexpr void // constexpr in C++20
1393 generate(ForwardIterator first, ForwardIterator last, Generator gen);
1394
1395template <class OutputIterator, class Size, class Generator>
1396 constexpr OutputIterator // constexpr in C++20
1397 generate_n(OutputIterator first, Size n, Generator gen);
1398
1399template <class ForwardIterator, class T>
1400 constexpr ForwardIterator // constexpr in C++20
1401 remove(ForwardIterator first, ForwardIterator last, const T& value);
1402
1403template <class ForwardIterator, class Predicate>
1404 constexpr ForwardIterator // constexpr in C++20
1405 remove_if(ForwardIterator first, ForwardIterator last, Predicate pred);
1406
1407template <class InputIterator, class OutputIterator, class T>
1408 constexpr OutputIterator // constexpr in C++20
1409 remove_copy(InputIterator first, InputIterator last, OutputIterator result, const T& value);
1410
1411template <class InputIterator, class OutputIterator, class Predicate>
1412 constexpr OutputIterator // constexpr in C++20
1413 remove_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred);
1414
1415template <class ForwardIterator>
1416 constexpr ForwardIterator // constexpr in C++20
1417 unique(ForwardIterator first, ForwardIterator last);
1418
1419template <class ForwardIterator, class BinaryPredicate>
1420 constexpr ForwardIterator // constexpr in C++20
1421 unique(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
1422
1423template <class InputIterator, class OutputIterator>
1424 constexpr OutputIterator // constexpr in C++20
1425 unique_copy(InputIterator first, InputIterator last, OutputIterator result);
1426
1427template <class InputIterator, class OutputIterator, class BinaryPredicate>
1428 constexpr OutputIterator // constexpr in C++20
1429 unique_copy(InputIterator first, InputIterator last, OutputIterator result, BinaryPredicate pred);
1430
1431template <class BidirectionalIterator>
1432 constexpr void // constexpr in C++20
1433 reverse(BidirectionalIterator first, BidirectionalIterator last);
1434
1435template <class BidirectionalIterator, class OutputIterator>
1436 constexpr OutputIterator // constexpr in C++20
1437 reverse_copy(BidirectionalIterator first, BidirectionalIterator last, OutputIterator result);
1438
1439template <class ForwardIterator>
1440 constexpr ForwardIterator // constexpr in C++20
1441 rotate(ForwardIterator first, ForwardIterator middle, ForwardIterator last);
1442
1443template <class ForwardIterator, class OutputIterator>
1444 constexpr OutputIterator // constexpr in C++20
1445 rotate_copy(ForwardIterator first, ForwardIterator middle, ForwardIterator last, OutputIterator result);
1446
1447template <class RandomAccessIterator>
1448 void
1449 random_shuffle(RandomAccessIterator first, RandomAccessIterator last); // deprecated in C++14, removed in C++17
1450
1451template <class RandomAccessIterator, class RandomNumberGenerator>
1452 void
1453 random_shuffle(RandomAccessIterator first, RandomAccessIterator last,
1454 RandomNumberGenerator& rand); // deprecated in C++14, removed in C++17
1455
1456template<class PopulationIterator, class SampleIterator,
1457 class Distance, class UniformRandomBitGenerator>
1458 SampleIterator sample(PopulationIterator first, PopulationIterator last,
1459 SampleIterator out, Distance n,
1460 UniformRandomBitGenerator&& g); // C++17
1461
1462template<class RandomAccessIterator, class UniformRandomNumberGenerator>
1463 void shuffle(RandomAccessIterator first, RandomAccessIterator last,
1464 UniformRandomNumberGenerator&& g);
1465
1466template<class ForwardIterator>
1467 constexpr ForwardIterator
1468 shift_left(ForwardIterator first, ForwardIterator last,
1469 typename iterator_traits<ForwardIterator>::difference_type n); // C++20
1470
1471template<class ForwardIterator>
1472 constexpr ForwardIterator
1473 shift_right(ForwardIterator first, ForwardIterator last,
1474 typename iterator_traits<ForwardIterator>::difference_type n); // C++20
1475
1476template <class InputIterator, class Predicate>
1477 constexpr bool // constexpr in C++20
1478 is_partitioned(InputIterator first, InputIterator last, Predicate pred);
1479
1480template <class ForwardIterator, class Predicate>
1481 constexpr ForwardIterator // constexpr in C++20
1482 partition(ForwardIterator first, ForwardIterator last, Predicate pred);
1483
1484template <class InputIterator, class OutputIterator1,
1485 class OutputIterator2, class Predicate>
1486 constexpr pair<OutputIterator1, OutputIterator2> // constexpr in C++20
1487 partition_copy(InputIterator first, InputIterator last,
1488 OutputIterator1 out_true, OutputIterator2 out_false,
1489 Predicate pred);
1490
1491template <class ForwardIterator, class Predicate>
1492 ForwardIterator
1493 stable_partition(ForwardIterator first, ForwardIterator last, Predicate pred);
1494
1495template<class ForwardIterator, class Predicate>
1496 constexpr ForwardIterator // constexpr in C++20
1497 partition_point(ForwardIterator first, ForwardIterator last, Predicate pred);
1498
1499template <class ForwardIterator>
1500 constexpr bool // constexpr in C++20
1501 is_sorted(ForwardIterator first, ForwardIterator last);
1502
1503template <class ForwardIterator, class Compare>
1504 constexpr bool // constexpr in C++20
1505 is_sorted(ForwardIterator first, ForwardIterator last, Compare comp);
1506
1507template<class ForwardIterator>
1508 constexpr ForwardIterator // constexpr in C++20
1509 is_sorted_until(ForwardIterator first, ForwardIterator last);
1510
1511template <class ForwardIterator, class Compare>
1512 constexpr ForwardIterator // constexpr in C++20
1513 is_sorted_until(ForwardIterator first, ForwardIterator last, Compare comp);
1514
1515template <class RandomAccessIterator>
1516 constexpr void // constexpr in C++20
1517 sort(RandomAccessIterator first, RandomAccessIterator last);
1518
1519template <class RandomAccessIterator, class Compare>
1520 constexpr void // constexpr in C++20
1521 sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
1522
1523template <class RandomAccessIterator>
1524 void
1525 stable_sort(RandomAccessIterator first, RandomAccessIterator last);
1526
1527template <class RandomAccessIterator, class Compare>
1528 void
1529 stable_sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
1530
1531template <class RandomAccessIterator>
1532 constexpr void // constexpr in C++20
1533 partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last);
1534
1535template <class RandomAccessIterator, class Compare>
1536 constexpr void // constexpr in C++20
1537 partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last, Compare comp);
1538
1539template <class InputIterator, class RandomAccessIterator>
1540 constexpr RandomAccessIterator // constexpr in C++20
1541 partial_sort_copy(InputIterator first, InputIterator last,
1542 RandomAccessIterator result_first, RandomAccessIterator result_last);
1543
1544template <class InputIterator, class RandomAccessIterator, class Compare>
1545 constexpr RandomAccessIterator // constexpr in C++20
1546 partial_sort_copy(InputIterator first, InputIterator last,
1547 RandomAccessIterator result_first, RandomAccessIterator result_last, Compare comp);
1548
1549template <class RandomAccessIterator>
1550 constexpr void // constexpr in C++20
1551 nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last);
1552
1553template <class RandomAccessIterator, class Compare>
1554 constexpr void // constexpr in C++20
1555 nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last, Compare comp);
1556
1557template <class ForwardIterator, class T>
1558 constexpr ForwardIterator // constexpr in C++20
1559 lower_bound(ForwardIterator first, ForwardIterator last, const T& value);
1560
1561template <class ForwardIterator, class T, class Compare>
1562 constexpr ForwardIterator // constexpr in C++20
1563 lower_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
1564
1565template <class ForwardIterator, class T>
1566 constexpr ForwardIterator // constexpr in C++20
1567 upper_bound(ForwardIterator first, ForwardIterator last, const T& value);
1568
1569template <class ForwardIterator, class T, class Compare>
1570 constexpr ForwardIterator // constexpr in C++20
1571 upper_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
1572
1573template <class ForwardIterator, class T>
1574 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++20
1575 equal_range(ForwardIterator first, ForwardIterator last, const T& value);
1576
1577template <class ForwardIterator, class T, class Compare>
1578 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++20
1579 equal_range(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
1580
1581template <class ForwardIterator, class T>
1582 constexpr bool // constexpr in C++20
1583 binary_search(ForwardIterator first, ForwardIterator last, const T& value);
1584
1585template <class ForwardIterator, class T, class Compare>
1586 constexpr bool // constexpr in C++20
1587 binary_search(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
1588
1589template <class InputIterator1, class InputIterator2, class OutputIterator>
1590 constexpr OutputIterator // constexpr in C++20
1591 merge(InputIterator1 first1, InputIterator1 last1,
1592 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
1593
1594template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
1595 constexpr OutputIterator // constexpr in C++20
1596 merge(InputIterator1 first1, InputIterator1 last1,
1597 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
1598
1599template <class BidirectionalIterator>
1600 void
1601 inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last);
1602
1603template <class BidirectionalIterator, class Compare>
1604 void
1605 inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last, Compare comp);
1606
1607template <class InputIterator1, class InputIterator2>
1608 constexpr bool // constexpr in C++20
1609 includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
1610
1611template <class InputIterator1, class InputIterator2, class Compare>
1612 constexpr bool // constexpr in C++20
1613 includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, Compare comp);
1614
1615template <class InputIterator1, class InputIterator2, class OutputIterator>
1616 constexpr OutputIterator // constexpr in C++20
1617 set_union(InputIterator1 first1, InputIterator1 last1,
1618 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
1619
1620template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
1621 constexpr OutputIterator // constexpr in C++20
1622 set_union(InputIterator1 first1, InputIterator1 last1,
1623 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
1624
1625template <class InputIterator1, class InputIterator2, class OutputIterator>
1626 constexpr OutputIterator // constexpr in C++20
1627 set_intersection(InputIterator1 first1, InputIterator1 last1,
1628 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
1629
1630template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
1631 constexpr OutputIterator // constexpr in C++20
1632 set_intersection(InputIterator1 first1, InputIterator1 last1,
1633 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
1634
1635template <class InputIterator1, class InputIterator2, class OutputIterator>
1636 constexpr OutputIterator // constexpr in C++20
1637 set_difference(InputIterator1 first1, InputIterator1 last1,
1638 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
1639
1640template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
1641 constexpr OutputIterator // constexpr in C++20
1642 set_difference(InputIterator1 first1, InputIterator1 last1,
1643 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
1644
1645template <class InputIterator1, class InputIterator2, class OutputIterator>
1646 constexpr OutputIterator // constexpr in C++20
1647 set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
1648 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
1649
1650template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
1651 constexpr OutputIterator // constexpr in C++20
1652 set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
1653 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
1654
1655template <class RandomAccessIterator>
1656 constexpr void // constexpr in C++20
1657 push_heap(RandomAccessIterator first, RandomAccessIterator last);
1658
1659template <class RandomAccessIterator, class Compare>
1660 constexpr void // constexpr in C++20
1661 push_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
1662
1663template <class RandomAccessIterator>
1664 constexpr void // constexpr in C++20
1665 pop_heap(RandomAccessIterator first, RandomAccessIterator last);
1666
1667template <class RandomAccessIterator, class Compare>
1668 constexpr void // constexpr in C++20
1669 pop_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
1670
1671template <class RandomAccessIterator>
1672 constexpr void // constexpr in C++20
1673 make_heap(RandomAccessIterator first, RandomAccessIterator last);
1674
1675template <class RandomAccessIterator, class Compare>
1676 constexpr void // constexpr in C++20
1677 make_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
1678
1679template <class RandomAccessIterator>
1680 constexpr void // constexpr in C++20
1681 sort_heap(RandomAccessIterator first, RandomAccessIterator last);
1682
1683template <class RandomAccessIterator, class Compare>
1684 constexpr void // constexpr in C++20
1685 sort_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
1686
1687template <class RandomAccessIterator>
1688 constexpr bool // constexpr in C++20
1689 is_heap(RandomAccessIterator first, RandomAccessiterator last);
1690
1691template <class RandomAccessIterator, class Compare>
1692 constexpr bool // constexpr in C++20
1693 is_heap(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
1694
1695template <class RandomAccessIterator>
1696 constexpr RandomAccessIterator // constexpr in C++20
1697 is_heap_until(RandomAccessIterator first, RandomAccessiterator last);
1698
1699template <class RandomAccessIterator, class Compare>
1700 constexpr RandomAccessIterator // constexpr in C++20
1701 is_heap_until(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
1702
1703template <class ForwardIterator>
1704 constexpr ForwardIterator // constexpr in C++14
1705 min_element(ForwardIterator first, ForwardIterator last);
1706
1707template <class ForwardIterator, class Compare>
1708 constexpr ForwardIterator // constexpr in C++14
1709 min_element(ForwardIterator first, ForwardIterator last, Compare comp);
1710
1711template <class T>
1712 constexpr const T& // constexpr in C++14
1713 min(const T& a, const T& b);
1714
1715template <class T, class Compare>
1716 constexpr const T& // constexpr in C++14
1717 min(const T& a, const T& b, Compare comp);
1718
1719template<class T>
1720 constexpr T // constexpr in C++14
1721 min(initializer_list<T> t);
1722
1723template<class T, class Compare>
1724 constexpr T // constexpr in C++14
1725 min(initializer_list<T> t, Compare comp);
1726
1727template<class T>
1728 constexpr const T& clamp(const T& v, const T& lo, const T& hi); // C++17
1729
1730template<class T, class Compare>
1731 constexpr const T& clamp(const T& v, const T& lo, const T& hi, Compare comp); // C++17
1732
1733template <class ForwardIterator>
1734 constexpr ForwardIterator // constexpr in C++14
1735 max_element(ForwardIterator first, ForwardIterator last);
1736
1737template <class ForwardIterator, class Compare>
1738 constexpr ForwardIterator // constexpr in C++14
1739 max_element(ForwardIterator first, ForwardIterator last, Compare comp);
1740
1741template <class T>
1742 constexpr const T& // constexpr in C++14
1743 max(const T& a, const T& b);
1744
1745template <class T, class Compare>
1746 constexpr const T& // constexpr in C++14
1747 max(const T& a, const T& b, Compare comp);
1748
1749template<class T>
1750 constexpr T // constexpr in C++14
1751 max(initializer_list<T> t);
1752
1753template<class T, class Compare>
1754 constexpr T // constexpr in C++14
1755 max(initializer_list<T> t, Compare comp);
1756
1757template<class ForwardIterator>
1758 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++14
1759 minmax_element(ForwardIterator first, ForwardIterator last);
1760
1761template<class ForwardIterator, class Compare>
1762 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++14
1763 minmax_element(ForwardIterator first, ForwardIterator last, Compare comp);
1764
1765template<class T>
1766 constexpr pair<const T&, const T&> // constexpr in C++14
1767 minmax(const T& a, const T& b);
1768
1769template<class T, class Compare>
1770 constexpr pair<const T&, const T&> // constexpr in C++14
1771 minmax(const T& a, const T& b, Compare comp);
1772
1773template<class T>
1774 constexpr pair<T, T> // constexpr in C++14
1775 minmax(initializer_list<T> t);
1776
1777template<class T, class Compare>
1778 constexpr pair<T, T> // constexpr in C++14
1779 minmax(initializer_list<T> t, Compare comp);
1780
1781template <class InputIterator1, class InputIterator2>
1782 constexpr bool // constexpr in C++20
1783 lexicographical_compare(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
1784
1785template <class InputIterator1, class InputIterator2, class Compare>
1786 constexpr bool // constexpr in C++20
1787 lexicographical_compare(InputIterator1 first1, InputIterator1 last1,
1788 InputIterator2 first2, InputIterator2 last2, Compare comp);
1789
1790template<class InputIterator1, class InputIterator2, class Cmp>
1791 constexpr auto
1792 lexicographical_compare_three_way(InputIterator1 first1, InputIterator1 last1,
1793 InputIterator2 first2, InputIterator2 last2,
1794 Cmp comp)
1795 -> decltype(comp(*b1, *b2)); // since C++20
1796
1797template<class InputIterator1, class InputIterator2>
1798 constexpr auto
1799 lexicographical_compare_three_way(InputIterator1 first1, InputIterator1 last1,
1800 InputIterator2 first2, InputIterator2 last2); // since C++20
1801
1802template <class BidirectionalIterator>
1803 constexpr bool // constexpr in C++20
1804 next_permutation(BidirectionalIterator first, BidirectionalIterator last);
1805
1806template <class BidirectionalIterator, class Compare>
1807 constexpr bool // constexpr in C++20
1808 next_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
1809
1810template <class BidirectionalIterator>
1811 constexpr bool // constexpr in C++20
1812 prev_permutation(BidirectionalIterator first, BidirectionalIterator last);
1813
1814template <class BidirectionalIterator, class Compare>
1815 constexpr bool // constexpr in C++20
1816 prev_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
1817} // std
1818
1819*/
1820
1821#include <__config>
1822
1823#include <__algorithm/adjacent_find.h>
1824#include <__algorithm/all_of.h>
1825#include <__algorithm/any_of.h>
1826#include <__algorithm/binary_search.h>
1827#include <__algorithm/copy.h>
1828#include <__algorithm/copy_backward.h>
1829#include <__algorithm/copy_if.h>
1830#include <__algorithm/copy_n.h>
1831#include <__algorithm/count.h>
1832#include <__algorithm/count_if.h>
1833#include <__algorithm/equal.h>
1834#include <__algorithm/equal_range.h>
1835#include <__algorithm/fill.h>
1836#include <__algorithm/fill_n.h>
1837#include <__algorithm/find.h>
1838#include <__algorithm/find_end.h>
1839#include <__algorithm/find_first_of.h>
1840#include <__algorithm/find_if.h>
1841#include <__algorithm/find_if_not.h>
1842#include <__algorithm/for_each.h>
1843#include <__algorithm/generate.h>
1844#include <__algorithm/generate_n.h>
1845#include <__algorithm/includes.h>
1846#include <__algorithm/inplace_merge.h>
1847#include <__algorithm/is_heap.h>
1848#include <__algorithm/is_heap_until.h>
1849#include <__algorithm/is_partitioned.h>
1850#include <__algorithm/is_permutation.h>
1851#include <__algorithm/is_sorted.h>
1852#include <__algorithm/is_sorted_until.h>
1853#include <__algorithm/iter_swap.h>
1854#include <__algorithm/lexicographical_compare.h>
1855#include <__algorithm/lower_bound.h>
1856#include <__algorithm/make_heap.h>
1857#include <__algorithm/max.h>
1858#include <__algorithm/max_element.h>
1859#include <__algorithm/merge.h>
1860#include <__algorithm/min.h>
1861#include <__algorithm/min_element.h>
1862#include <__algorithm/minmax.h>
1863#include <__algorithm/minmax_element.h>
1864#include <__algorithm/mismatch.h>
1865#include <__algorithm/move.h>
1866#include <__algorithm/move_backward.h>
1867#include <__algorithm/next_permutation.h>
1868#include <__algorithm/none_of.h>
1869#include <__algorithm/nth_element.h>
1870#include <__algorithm/partial_sort.h>
1871#include <__algorithm/partial_sort_copy.h>
1872#include <__algorithm/partition.h>
1873#include <__algorithm/partition_copy.h>
1874#include <__algorithm/partition_point.h>
1875#include <__algorithm/pop_heap.h>
1876#include <__algorithm/prev_permutation.h>
1877#include <__algorithm/push_heap.h>
1878#include <__algorithm/remove.h>
1879#include <__algorithm/remove_copy.h>
1880#include <__algorithm/remove_copy_if.h>
1881#include <__algorithm/remove_if.h>
1882#include <__algorithm/replace.h>
1883#include <__algorithm/replace_copy.h>
1884#include <__algorithm/replace_copy_if.h>
1885#include <__algorithm/replace_if.h>
1886#include <__algorithm/reverse.h>
1887#include <__algorithm/reverse_copy.h>
1888#include <__algorithm/rotate.h>
1889#include <__algorithm/rotate_copy.h>
1890#include <__algorithm/search.h>
1891#include <__algorithm/search_n.h>
1892#include <__algorithm/set_difference.h>
1893#include <__algorithm/set_intersection.h>
1894#include <__algorithm/set_symmetric_difference.h>
1895#include <__algorithm/set_union.h>
1896#include <__algorithm/shuffle.h>
1897#include <__algorithm/sort.h>
1898#include <__algorithm/sort_heap.h>
1899#include <__algorithm/stable_partition.h>
1900#include <__algorithm/stable_sort.h>
1901#include <__algorithm/swap_ranges.h>
1902#include <__algorithm/transform.h>
1903#include <__algorithm/unique.h>
1904#include <__algorithm/unique_copy.h>
1905#include <__algorithm/upper_bound.h>
1906
1907#if _LIBCPP_STD_VER >= 17
1908# include <__algorithm/clamp.h>
1909# include <__algorithm/for_each_n.h>
1910# include <__algorithm/pstl.h>
1911# include <__algorithm/sample.h>
1912#endif // _LIBCPP_STD_VER >= 17
1913
1914#if _LIBCPP_STD_VER >= 20
1915# include <__algorithm/in_found_result.h>
1916# include <__algorithm/in_fun_result.h>
1917# include <__algorithm/in_in_out_result.h>
1918# include <__algorithm/in_in_result.h>
1919# include <__algorithm/in_out_out_result.h>
1920# include <__algorithm/in_out_result.h>
1921# include <__algorithm/lexicographical_compare_three_way.h>
1922# include <__algorithm/min_max_result.h>
1923# include <__algorithm/ranges_adjacent_find.h>
1924# include <__algorithm/ranges_all_of.h>
1925# include <__algorithm/ranges_any_of.h>
1926# include <__algorithm/ranges_binary_search.h>
1927# include <__algorithm/ranges_clamp.h>
1928# include <__algorithm/ranges_contains.h>
1929# include <__algorithm/ranges_copy.h>
1930# include <__algorithm/ranges_copy_backward.h>
1931# include <__algorithm/ranges_copy_if.h>
1932# include <__algorithm/ranges_copy_n.h>
1933# include <__algorithm/ranges_count.h>
1934# include <__algorithm/ranges_count_if.h>
1935# include <__algorithm/ranges_equal.h>
1936# include <__algorithm/ranges_equal_range.h>
1937# include <__algorithm/ranges_fill.h>
1938# include <__algorithm/ranges_fill_n.h>
1939# include <__algorithm/ranges_find.h>
1940# include <__algorithm/ranges_find_end.h>
1941# include <__algorithm/ranges_find_first_of.h>
1942# include <__algorithm/ranges_find_if.h>
1943# include <__algorithm/ranges_find_if_not.h>
1944# include <__algorithm/ranges_for_each.h>
1945# include <__algorithm/ranges_for_each_n.h>
1946# include <__algorithm/ranges_generate.h>
1947# include <__algorithm/ranges_generate_n.h>
1948# include <__algorithm/ranges_includes.h>
1949# include <__algorithm/ranges_inplace_merge.h>
1950# include <__algorithm/ranges_is_heap.h>
1951# include <__algorithm/ranges_is_heap_until.h>
1952# include <__algorithm/ranges_is_partitioned.h>
1953# include <__algorithm/ranges_is_permutation.h>
1954# include <__algorithm/ranges_is_sorted.h>
1955# include <__algorithm/ranges_is_sorted_until.h>
1956# include <__algorithm/ranges_lexicographical_compare.h>
1957# include <__algorithm/ranges_lower_bound.h>
1958# include <__algorithm/ranges_make_heap.h>
1959# include <__algorithm/ranges_max.h>
1960# include <__algorithm/ranges_max_element.h>
1961# include <__algorithm/ranges_merge.h>
1962# include <__algorithm/ranges_min.h>
1963# include <__algorithm/ranges_min_element.h>
1964# include <__algorithm/ranges_minmax.h>
1965# include <__algorithm/ranges_minmax_element.h>
1966# include <__algorithm/ranges_mismatch.h>
1967# include <__algorithm/ranges_move.h>
1968# include <__algorithm/ranges_move_backward.h>
1969# include <__algorithm/ranges_next_permutation.h>
1970# include <__algorithm/ranges_none_of.h>
1971# include <__algorithm/ranges_nth_element.h>
1972# include <__algorithm/ranges_partial_sort.h>
1973# include <__algorithm/ranges_partial_sort_copy.h>
1974# include <__algorithm/ranges_partition.h>
1975# include <__algorithm/ranges_partition_copy.h>
1976# include <__algorithm/ranges_partition_point.h>
1977# include <__algorithm/ranges_pop_heap.h>
1978# include <__algorithm/ranges_prev_permutation.h>
1979# include <__algorithm/ranges_push_heap.h>
1980# include <__algorithm/ranges_remove.h>
1981# include <__algorithm/ranges_remove_copy.h>
1982# include <__algorithm/ranges_remove_copy_if.h>
1983# include <__algorithm/ranges_remove_if.h>
1984# include <__algorithm/ranges_replace.h>
1985# include <__algorithm/ranges_replace_copy.h>
1986# include <__algorithm/ranges_replace_copy_if.h>
1987# include <__algorithm/ranges_replace_if.h>
1988# include <__algorithm/ranges_reverse.h>
1989# include <__algorithm/ranges_reverse_copy.h>
1990# include <__algorithm/ranges_rotate.h>
1991# include <__algorithm/ranges_rotate_copy.h>
1992# include <__algorithm/ranges_sample.h>
1993# include <__algorithm/ranges_search.h>
1994# include <__algorithm/ranges_search_n.h>
1995# include <__algorithm/ranges_set_difference.h>
1996# include <__algorithm/ranges_set_intersection.h>
1997# include <__algorithm/ranges_set_symmetric_difference.h>
1998# include <__algorithm/ranges_set_union.h>
1999# include <__algorithm/ranges_shuffle.h>
2000# include <__algorithm/ranges_sort.h>
2001# include <__algorithm/ranges_sort_heap.h>
2002# include <__algorithm/ranges_stable_partition.h>
2003# include <__algorithm/ranges_stable_sort.h>
2004# include <__algorithm/ranges_swap_ranges.h>
2005# include <__algorithm/ranges_transform.h>
2006# include <__algorithm/ranges_unique.h>
2007# include <__algorithm/ranges_unique_copy.h>
2008# include <__algorithm/ranges_upper_bound.h>
2009# include <__algorithm/shift_left.h>
2010# include <__algorithm/shift_right.h>
2011#endif
2012
2013#if _LIBCPP_STD_VER >= 23
2014# include <__algorithm/fold.h>
2015# include <__algorithm/ranges_contains_subrange.h>
2016# include <__algorithm/ranges_ends_with.h>
2017# include <__algorithm/ranges_find_last.h>
2018# include <__algorithm/ranges_starts_with.h>
2019#endif // _LIBCPP_STD_VER >= 23
2020
2021#include <version>
2022
2023// standard-mandated includes
2024
2025// [algorithm.syn]
2026#include <initializer_list>
2027
2028#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2029# pragma GCC system_header
2030#endif
2031
2032#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER == 14
2033# include <execution>
2034#endif
2035
2036#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
2037# include <atomic>
2038# include <bit>
2039# include <concepts>
2040# include <cstdlib>
2041# include <cstring>
2042# include <iterator>
2043# include <memory>
2044# include <stdexcept>
2045# include <type_traits>
2046# include <utility>
2047#endif
2048
2049#endif // _LIBCPP_ALGORITHM
2050