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