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