blob: 80788ed3f96ad416756c8ae6958e3f0d67a99933 [file] [log] [blame]
Howard Hinnantc51e1022010-05-11 19:42:16 +00001// -*- C++ -*-
Louis Dionne9bd93882021-11-17 16:25:01 -05002//===----------------------------------------------------------------------===//
Howard Hinnantc51e1022010-05-11 19:42:16 +00003//
Chandler Carruthd2012102019-01-19 10:56:40 +00004// 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
Howard Hinnantc51e1022010-05-11 19:42:16 +00007//
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
Nikolas Klauserf74be4e2022-01-14 02:55:51 +010021namespace ranges {
Nikolas Klauser671b4752022-02-11 17:01:58 +010022 template <class I, class F>
Nikolas Klauser2e263162022-02-21 22:48:36 +010023 struct in_fun_result; // since C++20
Nikolas Klauser671b4752022-02-11 17:01:58 +010024
Nikolas Klauserf74be4e2022-01-14 02:55:51 +010025 template <class I1, class I2>
Nikolas Klauser2e263162022-02-21 22:48:36 +010026 struct in_in_result; // since C++20
Nikolas Klauser05e2cd82022-01-25 11:21:47 +010027
28 template <class I1, class I2, class O>
Nikolas Klauser2e263162022-02-21 22:48:36 +010029 struct in_in_out_result; // since C++20
Nikolas Klauser61ce8162022-02-03 02:17:03 +010030
31 template <class I, class O1, class O2>
32 struct in_out_out_result; // since C++20
Nikolas Klauser671b4752022-02-11 17:01:58 +010033
Nikolas Klauser2e263162022-02-21 22:48:36 +010034 template <class I1, class I2>
35 struct min_max_result; // since C++20
36
Nikolas Klauserdd5ad212022-02-21 23:07:02 +010037 template <class I>
38 struct in_found_result; // since C++20
39
Nikolas Klauser0a62a172022-02-11 13:11:57 +010040 template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
41 indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less> // since C++20
42 constexpr I min_element(I first, S last, Comp comp = {}, Proj proj = {});
43
44 template<forward_range R, class Proj = identity,
45 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less> // since C++20
46 constexpr borrowed_iterator_t<R> min_element(R&& r, Comp comp = {}, Proj proj = {});
Nikolas Klauser12fc9bf2022-03-08 23:12:35 +010047
Nikolas Klauser10c612d2022-05-22 13:43:37 +020048 template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
49 indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
50 constexpr I ranges::max_element(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
51
52 template<forward_range R, class Proj = identity,
53 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
54 constexpr borrowed_iterator_t<R> ranges::max_element(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
55
56
Nikolas Klauser12fc9bf2022-03-08 23:12:35 +010057 template <input_iterator I1, sentinel_for<_I1> S1, input_iterator I2, sentinel_for<_I2> S2,
58 class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
59 requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
60 constexpr mismatch_result<_I1, _I2>
61 mismatch()(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}) // since C++20
62
63 template <input_range R1, input_range R2,
64 class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
65 requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
66 constexpr mismatch_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>>
67 mismatch(R1&& r1, R2&& r2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}) // since C++20
Nikolas Klauser37d076e2022-03-12 01:45:35 +010068
Nikolas Klauser37d076e2022-03-12 01:45:35 +010069 requires indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
70 constexpr I find(I first, S last, const T& value, Proj proj = {}); // since C++20
71
72 template<input_range R, class T, class Proj = identity>
73 requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*>
74 constexpr borrowed_iterator_t<R>
75 find(R&& r, const T& value, Proj proj = {}); // since C++20
76
77 template<input_iterator I, sentinel_for<I> S, class Proj = identity,
78 indirect_unary_predicate<projected<I, Proj>> Pred>
79 constexpr I find_if(I first, S last, Pred pred, Proj proj = {}); // since C++20
80
81 template<input_range R, class Proj = identity,
82 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
83 constexpr borrowed_iterator_t<R>
84 find_if(R&& r, Pred pred, Proj proj = {}); // since C++20
85
86 template<input_iterator I, sentinel_for<I> S, class Proj = identity,
87 indirect_unary_predicate<projected<I, Proj>> Pred>
88 constexpr I find_if_not(I first, S last, Pred pred, Proj proj = {}); // since C++20
89
90 template<input_range R, class Proj = identity,
91 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
92 constexpr borrowed_iterator_t<R>
93 find_if_not(R&& r, Pred pred, Proj proj = {}); // since C++20
Nikolas Klauser3559e452022-03-18 02:57:08 +010094
Nikolas Klauser573cd6f2022-04-03 09:17:01 +020095 template<class T, class Proj = identity,
96 indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
97 constexpr const T& min(const T& a, const T& b, Comp comp = {}, Proj proj = {}); // since C++20
Nikolas Klauser3559e452022-03-18 02:57:08 +010098
Nikolas Klauser573cd6f2022-04-03 09:17:01 +020099 template<copyable T, class Proj = identity,
100 indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
101 constexpr T min(initializer_list<T> r, Comp comp = {}, Proj proj = {}); // since C++20
Nikolas Klauser3559e452022-03-18 02:57:08 +0100102
103 template<input_range R, class Proj = identity,
104 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
105 requires indirectly_copyable_storable<iterator_t<R>, range_value_t<R>*>
106 constexpr range_value_t<R>
107 min(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
Nikolas Klauser573cd6f2022-04-03 09:17:01 +0200108
109 template<class T, class Proj = identity,
110 indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
111 constexpr const T& max(const T& a, const T& b, Comp comp = {}, Proj proj = {}); // since C++20
112
113 template<copyable T, class Proj = identity,
114 indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
115 constexpr T max(initializer_list<T> r, Comp comp = {}, Proj proj = {}); // since C++20
116
117 template<input_range R, class Proj = identity,
118 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
119 requires indirectly_copyable_storable<iterator_t<R>, range_value_t<R>*>
120 constexpr range_value_t<R>
121 max(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
Nikolas Klauser559a1772022-04-05 11:05:36 +0200122
123 template<class I, class O>
124 using unary_transform_result = in_out_result<I, O>; // since C++20
125
126 template<class I1, class I2, class O>
127 using binary_transform_result = in_in_out_result<I1, I2, O>; // since C++20
128
129 template<input_iterator I, sentinel_for<I> S, weakly_incrementable O,
130 copy_constructible F, class Proj = identity>
131 requires indirectly_writable<O, indirect_result_t<F&, projected<I, Proj>>>
132 constexpr ranges::unary_transform_result<I, O>
133 transform(I first1, S last1, O result, F op, Proj proj = {}); // since C++20
134
135 template<input_range R, weakly_incrementable O, copy_constructible F,
136 class Proj = identity>
137 requires indirectly_writable<O, indirect_result_t<F&, projected<iterator_t<R>, Proj>>>
138 constexpr ranges::unary_transform_result<borrowed_iterator_t<R>, O>
139 transform(R&& r, O result, F op, Proj proj = {}); // since C++20
140
141 template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
142 weakly_incrementable O, copy_constructible F, class Proj1 = identity,
143 class Proj2 = identity>
144 requires indirectly_writable<O, indirect_result_t<F&, projected<I1, Proj1>,
145 projected<I2, Proj2>>>
146 constexpr ranges::binary_transform_result<I1, I2, O>
147 transform(I1 first1, S1 last1, I2 first2, S2 last2, O result,
148 F binary_op, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
149
150 template<input_range R1, input_range R2, weakly_incrementable O,
151 copy_constructible F, class Proj1 = identity, class Proj2 = identity>
152 requires indirectly_writable<O, indirect_result_t<F&, projected<iterator_t<R1>, Proj1>,
153 projected<iterator_t<R2>, Proj2>>>
154 constexpr ranges::binary_transform_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>, O>
155 transform(R1&& r1, R2&& r2, O result,
156 F binary_op, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
Nikolas Klauserf1373d02022-04-07 13:02:02 +0200157
158 template<input_iterator I, sentinel_for<I> S, class T, class Proj = identity>
159 requires indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
160 constexpr iter_difference_t<I>
161 count(I first, S last, const T& value, Proj proj = {}); // since C++20
162
163 template<input_range R, class T, class Proj = identity>
164 requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*>
165 constexpr range_difference_t<R>
166 count(R&& r, const T& value, Proj proj = {}); // since C++20
167
168 template<input_iterator I, sentinel_for<I> S, class Proj = identity,
169 indirect_unary_predicate<projected<I, Proj>> Pred>
170 constexpr iter_difference_t<I>
171 count_if(I first, S last, Pred pred, Proj proj = {}); // since C++20
172
173 template<input_range R, class Proj = identity,
174 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
175 constexpr range_difference_t<R>
176 count_if(R&& r, Pred pred, Proj proj = {}); // since C++20
Nikolas Klauser0a2f44f2022-04-13 22:59:09 +0200177
178 template<class T, class Proj = identity,
179 indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
180 constexpr ranges::minmax_result<const T&>
181 minmax(const T& a, const T& b, Comp comp = {}, Proj proj = {}); // since C++20
182
183 template<copyable T, class Proj = identity,
184 indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
185 constexpr ranges::minmax_result<T>
186 minmax(initializer_list<T> r, Comp comp = {}, Proj proj = {}); // since C++20
187
188 template<input_range R, class Proj = identity,
189 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
190 requires indirectly_copyable_storable<iterator_t<R>, range_value_t<R>*>
191 constexpr ranges::minmax_result<range_value_t<R>>
192 minmax(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
193
194 template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
195 indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
196 constexpr ranges::minmax_element_result<I>
197 minmax_element(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
198
199 template<forward_range R, class Proj = identity,
200 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
201 constexpr ranges::minmax_element_result<borrowed_iterator_t<R>>
202 minmax_element(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
Nikolas Klauserd959d842022-04-15 13:43:40 +0200203
204 template<class I, class O>
205 using copy_result = in_out_result<I, O>; // since C++20
206
207 template<class I, class O>
208 using copy_n_result = in_out_result<I, O>; // since C++20
209
210 template<class I, class O>
211 using copy_if_result = in_out_result<I, O>; // since C++20
212
213 template<class I1, class I2>
214 using copy_backward_result = in_out_result<I1, I2>; // since C++20
215
216 template<input_iterator I, sentinel_for<I> S, weakly_incrementable O>
217 requires indirectly_copyable<I, O>
218 constexpr ranges::copy_result<I, O> ranges::copy(I first, S last, O result); // since C++20
219
220 template<input_range R, weakly_incrementable O>
221 requires indirectly_copyable<iterator_t<R>, O>
222 constexpr ranges::copy_result<borrowed_iterator_t<R>, O> ranges::copy(R&& r, O result); // since C++20
223
224 template<input_iterator I, weakly_incrementable O>
225 requires indirectly_copyable<I, O>
226 constexpr ranges::copy_n_result<I, O>
227 ranges::copy_n(I first, iter_difference_t<I> n, O result); // since C++20
228
229 template<input_iterator I, sentinel_for<I> S, weakly_incrementable O, class Proj = identity,
230 indirect_unary_predicate<projected<I, Proj>> Pred>
231 requires indirectly_copyable<I, O>
232 constexpr ranges::copy_if_result<I, O>
233 ranges::copy_if(I first, S last, O result, Pred pred, Proj proj = {}); // since C++20
234
235 template<input_range R, weakly_incrementable O, class Proj = identity,
236 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
237 requires indirectly_copyable<iterator_t<R>, O>
238 constexpr ranges::copy_if_result<borrowed_iterator_t<R>, O>
239 ranges::copy_if(R&& r, O result, Pred pred, Proj proj = {}); // since C++20
240
241 template<bidirectional_iterator I1, sentinel_for<I1> S1, bidirectional_iterator I2>
242 requires indirectly_copyable<I1, I2>
243 constexpr ranges::copy_backward_result<I1, I2>
244 ranges::copy_backward(I1 first, S1 last, I2 result); // since C++20
245
246 template<bidirectional_range R, bidirectional_iterator I>
247 requires indirectly_copyable<iterator_t<R>, I>
248 constexpr ranges::copy_backward_result<borrowed_iterator_t<R>, I>
249 ranges::copy_backward(R&& r, I result); // since C++20
Nikolas Klauser58de98c2022-05-04 20:27:07 +0200250
251 template<class I, class F>
252 using for_each_result = in_fun_result<I, F>; // since C++20
253
254 template<input_iterator I, sentinel_for<I> S, class Proj = identity,
255 indirectly_unary_invocable<projected<I, Proj>> Fun>
256 constexpr ranges::for_each_result<I, Fun>
257 ranges::for_each(I first, S last, Fun f, Proj proj = {}); // since C++20
258
259 template<input_range R, class Proj = identity,
260 indirectly_unary_invocable<projected<iterator_t<R>, Proj>> Fun>
261 constexpr ranges::for_each_result<borrowed_iterator_t<R>, Fun>
262 ranges::for_each(R&& r, Fun f, Proj proj = {}); // since C++20
263
264 template<input_iterator I, class Proj = identity,
265 indirectly_unary_invocable<projected<I, Proj>> Fun>
266 constexpr ranges::for_each_n_result<I, Fun>
267 ranges::for_each_n(I first, iter_difference_t<I> n, Fun f, Proj proj = {}); // since C++20
Nikolas Klauserbb9049d2022-05-04 14:19:09 +0200268
269 template<input_iterator I, sentinel_for<I> S, class Proj = identity,
270 indirect_unary_predicate<projected<I, Proj>> Pred>
271 constexpr bool ranges::is_partitioned(I first, S last, Pred pred, Proj proj = {}); // since C++20
272
273 template<input_range R, class Proj = identity,
274 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
275 constexpr bool ranges::is_partitioned(R&& r, Pred pred, Proj proj = {}); // since C++20
276
Nikolas Klauser52f20072022-05-24 10:32:50 +0200277
278 template<bidirectional_iterator I, sentinel_for<I> S>
279 requires permutable<I>
280 constexpr I ranges::reverse(I first, S last); // since C++20
281
282 template<bidirectional_range R>
283 requires permutable<iterator_t<R>>
284 constexpr borrowed_iterator_t<R> ranges::reverse(R&& r); // since C++20
285
Nikolas Klausereb49c2a2022-05-21 18:26:29 +0200286 template<class T, output_iterator<const T&> O, sentinel_for<O> S>
287 constexpr O ranges::fill(O first, S last, const T& value); // since C++20
288
289 template<class T, output_range<const T&> R>
290 constexpr borrowed_iterator_t<R> ranges::fill(R&& r, const T& value); // since C++20
291
292 template<class T, output_iterator<const T&> O>
293 constexpr O ranges::fill_n(O first, iter_difference_t<O> n, const T& value); // since C++20
Nikolas Klauser353f1dd2022-05-25 11:09:43 +0200294
295 template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
296 class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
297 requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
298 constexpr bool ranges::equal(I1 first1, S1 last1, I2 first2, S2 last2,
299 Pred pred = {},
300 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
301
302 template<input_range R1, input_range R2, class Pred = ranges::equal_to,
303 class Proj1 = identity, class Proj2 = identity>
304 requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
305 constexpr bool ranges::equal(R1&& r1, R2&& r2, Pred pred = {},
306 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
307
Nikolas Klausered3f0e82022-05-26 16:42:46 +0200308 template<input_iterator I, sentinel_for<I> S, class Proj = identity,
309 indirect_unary_predicate<projected<I, Proj>> Pred>
310 constexpr bool ranges::all_of(I first, S last, Pred pred, Proj proj = {}); // since C++20
311
312 template<input_range R, class Proj = identity,
313 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
314 constexpr bool ranges::all_of(R&& r, Pred pred, Proj proj = {}); // since C++20
315
316 template<input_iterator I, sentinel_for<I> S, class Proj = identity,
317 indirect_unary_predicate<projected<I, Proj>> Pred>
318 constexpr bool ranges::any_of(I first, S last, Pred pred, Proj proj = {}); // since C++20
319
320 template<input_range R, class Proj = identity,
321 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
322 constexpr bool ranges::any_of(R&& r, Pred pred, Proj proj = {}); // since C++20
323
324 template<input_iterator I, sentinel_for<I> S, class Proj = identity,
325 indirect_unary_predicate<projected<I, Proj>> Pred>
326 constexpr bool ranges::none_of(I first, S last, Pred pred, Proj proj = {}); // since C++20
327
328 template<input_range R, class Proj = identity,
329 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
330 constexpr bool ranges::none_of(R&& r, Pred pred, Proj proj = {}); // since C++20
331
Nikolas Klauserab0b7af2022-05-26 16:08:55 +0200332 template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
333 indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
334 constexpr bool ranges::is_sorted(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
335
336 template<forward_range R, class Proj = identity,
337 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
338 constexpr bool ranges::is_sorted(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
339
340 template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
341 indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
342 constexpr I ranges::is_sorted_until(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
343
344 template<forward_range R, class Proj = identity,
345 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
346 constexpr borrowed_iterator_t<R>
347 ranges::is_sorted_until(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
Nikolas Klauser8b381972022-06-05 21:15:16 +0200348
349 template<forward_iterator I, sentinel_for<I> S, class T, class Proj = identity,
350 indirect_strict_weak_order<const T*, projected<I, Proj>> Comp = ranges::less>
351 constexpr I upper_bound(I first, S last, const T& value, Comp comp = {}, Proj proj = {}); // since C++20
352
353 template<forward_range R, class T, class Proj = identity,
354 indirect_strict_weak_order<const T*, projected<iterator_t<R>, Proj>> Comp =
355 ranges::less>
356 constexpr borrowed_iterator_t<R>
357 upper_bound(R&& r, const T& value, Comp comp = {}, Proj proj = {}); // since C++20
358
359 template<forward_iterator I, sentinel_for<I> S, class T, class Proj = identity,
360 indirect_strict_weak_order<const T*, projected<I, Proj>> Comp = ranges::less>
361 constexpr I lower_bound(I first, S last, const T& value, Comp comp = {},
362 Proj proj = {}); // since C++20
363 template<forward_range R, class T, class Proj = identity,
364 indirect_strict_weak_order<const T*, projected<iterator_t<R>, Proj>> Comp =
365 ranges::less>
366 constexpr borrowed_iterator_t<R>
367 lower_bound(R&& r, const T& value, Comp comp = {}, Proj proj = {}); // since C++20
368
369 template<forward_iterator I, sentinel_for<I> S, class T, class Proj = identity,
370 indirect_strict_weak_order<const T*, projected<I, Proj>> Comp = ranges::less>
371 constexpr bool binary_search(I first, S last, const T& value, Comp comp = {},
372 Proj proj = {}); // since C++20
Nikolas Klauser0a7e46d2022-06-06 13:57:34 +0200373
Nikolas Klauser8b381972022-06-05 21:15:16 +0200374 template<forward_range R, class T, class Proj = identity,
375 indirect_strict_weak_order<const T*, projected<iterator_t<R>, Proj>> Comp =
376 ranges::less>
377 constexpr bool binary_search(R&& r, const T& value, Comp comp = {},
378 Proj proj = {}); // since C++20
Nikolas Klauser0a7e46d2022-06-06 13:57:34 +0200379 template<input_iterator I1, sentinel_for<I1> S1, forward_iterator I2, sentinel_for<I2> S2,
380 class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
381 requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
382 constexpr I1 ranges::find_first_of(I1 first1, S1 last1, I2 first2, S2 last2,
383 Pred pred = {},
384 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
385
386 template<input_range R1, forward_range R2,
387 class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
388 requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
389 constexpr borrowed_iterator_t<R1>
390 ranges::find_first_of(R1&& r1, R2&& r2,
391 Pred pred = {},
392 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
Nikolas Klauser8b381972022-06-05 21:15:16 +0200393
Nikolas Klauserf74be4e2022-01-14 02:55:51 +0100394}
395
Marshall Clowd607fdb2018-01-15 17:20:36 +0000396 constexpr bool // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000397 all_of(InputIterator first, InputIterator last, Predicate pred);
398
399template <class InputIterator, class Predicate>
Marshall Clowd607fdb2018-01-15 17:20:36 +0000400 constexpr bool // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000401 any_of(InputIterator first, InputIterator last, Predicate pred);
402
403template <class InputIterator, class Predicate>
Marshall Clowd607fdb2018-01-15 17:20:36 +0000404 constexpr bool // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000405 none_of(InputIterator first, InputIterator last, Predicate pred);
406
407template <class InputIterator, class Function>
Marshall Clow5492c8a2018-01-22 20:44:33 +0000408 constexpr Function // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000409 for_each(InputIterator first, InputIterator last, Function f);
410
Marshall Clowde0169c2017-05-25 02:29:54 +0000411template<class InputIterator, class Size, class Function>
Marshall Clow5492c8a2018-01-22 20:44:33 +0000412 constexpr InputIterator // constexpr in C++20
413 for_each_n(InputIterator first, Size n, Function f); // C++17
Marshall Clowde0169c2017-05-25 02:29:54 +0000414
Howard Hinnantc51e1022010-05-11 19:42:16 +0000415template <class InputIterator, class T>
Marshall Clowee0161e2018-01-15 19:26:05 +0000416 constexpr InputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000417 find(InputIterator first, InputIterator last, const T& value);
418
419template <class InputIterator, class Predicate>
Marshall Clowee0161e2018-01-15 19:26:05 +0000420 constexpr InputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000421 find_if(InputIterator first, InputIterator last, Predicate pred);
422
423template<class InputIterator, class Predicate>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500424 constexpr InputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000425 find_if_not(InputIterator first, InputIterator last, Predicate pred);
426
427template <class ForwardIterator1, class ForwardIterator2>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500428 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000429 find_end(ForwardIterator1 first1, ForwardIterator1 last1,
430 ForwardIterator2 first2, ForwardIterator2 last2);
431
432template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500433 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000434 find_end(ForwardIterator1 first1, ForwardIterator1 last1,
435 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
436
437template <class ForwardIterator1, class ForwardIterator2>
Marshall Clowee0161e2018-01-15 19:26:05 +0000438 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000439 find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
440 ForwardIterator2 first2, ForwardIterator2 last2);
441
442template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clowee0161e2018-01-15 19:26:05 +0000443 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000444 find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
445 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
446
447template <class ForwardIterator>
Marshall Clowee0161e2018-01-15 19:26:05 +0000448 constexpr ForwardIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000449 adjacent_find(ForwardIterator first, ForwardIterator last);
450
451template <class ForwardIterator, class BinaryPredicate>
Marshall Clowee0161e2018-01-15 19:26:05 +0000452 constexpr ForwardIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000453 adjacent_find(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
454
455template <class InputIterator, class T>
Marshall Clow3c0558f2018-01-15 19:40:34 +0000456 constexpr typename iterator_traits<InputIterator>::difference_type // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000457 count(InputIterator first, InputIterator last, const T& value);
458
459template <class InputIterator, class Predicate>
Marshall Clow3c0558f2018-01-15 19:40:34 +0000460 constexpr typename iterator_traits<InputIterator>::difference_type // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000461 count_if(InputIterator first, InputIterator last, Predicate pred);
462
463template <class InputIterator1, class InputIterator2>
Marshall Clow30bf3022018-01-16 02:04:10 +0000464 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000465 mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
466
Marshall Clow96b42b22013-05-09 21:14:23 +0000467template <class InputIterator1, class InputIterator2>
Marshall Clow30bf3022018-01-16 02:04:10 +0000468 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Aditya Kumar3a0179a2016-08-25 11:52:38 +0000469 mismatch(InputIterator1 first1, InputIterator1 last1,
Marshall Clow96b42b22013-05-09 21:14:23 +0000470 InputIterator2 first2, InputIterator2 last2); // **C++14**
471
Howard Hinnantc51e1022010-05-11 19:42:16 +0000472template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow30bf3022018-01-16 02:04:10 +0000473 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000474 mismatch(InputIterator1 first1, InputIterator1 last1,
475 InputIterator2 first2, BinaryPredicate pred);
476
Marshall Clow96b42b22013-05-09 21:14:23 +0000477template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow30bf3022018-01-16 02:04:10 +0000478 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Marshall Clow96b42b22013-05-09 21:14:23 +0000479 mismatch(InputIterator1 first1, InputIterator1 last1,
480 InputIterator2 first2, InputIterator2 last2,
481 BinaryPredicate pred); // **C++14**
482
Howard Hinnantc51e1022010-05-11 19:42:16 +0000483template <class InputIterator1, class InputIterator2>
Marshall Clow30bf3022018-01-16 02:04:10 +0000484 constexpr bool // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000485 equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
486
Marshall Clow96b42b22013-05-09 21:14:23 +0000487template <class InputIterator1, class InputIterator2>
Marshall Clow30bf3022018-01-16 02:04:10 +0000488 constexpr bool // constexpr in C++20
Aditya Kumar3a0179a2016-08-25 11:52:38 +0000489 equal(InputIterator1 first1, InputIterator1 last1,
Marshall Clow96b42b22013-05-09 21:14:23 +0000490 InputIterator2 first2, InputIterator2 last2); // **C++14**
491
Howard Hinnantc51e1022010-05-11 19:42:16 +0000492template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow30bf3022018-01-16 02:04:10 +0000493 constexpr bool // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000494 equal(InputIterator1 first1, InputIterator1 last1,
495 InputIterator2 first2, BinaryPredicate pred);
496
Marshall Clow96b42b22013-05-09 21:14:23 +0000497template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow30bf3022018-01-16 02:04:10 +0000498 constexpr bool // constexpr in C++20
Marshall Clow96b42b22013-05-09 21:14:23 +0000499 equal(InputIterator1 first1, InputIterator1 last1,
500 InputIterator2 first2, InputIterator2 last2,
501 BinaryPredicate pred); // **C++14**
502
Howard Hinnantc51e1022010-05-11 19:42:16 +0000503template<class ForwardIterator1, class ForwardIterator2>
Marshall Clow96d050a2018-01-15 16:16:32 +0000504 constexpr bool // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000505 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
506 ForwardIterator2 first2);
507
Marshall Clow96b42b22013-05-09 21:14:23 +0000508template<class ForwardIterator1, class ForwardIterator2>
Marshall Clow96d050a2018-01-15 16:16:32 +0000509 constexpr bool // constexpr in C++20
Marshall Clow96b42b22013-05-09 21:14:23 +0000510 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
511 ForwardIterator2 first2, ForwardIterator2 last2); // **C++14**
512
Howard Hinnantc51e1022010-05-11 19:42:16 +0000513template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow96d050a2018-01-15 16:16:32 +0000514 constexpr bool // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000515 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
516 ForwardIterator2 first2, BinaryPredicate pred);
517
Marshall Clow96b42b22013-05-09 21:14:23 +0000518template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow96d050a2018-01-15 16:16:32 +0000519 constexpr bool // constexpr in C++20
Marshall Clow96b42b22013-05-09 21:14:23 +0000520 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
521 ForwardIterator2 first2, ForwardIterator2 last2,
522 BinaryPredicate pred); // **C++14**
523
Howard Hinnantc51e1022010-05-11 19:42:16 +0000524template <class ForwardIterator1, class ForwardIterator2>
Marshall Clow323fc5b2018-01-16 15:48:27 +0000525 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000526 search(ForwardIterator1 first1, ForwardIterator1 last1,
527 ForwardIterator2 first2, ForwardIterator2 last2);
528
529template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow323fc5b2018-01-16 15:48:27 +0000530 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000531 search(ForwardIterator1 first1, ForwardIterator1 last1,
532 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
533
534template <class ForwardIterator, class Size, class T>
Marshall Clow323fc5b2018-01-16 15:48:27 +0000535 constexpr ForwardIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000536 search_n(ForwardIterator first, ForwardIterator last, Size count, const T& value);
537
538template <class ForwardIterator, class Size, class T, class BinaryPredicate>
Marshall Clow323fc5b2018-01-16 15:48:27 +0000539 constexpr ForwardIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000540 search_n(ForwardIterator first, ForwardIterator last,
541 Size count, const T& value, BinaryPredicate pred);
542
543template <class InputIterator, class OutputIterator>
Louis Dionne65b433b2019-11-06 12:02:41 +0000544 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000545 copy(InputIterator first, InputIterator last, OutputIterator result);
546
547template<class InputIterator, class OutputIterator, class Predicate>
Louis Dionne65b433b2019-11-06 12:02:41 +0000548 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000549 copy_if(InputIterator first, InputIterator last,
550 OutputIterator result, Predicate pred);
551
552template<class InputIterator, class Size, class OutputIterator>
Louis Dionne65b433b2019-11-06 12:02:41 +0000553 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000554 copy_n(InputIterator first, Size n, OutputIterator result);
555
556template <class BidirectionalIterator1, class BidirectionalIterator2>
Louis Dionne65b433b2019-11-06 12:02:41 +0000557 constexpr BidirectionalIterator2 // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000558 copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last,
559 BidirectionalIterator2 result);
560
561template <class ForwardIterator1, class ForwardIterator2>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500562 constexpr ForwardIterator2 // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000563 swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2);
564
Nikolas Klauser4ceab5f2022-02-10 13:33:03 +0100565template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2>
566 requires indirectly_swappable<I1, I2>
567 constexpr ranges::swap_ranges_result<I1, I2>
568 ranges::swap_ranges(I1 first1, S1 last1, I2 first2, S2 last2);
569
570template<input_range R1, input_range R2>
571 requires indirectly_swappable<iterator_t<R1>, iterator_t<R2>>
572 constexpr ranges::swap_ranges_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>>
573 ranges::swap_ranges(R1&& r1, R2&& r2);
574
Howard Hinnantc51e1022010-05-11 19:42:16 +0000575template <class ForwardIterator1, class ForwardIterator2>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500576 constexpr void // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000577 iter_swap(ForwardIterator1 a, ForwardIterator2 b);
578
579template <class InputIterator, class OutputIterator, class UnaryOperation>
Marshall Clow31427c62018-01-19 17:45:39 +0000580 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000581 transform(InputIterator first, InputIterator last, OutputIterator result, UnaryOperation op);
582
583template <class InputIterator1, class InputIterator2, class OutputIterator, class BinaryOperation>
Marshall Clow31427c62018-01-19 17:45:39 +0000584 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000585 transform(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2,
586 OutputIterator result, BinaryOperation binary_op);
587
588template <class ForwardIterator, class T>
Marshall Clow01bbbd22018-01-19 18:07:29 +0000589 constexpr void // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000590 replace(ForwardIterator first, ForwardIterator last, const T& old_value, const T& new_value);
591
592template <class ForwardIterator, class Predicate, class T>
Marshall Clow01bbbd22018-01-19 18:07:29 +0000593 constexpr void // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000594 replace_if(ForwardIterator first, ForwardIterator last, Predicate pred, const T& new_value);
595
596template <class InputIterator, class OutputIterator, class T>
Marshall Clow01bbbd22018-01-19 18:07:29 +0000597 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000598 replace_copy(InputIterator first, InputIterator last, OutputIterator result,
599 const T& old_value, const T& new_value);
600
601template <class InputIterator, class OutputIterator, class Predicate, class T>
Marshall Clow01bbbd22018-01-19 18:07:29 +0000602 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000603 replace_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred, const T& new_value);
604
605template <class ForwardIterator, class T>
Marshall Clowe9cdc5c2018-01-20 20:14:32 +0000606 constexpr void // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000607 fill(ForwardIterator first, ForwardIterator last, const T& value);
608
609template <class OutputIterator, class Size, class T>
Marshall Clowe9cdc5c2018-01-20 20:14:32 +0000610 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000611 fill_n(OutputIterator first, Size n, const T& value);
612
613template <class ForwardIterator, class Generator>
Marshall Clowe9cdc5c2018-01-20 20:14:32 +0000614 constexpr void // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000615 generate(ForwardIterator first, ForwardIterator last, Generator gen);
616
617template <class OutputIterator, class Size, class Generator>
Marshall Clowe9cdc5c2018-01-20 20:14:32 +0000618 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000619 generate_n(OutputIterator first, Size n, Generator gen);
620
621template <class ForwardIterator, class T>
Marshall Clow7c0fbd82018-01-22 21:43:04 +0000622 constexpr ForwardIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000623 remove(ForwardIterator first, ForwardIterator last, const T& value);
624
625template <class ForwardIterator, class Predicate>
Marshall Clow7c0fbd82018-01-22 21:43:04 +0000626 constexpr ForwardIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000627 remove_if(ForwardIterator first, ForwardIterator last, Predicate pred);
628
629template <class InputIterator, class OutputIterator, class T>
Marshall Clow7c0fbd82018-01-22 21:43:04 +0000630 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000631 remove_copy(InputIterator first, InputIterator last, OutputIterator result, const T& value);
632
633template <class InputIterator, class OutputIterator, class Predicate>
Marshall Clow7c0fbd82018-01-22 21:43:04 +0000634 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000635 remove_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred);
636
637template <class ForwardIterator>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500638 constexpr ForwardIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000639 unique(ForwardIterator first, ForwardIterator last);
640
641template <class ForwardIterator, class BinaryPredicate>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500642 constexpr ForwardIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000643 unique(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
644
645template <class InputIterator, class OutputIterator>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500646 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000647 unique_copy(InputIterator first, InputIterator last, OutputIterator result);
648
649template <class InputIterator, class OutputIterator, class BinaryPredicate>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500650 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000651 unique_copy(InputIterator first, InputIterator last, OutputIterator result, BinaryPredicate pred);
652
653template <class BidirectionalIterator>
Arthur O'Dwyere50e7472020-12-17 00:01:08 -0500654 constexpr void // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000655 reverse(BidirectionalIterator first, BidirectionalIterator last);
656
657template <class BidirectionalIterator, class OutputIterator>
Marshall Clow7c0fbd82018-01-22 21:43:04 +0000658 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000659 reverse_copy(BidirectionalIterator first, BidirectionalIterator last, OutputIterator result);
660
661template <class ForwardIterator>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500662 constexpr ForwardIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000663 rotate(ForwardIterator first, ForwardIterator middle, ForwardIterator last);
664
665template <class ForwardIterator, class OutputIterator>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500666 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000667 rotate_copy(ForwardIterator first, ForwardIterator middle, ForwardIterator last, OutputIterator result);
668
669template <class RandomAccessIterator>
670 void
Marshall Clowfac06e52017-03-23 13:43:37 +0000671 random_shuffle(RandomAccessIterator first, RandomAccessIterator last); // deprecated in C++14, removed in C++17
Howard Hinnantc51e1022010-05-11 19:42:16 +0000672
673template <class RandomAccessIterator, class RandomNumberGenerator>
674 void
Marshall Clow83f35392014-03-03 06:14:19 +0000675 random_shuffle(RandomAccessIterator first, RandomAccessIterator last,
Marshall Clowfac06e52017-03-23 13:43:37 +0000676 RandomNumberGenerator& rand); // deprecated in C++14, removed in C++17
Howard Hinnantc51e1022010-05-11 19:42:16 +0000677
Eric Fiselier1208fcd2016-08-28 22:14:37 +0000678template<class PopulationIterator, class SampleIterator,
679 class Distance, class UniformRandomBitGenerator>
680 SampleIterator sample(PopulationIterator first, PopulationIterator last,
681 SampleIterator out, Distance n,
682 UniformRandomBitGenerator&& g); // C++17
683
Howard Hinnant578ac0f2010-05-26 17:49:34 +0000684template<class RandomAccessIterator, class UniformRandomNumberGenerator>
685 void shuffle(RandomAccessIterator first, RandomAccessIterator last,
Howard Hinnanta5e71782010-11-18 01:47:02 +0000686 UniformRandomNumberGenerator&& g);
Howard Hinnant578ac0f2010-05-26 17:49:34 +0000687
Arthur O'Dwyercea050d2020-12-26 01:39:03 -0500688template<class ForwardIterator>
689 constexpr ForwardIterator
690 shift_left(ForwardIterator first, ForwardIterator last,
691 typename iterator_traits<ForwardIterator>::difference_type n); // C++20
692
693template<class ForwardIterator>
694 constexpr ForwardIterator
695 shift_right(ForwardIterator first, ForwardIterator last,
696 typename iterator_traits<ForwardIterator>::difference_type n); // C++20
697
Howard Hinnantc51e1022010-05-11 19:42:16 +0000698template <class InputIterator, class Predicate>
Marshall Clow96d050a2018-01-15 16:16:32 +0000699 constexpr bool // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000700 is_partitioned(InputIterator first, InputIterator last, Predicate pred);
701
702template <class ForwardIterator, class Predicate>
Arthur O'Dwyere50e7472020-12-17 00:01:08 -0500703 constexpr ForwardIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000704 partition(ForwardIterator first, ForwardIterator last, Predicate pred);
705
706template <class InputIterator, class OutputIterator1,
707 class OutputIterator2, class Predicate>
Marshall Clow5492c8a2018-01-22 20:44:33 +0000708 constexpr pair<OutputIterator1, OutputIterator2> // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000709 partition_copy(InputIterator first, InputIterator last,
710 OutputIterator1 out_true, OutputIterator2 out_false,
711 Predicate pred);
712
713template <class ForwardIterator, class Predicate>
714 ForwardIterator
715 stable_partition(ForwardIterator first, ForwardIterator last, Predicate pred);
716
717template<class ForwardIterator, class Predicate>
Marshall Clowe00916c2018-01-16 02:34:41 +0000718 constexpr ForwardIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000719 partition_point(ForwardIterator first, ForwardIterator last, Predicate pred);
720
721template <class ForwardIterator>
Marshall Clow96d050a2018-01-15 16:16:32 +0000722 constexpr bool // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000723 is_sorted(ForwardIterator first, ForwardIterator last);
724
725template <class ForwardIterator, class Compare>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500726 constexpr bool // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000727 is_sorted(ForwardIterator first, ForwardIterator last, Compare comp);
728
729template<class ForwardIterator>
Marshall Clow3c0558f2018-01-15 19:40:34 +0000730 constexpr ForwardIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000731 is_sorted_until(ForwardIterator first, ForwardIterator last);
732
733template <class ForwardIterator, class Compare>
Marshall Clow3c0558f2018-01-15 19:40:34 +0000734 constexpr ForwardIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000735 is_sorted_until(ForwardIterator first, ForwardIterator last, Compare comp);
736
737template <class RandomAccessIterator>
Arthur O'Dwyer1bb0f672020-12-20 15:21:42 -0500738 constexpr void // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000739 sort(RandomAccessIterator first, RandomAccessIterator last);
740
741template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer1bb0f672020-12-20 15:21:42 -0500742 constexpr void // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000743 sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
744
745template <class RandomAccessIterator>
746 void
747 stable_sort(RandomAccessIterator first, RandomAccessIterator last);
748
749template <class RandomAccessIterator, class Compare>
750 void
751 stable_sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
752
753template <class RandomAccessIterator>
Arthur O'Dwyer2dfea5d2020-12-17 00:26:18 -0500754 constexpr void // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000755 partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last);
756
757template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer2dfea5d2020-12-17 00:26:18 -0500758 constexpr void // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000759 partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last, Compare comp);
760
761template <class InputIterator, class RandomAccessIterator>
Arthur O'Dwyer2dfea5d2020-12-17 00:26:18 -0500762 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000763 partial_sort_copy(InputIterator first, InputIterator last,
764 RandomAccessIterator result_first, RandomAccessIterator result_last);
765
766template <class InputIterator, class RandomAccessIterator, class Compare>
Arthur O'Dwyer2dfea5d2020-12-17 00:26:18 -0500767 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000768 partial_sort_copy(InputIterator first, InputIterator last,
769 RandomAccessIterator result_first, RandomAccessIterator result_last, Compare comp);
770
771template <class RandomAccessIterator>
Arthur O'Dwyer4f5717b2021-02-04 18:12:52 -0500772 constexpr void // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000773 nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last);
774
775template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer4f5717b2021-02-04 18:12:52 -0500776 constexpr void // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000777 nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last, Compare comp);
778
779template <class ForwardIterator, class T>
Marshall Clowe00916c2018-01-16 02:34:41 +0000780 constexpr ForwardIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000781 lower_bound(ForwardIterator first, ForwardIterator last, const T& value);
782
783template <class ForwardIterator, class T, class Compare>
Marshall Clowe00916c2018-01-16 02:34:41 +0000784 constexpr ForwardIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000785 lower_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
786
787template <class ForwardIterator, class T>
Marshall Clowe00916c2018-01-16 02:34:41 +0000788 constexpr ForwardIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000789 upper_bound(ForwardIterator first, ForwardIterator last, const T& value);
790
791template <class ForwardIterator, class T, class Compare>
Marshall Clowe00916c2018-01-16 02:34:41 +0000792 constexpr ForwardIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000793 upper_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
794
795template <class ForwardIterator, class T>
Marshall Clowe00916c2018-01-16 02:34:41 +0000796 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000797 equal_range(ForwardIterator first, ForwardIterator last, const T& value);
798
799template <class ForwardIterator, class T, class Compare>
Marshall Clowe00916c2018-01-16 02:34:41 +0000800 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000801 equal_range(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
802
803template <class ForwardIterator, class T>
Marshall Clowe00916c2018-01-16 02:34:41 +0000804 constexpr bool // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000805 binary_search(ForwardIterator first, ForwardIterator last, const T& value);
806
807template <class ForwardIterator, class T, class Compare>
Marshall Clowc0b7f972018-01-22 23:10:40 +0000808 constexpr bool // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000809 binary_search(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
810
811template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer5afc5692020-12-04 13:47:12 -0500812 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000813 merge(InputIterator1 first1, InputIterator1 last1,
814 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
815
816template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer5afc5692020-12-04 13:47:12 -0500817 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000818 merge(InputIterator1 first1, InputIterator1 last1,
819 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
820
821template <class BidirectionalIterator>
822 void
823 inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last);
824
825template <class BidirectionalIterator, class Compare>
826 void
827 inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last, Compare comp);
828
829template <class InputIterator1, class InputIterator2>
Marshall Clowc0b7f972018-01-22 23:10:40 +0000830 constexpr bool // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000831 includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
832
833template <class InputIterator1, class InputIterator2, class Compare>
Marshall Clowc0b7f972018-01-22 23:10:40 +0000834 constexpr bool // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000835 includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, Compare comp);
836
837template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer5afc5692020-12-04 13:47:12 -0500838 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000839 set_union(InputIterator1 first1, InputIterator1 last1,
840 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
841
842template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer5afc5692020-12-04 13:47:12 -0500843 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000844 set_union(InputIterator1 first1, InputIterator1 last1,
845 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
846
847template <class InputIterator1, class InputIterator2, class OutputIterator>
Marshall Clowc0b7f972018-01-22 23:10:40 +0000848 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000849 set_intersection(InputIterator1 first1, InputIterator1 last1,
850 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
851
852template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Marshall Clowc0b7f972018-01-22 23:10:40 +0000853 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000854 set_intersection(InputIterator1 first1, InputIterator1 last1,
855 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
856
857template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer5afc5692020-12-04 13:47:12 -0500858 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000859 set_difference(InputIterator1 first1, InputIterator1 last1,
860 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
861
862template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer5afc5692020-12-04 13:47:12 -0500863 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000864 set_difference(InputIterator1 first1, InputIterator1 last1,
865 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
866
867template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer5afc5692020-12-04 13:47:12 -0500868 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000869 set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
870 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
871
872template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer5afc5692020-12-04 13:47:12 -0500873 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000874 set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
875 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
876
877template <class RandomAccessIterator>
Arthur O'Dwyer2dfea5d2020-12-17 00:26:18 -0500878 constexpr void // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000879 push_heap(RandomAccessIterator first, RandomAccessIterator last);
880
881template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer2dfea5d2020-12-17 00:26:18 -0500882 constexpr void // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000883 push_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
884
885template <class RandomAccessIterator>
Arthur O'Dwyer2dfea5d2020-12-17 00:26:18 -0500886 constexpr void // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000887 pop_heap(RandomAccessIterator first, RandomAccessIterator last);
888
889template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer2dfea5d2020-12-17 00:26:18 -0500890 constexpr void // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000891 pop_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
892
893template <class RandomAccessIterator>
Arthur O'Dwyer2dfea5d2020-12-17 00:26:18 -0500894 constexpr void // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000895 make_heap(RandomAccessIterator first, RandomAccessIterator last);
896
897template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer2dfea5d2020-12-17 00:26:18 -0500898 constexpr void // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000899 make_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
900
901template <class RandomAccessIterator>
Arthur O'Dwyer2dfea5d2020-12-17 00:26:18 -0500902 constexpr void // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000903 sort_heap(RandomAccessIterator first, RandomAccessIterator last);
904
905template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer2dfea5d2020-12-17 00:26:18 -0500906 constexpr void // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000907 sort_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
908
Howard Hinnant3b6579a2010-08-22 00:02:43 +0000909template <class RandomAccessIterator>
Marshall Clow96d050a2018-01-15 16:16:32 +0000910 constexpr bool // constexpr in C++20
Howard Hinnant3b6579a2010-08-22 00:02:43 +0000911 is_heap(RandomAccessIterator first, RandomAccessiterator last);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000912
Howard Hinnant3b6579a2010-08-22 00:02:43 +0000913template <class RandomAccessIterator, class Compare>
Marshall Clow96d050a2018-01-15 16:16:32 +0000914 constexpr bool // constexpr in C++20
Howard Hinnant3b6579a2010-08-22 00:02:43 +0000915 is_heap(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000916
Howard Hinnant3b6579a2010-08-22 00:02:43 +0000917template <class RandomAccessIterator>
Marshall Clow96d050a2018-01-15 16:16:32 +0000918 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnant3b6579a2010-08-22 00:02:43 +0000919 is_heap_until(RandomAccessIterator first, RandomAccessiterator last);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000920
Howard Hinnant3b6579a2010-08-22 00:02:43 +0000921template <class RandomAccessIterator, class Compare>
Marshall Clow96d050a2018-01-15 16:16:32 +0000922 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnant3b6579a2010-08-22 00:02:43 +0000923 is_heap_until(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000924
Howard Hinnantb120e7a2010-08-21 20:10:01 +0000925template <class ForwardIterator>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500926 constexpr ForwardIterator // constexpr in C++14
927 min_element(ForwardIterator first, ForwardIterator last);
Howard Hinnantb120e7a2010-08-21 20:10:01 +0000928
929template <class ForwardIterator, class Compare>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500930 constexpr ForwardIterator // constexpr in C++14
931 min_element(ForwardIterator first, ForwardIterator last, Compare comp);
Howard Hinnantb120e7a2010-08-21 20:10:01 +0000932
Howard Hinnantc51e1022010-05-11 19:42:16 +0000933template <class T>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500934 constexpr const T& // constexpr in C++14
935 min(const T& a, const T& b);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000936
937template <class T, class Compare>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500938 constexpr const T& // constexpr in C++14
939 min(const T& a, const T& b, Compare comp);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000940
Howard Hinnantb120e7a2010-08-21 20:10:01 +0000941template<class T>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500942 constexpr T // constexpr in C++14
943 min(initializer_list<T> t);
Howard Hinnantb120e7a2010-08-21 20:10:01 +0000944
945template<class T, class Compare>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500946 constexpr T // constexpr in C++14
947 min(initializer_list<T> t, Compare comp);
Howard Hinnantb120e7a2010-08-21 20:10:01 +0000948
Marshall Clow3e18d0e2016-03-07 22:43:49 +0000949template<class T>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500950 constexpr const T& clamp(const T& v, const T& lo, const T& hi); // C++17
Marshall Clow3e18d0e2016-03-07 22:43:49 +0000951
952template<class T, class Compare>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500953 constexpr const T& clamp(const T& v, const T& lo, const T& hi, Compare comp); // C++17
Marshall Clow3e18d0e2016-03-07 22:43:49 +0000954
Howard Hinnantb120e7a2010-08-21 20:10:01 +0000955template <class ForwardIterator>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500956 constexpr ForwardIterator // constexpr in C++14
957 max_element(ForwardIterator first, ForwardIterator last);
Howard Hinnantb120e7a2010-08-21 20:10:01 +0000958
959template <class ForwardIterator, class Compare>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500960 constexpr ForwardIterator // constexpr in C++14
961 max_element(ForwardIterator first, ForwardIterator last, Compare comp);
Howard Hinnantb120e7a2010-08-21 20:10:01 +0000962
Howard Hinnantc51e1022010-05-11 19:42:16 +0000963template <class T>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500964 constexpr const T& // constexpr in C++14
965 max(const T& a, const T& b);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000966
967template <class T, class Compare>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500968 constexpr const T& // constexpr in C++14
969 max(const T& a, const T& b, Compare comp);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000970
Howard Hinnantb120e7a2010-08-21 20:10:01 +0000971template<class T>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500972 constexpr T // constexpr in C++14
973 max(initializer_list<T> t);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000974
Howard Hinnantb120e7a2010-08-21 20:10:01 +0000975template<class T, class Compare>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500976 constexpr T // constexpr in C++14
977 max(initializer_list<T> t, Compare comp);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000978
Howard Hinnantb120e7a2010-08-21 20:10:01 +0000979template<class ForwardIterator>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500980 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++14
981 minmax_element(ForwardIterator first, ForwardIterator last);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000982
Howard Hinnantb120e7a2010-08-21 20:10:01 +0000983template<class ForwardIterator, class Compare>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500984 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++14
985 minmax_element(ForwardIterator first, ForwardIterator last, Compare comp);
Howard Hinnantb120e7a2010-08-21 20:10:01 +0000986
987template<class T>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500988 constexpr pair<const T&, const T&> // constexpr in C++14
989 minmax(const T& a, const T& b);
Howard Hinnantb120e7a2010-08-21 20:10:01 +0000990
991template<class T, class Compare>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500992 constexpr pair<const T&, const T&> // constexpr in C++14
993 minmax(const T& a, const T& b, Compare comp);
Howard Hinnantb120e7a2010-08-21 20:10:01 +0000994
995template<class T>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500996 constexpr pair<T, T> // constexpr in C++14
997 minmax(initializer_list<T> t);
Howard Hinnantb120e7a2010-08-21 20:10:01 +0000998
999template<class T, class Compare>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -05001000 constexpr pair<T, T> // constexpr in C++14
1001 minmax(initializer_list<T> t, Compare comp);
Howard Hinnantc51e1022010-05-11 19:42:16 +00001002
1003template <class InputIterator1, class InputIterator2>
Marshall Clow5492c8a2018-01-22 20:44:33 +00001004 constexpr bool // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +00001005 lexicographical_compare(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
1006
1007template <class InputIterator1, class InputIterator2, class Compare>
Marshall Clow5492c8a2018-01-22 20:44:33 +00001008 constexpr bool // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +00001009 lexicographical_compare(InputIterator1 first1, InputIterator1 last1,
1010 InputIterator2 first2, InputIterator2 last2, Compare comp);
1011
1012template <class BidirectionalIterator>
Arthur O'Dwyere50e7472020-12-17 00:01:08 -05001013 constexpr bool // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +00001014 next_permutation(BidirectionalIterator first, BidirectionalIterator last);
1015
1016template <class BidirectionalIterator, class Compare>
Arthur O'Dwyere50e7472020-12-17 00:01:08 -05001017 constexpr bool // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +00001018 next_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
1019
1020template <class BidirectionalIterator>
Arthur O'Dwyere50e7472020-12-17 00:01:08 -05001021 constexpr bool // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +00001022 prev_permutation(BidirectionalIterator first, BidirectionalIterator last);
1023
1024template <class BidirectionalIterator, class Compare>
Arthur O'Dwyere50e7472020-12-17 00:01:08 -05001025 constexpr bool // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +00001026 prev_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
Howard Hinnantc51e1022010-05-11 19:42:16 +00001027} // std
1028
1029*/
1030
Louis Dionneb4fce352022-03-25 12:55:36 -04001031#include <__assert> // all public C++ headers provide the assertion handler
Arthur O'Dwyer3693d7a2022-02-04 13:09:30 -05001032#include <__bits>
Howard Hinnantc51e1022010-05-11 19:42:16 +00001033#include <__config>
Louis Dionnea60dd872021-06-17 11:30:11 -04001034#include <__debug>
Howard Hinnant60e5cf42012-07-26 17:09:09 +00001035#include <cstddef>
Arthur O'Dwyeref181602021-05-19 11:57:04 -04001036#include <cstring>
Arthur O'Dwyeref181602021-05-19 11:57:04 -04001037#include <initializer_list>
1038#include <iterator>
1039#include <memory>
1040#include <type_traits>
Marshall Clow0a1e7502018-09-12 19:41:40 +00001041#include <version>
Howard Hinnantea382952013-08-14 18:00:20 +00001042
Louis Dionnea60dd872021-06-17 11:30:11 -04001043#include <__algorithm/adjacent_find.h>
1044#include <__algorithm/all_of.h>
1045#include <__algorithm/any_of.h>
1046#include <__algorithm/binary_search.h>
1047#include <__algorithm/clamp.h>
1048#include <__algorithm/comp.h>
1049#include <__algorithm/comp_ref_type.h>
1050#include <__algorithm/copy.h>
1051#include <__algorithm/copy_backward.h>
1052#include <__algorithm/copy_if.h>
1053#include <__algorithm/copy_n.h>
1054#include <__algorithm/count.h>
1055#include <__algorithm/count_if.h>
1056#include <__algorithm/equal.h>
1057#include <__algorithm/equal_range.h>
Louis Dionnea60dd872021-06-17 11:30:11 -04001058#include <__algorithm/fill.h>
Arthur O'Dwyer65077c02022-01-07 09:45:05 -05001059#include <__algorithm/fill_n.h>
Louis Dionnea60dd872021-06-17 11:30:11 -04001060#include <__algorithm/find.h>
1061#include <__algorithm/find_end.h>
1062#include <__algorithm/find_first_of.h>
1063#include <__algorithm/find_if.h>
1064#include <__algorithm/find_if_not.h>
1065#include <__algorithm/for_each.h>
1066#include <__algorithm/for_each_n.h>
Louis Dionnea60dd872021-06-17 11:30:11 -04001067#include <__algorithm/generate.h>
Arthur O'Dwyer65077c02022-01-07 09:45:05 -05001068#include <__algorithm/generate_n.h>
Louis Dionnea60dd872021-06-17 11:30:11 -04001069#include <__algorithm/half_positive.h>
Nikolas Klauserdd5ad212022-02-21 23:07:02 +01001070#include <__algorithm/in_found_result.h>
Nikolas Klauser671b4752022-02-11 17:01:58 +01001071#include <__algorithm/in_fun_result.h>
Nikolas Klauser05e2cd82022-01-25 11:21:47 +01001072#include <__algorithm/in_in_out_result.h>
Nikolas Klauserf74be4e2022-01-14 02:55:51 +01001073#include <__algorithm/in_in_result.h>
Nikolas Klauser61ce8162022-02-03 02:17:03 +01001074#include <__algorithm/in_out_out_result.h>
Konstantin Varlamov74736812022-01-10 22:49:37 -08001075#include <__algorithm/in_out_result.h>
Louis Dionnea60dd872021-06-17 11:30:11 -04001076#include <__algorithm/includes.h>
1077#include <__algorithm/inplace_merge.h>
1078#include <__algorithm/is_heap.h>
1079#include <__algorithm/is_heap_until.h>
1080#include <__algorithm/is_partitioned.h>
1081#include <__algorithm/is_permutation.h>
1082#include <__algorithm/is_sorted.h>
1083#include <__algorithm/is_sorted_until.h>
Christopher Di Bella41f26e82021-06-05 02:47:47 +00001084#include <__algorithm/iter_swap.h>
Louis Dionnea60dd872021-06-17 11:30:11 -04001085#include <__algorithm/lexicographical_compare.h>
1086#include <__algorithm/lower_bound.h>
1087#include <__algorithm/make_heap.h>
1088#include <__algorithm/max.h>
1089#include <__algorithm/max_element.h>
1090#include <__algorithm/merge.h>
1091#include <__algorithm/min.h>
1092#include <__algorithm/min_element.h>
Nikolas Klauser2e263162022-02-21 22:48:36 +01001093#include <__algorithm/min_max_result.h>
Louis Dionnea60dd872021-06-17 11:30:11 -04001094#include <__algorithm/minmax.h>
1095#include <__algorithm/minmax_element.h>
1096#include <__algorithm/mismatch.h>
1097#include <__algorithm/move.h>
1098#include <__algorithm/move_backward.h>
1099#include <__algorithm/next_permutation.h>
1100#include <__algorithm/none_of.h>
1101#include <__algorithm/nth_element.h>
1102#include <__algorithm/partial_sort.h>
1103#include <__algorithm/partial_sort_copy.h>
1104#include <__algorithm/partition.h>
1105#include <__algorithm/partition_copy.h>
1106#include <__algorithm/partition_point.h>
1107#include <__algorithm/pop_heap.h>
1108#include <__algorithm/prev_permutation.h>
1109#include <__algorithm/push_heap.h>
Nikolas Klausered3f0e82022-05-26 16:42:46 +02001110#include <__algorithm/ranges_all_of.h>
1111#include <__algorithm/ranges_any_of.h>
Nikolas Klauser8b381972022-06-05 21:15:16 +02001112#include <__algorithm/ranges_binary_search.h>
Nikolas Klauserd959d842022-04-15 13:43:40 +02001113#include <__algorithm/ranges_copy.h>
1114#include <__algorithm/ranges_copy_backward.h>
1115#include <__algorithm/ranges_copy_if.h>
1116#include <__algorithm/ranges_copy_n.h>
Nikolas Klauserf1373d02022-04-07 13:02:02 +02001117#include <__algorithm/ranges_count.h>
1118#include <__algorithm/ranges_count_if.h>
Nikolas Klauser353f1dd2022-05-25 11:09:43 +02001119#include <__algorithm/ranges_equal.h>
Nikolas Klausereb49c2a2022-05-21 18:26:29 +02001120#include <__algorithm/ranges_fill.h>
1121#include <__algorithm/ranges_fill_n.h>
Nikolas Klauser37d076e2022-03-12 01:45:35 +01001122#include <__algorithm/ranges_find.h>
Nikolas Klauser0a7e46d2022-06-06 13:57:34 +02001123#include <__algorithm/ranges_find_first_of.h>
Nikolas Klauser37d076e2022-03-12 01:45:35 +01001124#include <__algorithm/ranges_find_if.h>
1125#include <__algorithm/ranges_find_if_not.h>
Nikolas Klauser58de98c2022-05-04 20:27:07 +02001126#include <__algorithm/ranges_for_each.h>
1127#include <__algorithm/ranges_for_each_n.h>
Nikolas Klauserbb9049d2022-05-04 14:19:09 +02001128#include <__algorithm/ranges_is_partitioned.h>
Nikolas Klauserab0b7af2022-05-26 16:08:55 +02001129#include <__algorithm/ranges_is_sorted.h>
1130#include <__algorithm/ranges_is_sorted_until.h>
Nikolas Klauser8b381972022-06-05 21:15:16 +02001131#include <__algorithm/ranges_lower_bound.h>
Nikolas Klauser573cd6f2022-04-03 09:17:01 +02001132#include <__algorithm/ranges_max.h>
Nikolas Klauserf2a69ea2022-03-07 17:01:52 +01001133#include <__algorithm/ranges_max_element.h>
Nikolas Klauser3559e452022-03-18 02:57:08 +01001134#include <__algorithm/ranges_min.h>
Nikolas Klauser0a62a172022-02-11 13:11:57 +01001135#include <__algorithm/ranges_min_element.h>
Nikolas Klauser0a2f44f2022-04-13 22:59:09 +02001136#include <__algorithm/ranges_minmax.h>
1137#include <__algorithm/ranges_minmax_element.h>
Nikolas Klauser12fc9bf2022-03-08 23:12:35 +01001138#include <__algorithm/ranges_mismatch.h>
Nikolas Klausered3f0e82022-05-26 16:42:46 +02001139#include <__algorithm/ranges_none_of.h>
Nikolas Klauser52f20072022-05-24 10:32:50 +02001140#include <__algorithm/ranges_reverse.h>
Nikolas Klauser4ceab5f2022-02-10 13:33:03 +01001141#include <__algorithm/ranges_swap_ranges.h>
Nikolas Klauser559a1772022-04-05 11:05:36 +02001142#include <__algorithm/ranges_transform.h>
Nikolas Klauser8b381972022-06-05 21:15:16 +02001143#include <__algorithm/ranges_upper_bound.h>
Louis Dionnea60dd872021-06-17 11:30:11 -04001144#include <__algorithm/remove.h>
1145#include <__algorithm/remove_copy.h>
1146#include <__algorithm/remove_copy_if.h>
1147#include <__algorithm/remove_if.h>
1148#include <__algorithm/replace.h>
1149#include <__algorithm/replace_copy.h>
1150#include <__algorithm/replace_copy_if.h>
1151#include <__algorithm/replace_if.h>
1152#include <__algorithm/reverse.h>
1153#include <__algorithm/reverse_copy.h>
1154#include <__algorithm/rotate.h>
1155#include <__algorithm/rotate_copy.h>
1156#include <__algorithm/sample.h>
1157#include <__algorithm/search.h>
1158#include <__algorithm/search_n.h>
1159#include <__algorithm/set_difference.h>
1160#include <__algorithm/set_intersection.h>
1161#include <__algorithm/set_symmetric_difference.h>
1162#include <__algorithm/set_union.h>
1163#include <__algorithm/shift_left.h>
1164#include <__algorithm/shift_right.h>
1165#include <__algorithm/shuffle.h>
1166#include <__algorithm/sift_down.h>
1167#include <__algorithm/sort.h>
1168#include <__algorithm/sort_heap.h>
1169#include <__algorithm/stable_partition.h>
1170#include <__algorithm/stable_sort.h>
Christopher Di Bella41f26e82021-06-05 02:47:47 +00001171#include <__algorithm/swap_ranges.h>
Louis Dionnea60dd872021-06-17 11:30:11 -04001172#include <__algorithm/transform.h>
Louis Dionnea60dd872021-06-17 11:30:11 -04001173#include <__algorithm/unique.h>
Arthur O'Dwyer65077c02022-01-07 09:45:05 -05001174#include <__algorithm/unique_copy.h>
Louis Dionnea60dd872021-06-17 11:30:11 -04001175#include <__algorithm/unwrap_iter.h>
1176#include <__algorithm/upper_bound.h>
Eric Fiselier14b6de92014-08-10 23:53:08 +00001177
Howard Hinnantaaaa52b2011-10-17 20:05:10 +00001178#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Arthur O'Dwyer6eeaa002022-02-01 20:16:40 -05001179# pragma GCC system_header
Howard Hinnantaaaa52b2011-10-17 20:05:10 +00001180#endif
Howard Hinnantc51e1022010-05-11 19:42:16 +00001181
Louis Dionne59d0b3c2019-08-05 18:29:14 +00001182#if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17
Louis Dionned53d8c02019-08-06 21:11:24 +00001183# include <__pstl_algorithm>
Louis Dionne59d0b3c2019-08-05 18:29:14 +00001184#endif
1185
Louis Dionne2b1ceaa2021-04-20 12:03:32 -04001186#endif // _LIBCPP_ALGORITHM