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