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