blob: c55c87fac5058651aa4194fa6336dee44c9f7634 [file] [log] [blame]
Howard Hinnant3e519522010-05-11 19:42:161// -*- C++ -*-
Louis Dionneeb8650a2021-11-17 21:25:012//===----------------------------------------------------------------------===//
Howard Hinnant3e519522010-05-11 19:42:163//
Chandler Carruth57b08b02019-01-19 10:56:404// 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 Hinnant3e519522010-05-11 19:42:167//
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 Klauserd3729bb2022-01-14 01:55:5121namespace ranges {
Nikolas Klauser1e77b392022-02-11 16:01:5822 template <class I, class F>
Nikolas Klauser807766b2022-02-21 21:48:3623 struct in_fun_result; // since C++20
Nikolas Klauser1e77b392022-02-11 16:01:5824
Nikolas Klauserd3729bb2022-01-14 01:55:5125 template <class I1, class I2>
Nikolas Klauser807766b2022-02-21 21:48:3626 struct in_in_result; // since C++20
Nikolas Klauserf3514af2022-01-25 10:21:4727
28 template <class I1, class I2, class O>
Nikolas Klauser807766b2022-02-21 21:48:3629 struct in_in_out_result; // since C++20
Nikolas Klauser610979b2022-02-03 01:17:0330
31 template <class I, class O1, class O2>
32 struct in_out_out_result; // since C++20
Nikolas Klauser1e77b392022-02-11 16:01:5833
Nikolas Klauser807766b2022-02-21 21:48:3634 template <class I1, class I2>
35 struct min_max_result; // since C++20
36
Nikolas Klauser68f41312022-02-21 22:07:0237 template <class I>
38 struct in_found_result; // since C++20
39
Nikolas Klauser3b470d12022-02-11 12:11:5740 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 Klauserc2cd15a2022-03-08 22:12:3547
Nikolas Klauser40f7fca32022-05-22 11:43:3748 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 Klauserc2cd15a2022-03-08 22:12:3557 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 Klauseree0f8c42022-03-12 00:45:3568
Nikolas Klauseree0f8c42022-03-12 00:45:3569 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 Klauserf83d8332022-03-18 01:57:0894
Nikolas Klausere476df52022-04-03 07:17:0195 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 Klauserf83d8332022-03-18 01:57:0898
Nikolas Klausere476df52022-04-03 07:17:0199 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 Klauserf83d8332022-03-18 01:57:08102
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 Klausere476df52022-04-03 07:17:01108
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 Klauser3ba85482022-04-05 09:05:36122
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 Klauser1306b102022-04-07 11:02:02157
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 Klauser58d9ab72022-04-13 20:59:09177
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 Klauser1d837502022-04-15 11:43:40203
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 Klauser80045e92022-05-04 18:27:07250
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 Klauser37ba1b92022-05-04 12:19:09268
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 Klauser1d1a1912022-05-24 08:32:50277
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 Klauser7af89a32022-05-21 16:26:29286 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 Klauser569d6632022-05-25 09:09:43294
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 Klauser0e3dc1a2022-05-26 14:42:46308 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 Klauser11e3ad22022-05-26 14:08:55332 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 Klauser81715862022-06-05 19:15:16348
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
373 template<forward_range R, class T, class Proj = identity,
374 indirect_strict_weak_order<const T*, projected<iterator_t<R>, Proj>> Comp =
375 ranges::less>
376 constexpr bool binary_search(R&& r, const T& value, Comp comp = {},
377 Proj proj = {}); // since C++20
378
Nikolas Klauserd3729bb2022-01-14 01:55:51379}
380
Marshall Clow706ffef2018-01-15 17:20:36381 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16382 all_of(InputIterator first, InputIterator last, Predicate pred);
383
384template <class InputIterator, class Predicate>
Marshall Clow706ffef2018-01-15 17:20:36385 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16386 any_of(InputIterator first, InputIterator last, Predicate pred);
387
388template <class InputIterator, class Predicate>
Marshall Clow706ffef2018-01-15 17:20:36389 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16390 none_of(InputIterator first, InputIterator last, Predicate pred);
391
392template <class InputIterator, class Function>
Marshall Clow1b9a4ff2018-01-22 20:44:33393 constexpr Function // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16394 for_each(InputIterator first, InputIterator last, Function f);
395
Marshall Clowd5c65ff2017-05-25 02:29:54396template<class InputIterator, class Size, class Function>
Marshall Clow1b9a4ff2018-01-22 20:44:33397 constexpr InputIterator // constexpr in C++20
398 for_each_n(InputIterator first, Size n, Function f); // C++17
Marshall Clowd5c65ff2017-05-25 02:29:54399
Howard Hinnant3e519522010-05-11 19:42:16400template <class InputIterator, class T>
Marshall Clow86944282018-01-15 19:26:05401 constexpr InputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16402 find(InputIterator first, InputIterator last, const T& value);
403
404template <class InputIterator, class Predicate>
Marshall Clow86944282018-01-15 19:26:05405 constexpr InputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16406 find_if(InputIterator first, InputIterator last, Predicate pred);
407
408template<class InputIterator, class Predicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18409 constexpr InputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16410 find_if_not(InputIterator first, InputIterator last, Predicate pred);
411
412template <class ForwardIterator1, class ForwardIterator2>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18413 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16414 find_end(ForwardIterator1 first1, ForwardIterator1 last1,
415 ForwardIterator2 first2, ForwardIterator2 last2);
416
417template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18418 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16419 find_end(ForwardIterator1 first1, ForwardIterator1 last1,
420 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
421
422template <class ForwardIterator1, class ForwardIterator2>
Marshall Clow86944282018-01-15 19:26:05423 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16424 find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
425 ForwardIterator2 first2, ForwardIterator2 last2);
426
427template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow86944282018-01-15 19:26:05428 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16429 find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
430 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
431
432template <class ForwardIterator>
Marshall Clow86944282018-01-15 19:26:05433 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16434 adjacent_find(ForwardIterator first, ForwardIterator last);
435
436template <class ForwardIterator, class BinaryPredicate>
Marshall Clow86944282018-01-15 19:26:05437 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16438 adjacent_find(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
439
440template <class InputIterator, class T>
Marshall Clow056f15e2018-01-15 19:40:34441 constexpr typename iterator_traits<InputIterator>::difference_type // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16442 count(InputIterator first, InputIterator last, const T& value);
443
444template <class InputIterator, class Predicate>
Marshall Clow056f15e2018-01-15 19:40:34445 constexpr typename iterator_traits<InputIterator>::difference_type // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16446 count_if(InputIterator first, InputIterator last, Predicate pred);
447
448template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:10449 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16450 mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
451
Marshall Clow0b0bbd22013-05-09 21:14:23452template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:10453 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Aditya Kumar331fb802016-08-25 11:52:38454 mismatch(InputIterator1 first1, InputIterator1 last1,
Marshall Clow0b0bbd22013-05-09 21:14:23455 InputIterator2 first2, InputIterator2 last2); // **C++14**
456
Howard Hinnant3e519522010-05-11 19:42:16457template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:10458 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16459 mismatch(InputIterator1 first1, InputIterator1 last1,
460 InputIterator2 first2, BinaryPredicate pred);
461
Marshall Clow0b0bbd22013-05-09 21:14:23462template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:10463 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23464 mismatch(InputIterator1 first1, InputIterator1 last1,
465 InputIterator2 first2, InputIterator2 last2,
466 BinaryPredicate pred); // **C++14**
467
Howard Hinnant3e519522010-05-11 19:42:16468template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:10469 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16470 equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
471
Marshall Clow0b0bbd22013-05-09 21:14:23472template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:10473 constexpr bool // constexpr in C++20
Aditya Kumar331fb802016-08-25 11:52:38474 equal(InputIterator1 first1, InputIterator1 last1,
Marshall Clow0b0bbd22013-05-09 21:14:23475 InputIterator2 first2, InputIterator2 last2); // **C++14**
476
Howard Hinnant3e519522010-05-11 19:42:16477template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:10478 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16479 equal(InputIterator1 first1, InputIterator1 last1,
480 InputIterator2 first2, BinaryPredicate pred);
481
Marshall Clow0b0bbd22013-05-09 21:14:23482template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:10483 constexpr bool // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23484 equal(InputIterator1 first1, InputIterator1 last1,
485 InputIterator2 first2, InputIterator2 last2,
486 BinaryPredicate pred); // **C++14**
487
Howard Hinnant3e519522010-05-11 19:42:16488template<class ForwardIterator1, class ForwardIterator2>
Marshall Clow49c76432018-01-15 16:16:32489 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16490 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
491 ForwardIterator2 first2);
492
Marshall Clow0b0bbd22013-05-09 21:14:23493template<class ForwardIterator1, class ForwardIterator2>
Marshall Clow49c76432018-01-15 16:16:32494 constexpr bool // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23495 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
496 ForwardIterator2 first2, ForwardIterator2 last2); // **C++14**
497
Howard Hinnant3e519522010-05-11 19:42:16498template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow49c76432018-01-15 16:16:32499 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16500 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
501 ForwardIterator2 first2, BinaryPredicate pred);
502
Marshall Clow0b0bbd22013-05-09 21:14:23503template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow49c76432018-01-15 16:16:32504 constexpr bool // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23505 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
506 ForwardIterator2 first2, ForwardIterator2 last2,
507 BinaryPredicate pred); // **C++14**
508
Howard Hinnant3e519522010-05-11 19:42:16509template <class ForwardIterator1, class ForwardIterator2>
Marshall Clow12f0a772018-01-16 15:48:27510 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16511 search(ForwardIterator1 first1, ForwardIterator1 last1,
512 ForwardIterator2 first2, ForwardIterator2 last2);
513
514template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow12f0a772018-01-16 15:48:27515 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16516 search(ForwardIterator1 first1, ForwardIterator1 last1,
517 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
518
519template <class ForwardIterator, class Size, class T>
Marshall Clow12f0a772018-01-16 15:48:27520 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16521 search_n(ForwardIterator first, ForwardIterator last, Size count, const T& value);
522
523template <class ForwardIterator, class Size, class T, class BinaryPredicate>
Marshall Clow12f0a772018-01-16 15:48:27524 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16525 search_n(ForwardIterator first, ForwardIterator last,
526 Size count, const T& value, BinaryPredicate pred);
527
528template <class InputIterator, class OutputIterator>
Louis Dionne13c90a52019-11-06 12:02:41529 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16530 copy(InputIterator first, InputIterator last, OutputIterator result);
531
532template<class InputIterator, class OutputIterator, class Predicate>
Louis Dionne13c90a52019-11-06 12:02:41533 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16534 copy_if(InputIterator first, InputIterator last,
535 OutputIterator result, Predicate pred);
536
537template<class InputIterator, class Size, class OutputIterator>
Louis Dionne13c90a52019-11-06 12:02:41538 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16539 copy_n(InputIterator first, Size n, OutputIterator result);
540
541template <class BidirectionalIterator1, class BidirectionalIterator2>
Louis Dionne13c90a52019-11-06 12:02:41542 constexpr BidirectionalIterator2 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16543 copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last,
544 BidirectionalIterator2 result);
545
546template <class ForwardIterator1, class ForwardIterator2>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18547 constexpr ForwardIterator2 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16548 swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2);
549
Nikolas Klauser9d905312022-02-10 12:33:03550template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2>
551 requires indirectly_swappable<I1, I2>
552 constexpr ranges::swap_ranges_result<I1, I2>
553 ranges::swap_ranges(I1 first1, S1 last1, I2 first2, S2 last2);
554
555template<input_range R1, input_range R2>
556 requires indirectly_swappable<iterator_t<R1>, iterator_t<R2>>
557 constexpr ranges::swap_ranges_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>>
558 ranges::swap_ranges(R1&& r1, R2&& r2);
559
Howard Hinnant3e519522010-05-11 19:42:16560template <class ForwardIterator1, class ForwardIterator2>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18561 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16562 iter_swap(ForwardIterator1 a, ForwardIterator2 b);
563
564template <class InputIterator, class OutputIterator, class UnaryOperation>
Marshall Clow99894b62018-01-19 17:45:39565 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16566 transform(InputIterator first, InputIterator last, OutputIterator result, UnaryOperation op);
567
568template <class InputIterator1, class InputIterator2, class OutputIterator, class BinaryOperation>
Marshall Clow99894b62018-01-19 17:45:39569 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16570 transform(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2,
571 OutputIterator result, BinaryOperation binary_op);
572
573template <class ForwardIterator, class T>
Marshall Clow12c74232018-01-19 18:07:29574 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16575 replace(ForwardIterator first, ForwardIterator last, const T& old_value, const T& new_value);
576
577template <class ForwardIterator, class Predicate, class T>
Marshall Clow12c74232018-01-19 18:07:29578 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16579 replace_if(ForwardIterator first, ForwardIterator last, Predicate pred, const T& new_value);
580
581template <class InputIterator, class OutputIterator, class T>
Marshall Clow12c74232018-01-19 18:07:29582 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16583 replace_copy(InputIterator first, InputIterator last, OutputIterator result,
584 const T& old_value, const T& new_value);
585
586template <class InputIterator, class OutputIterator, class Predicate, class T>
Marshall Clow12c74232018-01-19 18:07:29587 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16588 replace_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred, const T& new_value);
589
590template <class ForwardIterator, class T>
Marshall Clow4bfb9312018-01-20 20:14:32591 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16592 fill(ForwardIterator first, ForwardIterator last, const T& value);
593
594template <class OutputIterator, class Size, class T>
Marshall Clow4bfb9312018-01-20 20:14:32595 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16596 fill_n(OutputIterator first, Size n, const T& value);
597
598template <class ForwardIterator, class Generator>
Marshall Clow4bfb9312018-01-20 20:14:32599 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16600 generate(ForwardIterator first, ForwardIterator last, Generator gen);
601
602template <class OutputIterator, class Size, class Generator>
Marshall Clow4bfb9312018-01-20 20:14:32603 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16604 generate_n(OutputIterator first, Size n, Generator gen);
605
606template <class ForwardIterator, class T>
Marshall Clowe8ea8292018-01-22 21:43:04607 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16608 remove(ForwardIterator first, ForwardIterator last, const T& value);
609
610template <class ForwardIterator, class Predicate>
Marshall Clowe8ea8292018-01-22 21:43:04611 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16612 remove_if(ForwardIterator first, ForwardIterator last, Predicate pred);
613
614template <class InputIterator, class OutputIterator, class T>
Marshall Clowe8ea8292018-01-22 21:43:04615 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16616 remove_copy(InputIterator first, InputIterator last, OutputIterator result, const T& value);
617
618template <class InputIterator, class OutputIterator, class Predicate>
Marshall Clowe8ea8292018-01-22 21:43:04619 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16620 remove_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred);
621
622template <class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18623 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16624 unique(ForwardIterator first, ForwardIterator last);
625
626template <class ForwardIterator, class BinaryPredicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18627 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16628 unique(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
629
630template <class InputIterator, class OutputIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18631 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16632 unique_copy(InputIterator first, InputIterator last, OutputIterator result);
633
634template <class InputIterator, class OutputIterator, class BinaryPredicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18635 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16636 unique_copy(InputIterator first, InputIterator last, OutputIterator result, BinaryPredicate pred);
637
638template <class BidirectionalIterator>
Arthur O'Dwyerf851db32020-12-17 05:01:08639 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16640 reverse(BidirectionalIterator first, BidirectionalIterator last);
641
642template <class BidirectionalIterator, class OutputIterator>
Marshall Clowe8ea8292018-01-22 21:43:04643 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16644 reverse_copy(BidirectionalIterator first, BidirectionalIterator last, OutputIterator result);
645
646template <class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18647 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16648 rotate(ForwardIterator first, ForwardIterator middle, ForwardIterator last);
649
650template <class ForwardIterator, class OutputIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18651 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16652 rotate_copy(ForwardIterator first, ForwardIterator middle, ForwardIterator last, OutputIterator result);
653
654template <class RandomAccessIterator>
655 void
Marshall Clow0f37a412017-03-23 13:43:37656 random_shuffle(RandomAccessIterator first, RandomAccessIterator last); // deprecated in C++14, removed in C++17
Howard Hinnant3e519522010-05-11 19:42:16657
658template <class RandomAccessIterator, class RandomNumberGenerator>
659 void
Marshall Clow06965c12014-03-03 06:14:19660 random_shuffle(RandomAccessIterator first, RandomAccessIterator last,
Marshall Clow0f37a412017-03-23 13:43:37661 RandomNumberGenerator& rand); // deprecated in C++14, removed in C++17
Howard Hinnant3e519522010-05-11 19:42:16662
Eric Fiseliere7154702016-08-28 22:14:37663template<class PopulationIterator, class SampleIterator,
664 class Distance, class UniformRandomBitGenerator>
665 SampleIterator sample(PopulationIterator first, PopulationIterator last,
666 SampleIterator out, Distance n,
667 UniformRandomBitGenerator&& g); // C++17
668
Howard Hinnantf9d540b2010-05-26 17:49:34669template<class RandomAccessIterator, class UniformRandomNumberGenerator>
670 void shuffle(RandomAccessIterator first, RandomAccessIterator last,
Howard Hinnantfb340102010-11-18 01:47:02671 UniformRandomNumberGenerator&& g);
Howard Hinnantf9d540b2010-05-26 17:49:34672
Arthur O'Dwyer3fbd3ea2020-12-26 06:39:03673template<class ForwardIterator>
674 constexpr ForwardIterator
675 shift_left(ForwardIterator first, ForwardIterator last,
676 typename iterator_traits<ForwardIterator>::difference_type n); // C++20
677
678template<class ForwardIterator>
679 constexpr ForwardIterator
680 shift_right(ForwardIterator first, ForwardIterator last,
681 typename iterator_traits<ForwardIterator>::difference_type n); // C++20
682
Howard Hinnant3e519522010-05-11 19:42:16683template <class InputIterator, class Predicate>
Marshall Clow49c76432018-01-15 16:16:32684 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16685 is_partitioned(InputIterator first, InputIterator last, Predicate pred);
686
687template <class ForwardIterator, class Predicate>
Arthur O'Dwyerf851db32020-12-17 05:01:08688 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16689 partition(ForwardIterator first, ForwardIterator last, Predicate pred);
690
691template <class InputIterator, class OutputIterator1,
692 class OutputIterator2, class Predicate>
Marshall Clow1b9a4ff2018-01-22 20:44:33693 constexpr pair<OutputIterator1, OutputIterator2> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16694 partition_copy(InputIterator first, InputIterator last,
695 OutputIterator1 out_true, OutputIterator2 out_false,
696 Predicate pred);
697
698template <class ForwardIterator, class Predicate>
699 ForwardIterator
700 stable_partition(ForwardIterator first, ForwardIterator last, Predicate pred);
701
702template<class ForwardIterator, class Predicate>
Marshall Clowd57c03d2018-01-16 02:34:41703 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16704 partition_point(ForwardIterator first, ForwardIterator last, Predicate pred);
705
706template <class ForwardIterator>
Marshall Clow49c76432018-01-15 16:16:32707 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16708 is_sorted(ForwardIterator first, ForwardIterator last);
709
710template <class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18711 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16712 is_sorted(ForwardIterator first, ForwardIterator last, Compare comp);
713
714template<class ForwardIterator>
Marshall Clow056f15e2018-01-15 19:40:34715 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16716 is_sorted_until(ForwardIterator first, ForwardIterator last);
717
718template <class ForwardIterator, class Compare>
Marshall Clow056f15e2018-01-15 19:40:34719 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16720 is_sorted_until(ForwardIterator first, ForwardIterator last, Compare comp);
721
722template <class RandomAccessIterator>
Arthur O'Dwyer493f1402020-12-20 20:21:42723 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16724 sort(RandomAccessIterator first, RandomAccessIterator last);
725
726template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer493f1402020-12-20 20:21:42727 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16728 sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
729
730template <class RandomAccessIterator>
731 void
732 stable_sort(RandomAccessIterator first, RandomAccessIterator last);
733
734template <class RandomAccessIterator, class Compare>
735 void
736 stable_sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
737
738template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18739 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16740 partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last);
741
742template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18743 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16744 partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last, Compare comp);
745
746template <class InputIterator, class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18747 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16748 partial_sort_copy(InputIterator first, InputIterator last,
749 RandomAccessIterator result_first, RandomAccessIterator result_last);
750
751template <class InputIterator, class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18752 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16753 partial_sort_copy(InputIterator first, InputIterator last,
754 RandomAccessIterator result_first, RandomAccessIterator result_last, Compare comp);
755
756template <class RandomAccessIterator>
Arthur O'Dwyer5d956562021-02-04 23:12:52757 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16758 nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last);
759
760template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5d956562021-02-04 23:12:52761 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16762 nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last, Compare comp);
763
764template <class ForwardIterator, class T>
Marshall Clowd57c03d2018-01-16 02:34:41765 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16766 lower_bound(ForwardIterator first, ForwardIterator last, const T& value);
767
768template <class ForwardIterator, class T, class Compare>
Marshall Clowd57c03d2018-01-16 02:34:41769 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16770 lower_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
771
772template <class ForwardIterator, class T>
Marshall Clowd57c03d2018-01-16 02:34:41773 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16774 upper_bound(ForwardIterator first, ForwardIterator last, const T& value);
775
776template <class ForwardIterator, class T, class Compare>
Marshall Clowd57c03d2018-01-16 02:34:41777 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16778 upper_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
779
780template <class ForwardIterator, class T>
Marshall Clowd57c03d2018-01-16 02:34:41781 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16782 equal_range(ForwardIterator first, ForwardIterator last, const T& value);
783
784template <class ForwardIterator, class T, class Compare>
Marshall Clowd57c03d2018-01-16 02:34:41785 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16786 equal_range(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
787
788template <class ForwardIterator, class T>
Marshall Clowd57c03d2018-01-16 02:34:41789 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16790 binary_search(ForwardIterator first, ForwardIterator last, const T& value);
791
792template <class ForwardIterator, class T, class Compare>
Marshall Clow8da1a482018-01-22 23:10:40793 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16794 binary_search(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
795
796template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer14098cf2020-12-04 18:47:12797 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16798 merge(InputIterator1 first1, InputIterator1 last1,
799 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
800
801template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer14098cf2020-12-04 18:47:12802 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16803 merge(InputIterator1 first1, InputIterator1 last1,
804 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
805
806template <class BidirectionalIterator>
807 void
808 inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last);
809
810template <class BidirectionalIterator, class Compare>
811 void
812 inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last, Compare comp);
813
814template <class InputIterator1, class InputIterator2>
Marshall Clow8da1a482018-01-22 23:10:40815 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16816 includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
817
818template <class InputIterator1, class InputIterator2, class Compare>
Marshall Clow8da1a482018-01-22 23:10:40819 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16820 includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, Compare comp);
821
822template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer14098cf2020-12-04 18:47:12823 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16824 set_union(InputIterator1 first1, InputIterator1 last1,
825 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
826
827template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer14098cf2020-12-04 18:47:12828 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16829 set_union(InputIterator1 first1, InputIterator1 last1,
830 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
831
832template <class InputIterator1, class InputIterator2, class OutputIterator>
Marshall Clow8da1a482018-01-22 23:10:40833 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16834 set_intersection(InputIterator1 first1, InputIterator1 last1,
835 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
836
837template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Marshall Clow8da1a482018-01-22 23:10:40838 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16839 set_intersection(InputIterator1 first1, InputIterator1 last1,
840 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
841
842template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer14098cf2020-12-04 18:47:12843 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16844 set_difference(InputIterator1 first1, InputIterator1 last1,
845 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
846
847template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer14098cf2020-12-04 18:47:12848 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16849 set_difference(InputIterator1 first1, InputIterator1 last1,
850 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
851
852template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer14098cf2020-12-04 18:47:12853 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16854 set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
855 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
856
857template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer14098cf2020-12-04 18:47:12858 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16859 set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
860 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
861
862template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18863 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16864 push_heap(RandomAccessIterator first, RandomAccessIterator last);
865
866template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18867 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16868 push_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
869
870template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18871 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16872 pop_heap(RandomAccessIterator first, RandomAccessIterator last);
873
874template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18875 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16876 pop_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
877
878template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18879 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16880 make_heap(RandomAccessIterator first, RandomAccessIterator last);
881
882template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18883 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16884 make_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
885
886template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18887 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16888 sort_heap(RandomAccessIterator first, RandomAccessIterator last);
889
890template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18891 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16892 sort_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
893
Howard Hinnantb3371f62010-08-22 00:02:43894template <class RandomAccessIterator>
Marshall Clow49c76432018-01-15 16:16:32895 constexpr bool // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43896 is_heap(RandomAccessIterator first, RandomAccessiterator last);
Howard Hinnant3e519522010-05-11 19:42:16897
Howard Hinnantb3371f62010-08-22 00:02:43898template <class RandomAccessIterator, class Compare>
Marshall Clow49c76432018-01-15 16:16:32899 constexpr bool // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43900 is_heap(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16901
Howard Hinnantb3371f62010-08-22 00:02:43902template <class RandomAccessIterator>
Marshall Clow49c76432018-01-15 16:16:32903 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43904 is_heap_until(RandomAccessIterator first, RandomAccessiterator last);
Howard Hinnant3e519522010-05-11 19:42:16905
Howard Hinnantb3371f62010-08-22 00:02:43906template <class RandomAccessIterator, class Compare>
Marshall Clow49c76432018-01-15 16:16:32907 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43908 is_heap_until(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16909
Howard Hinnant4eb27b72010-08-21 20:10:01910template <class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18911 constexpr ForwardIterator // constexpr in C++14
912 min_element(ForwardIterator first, ForwardIterator last);
Howard Hinnant4eb27b72010-08-21 20:10:01913
914template <class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18915 constexpr ForwardIterator // constexpr in C++14
916 min_element(ForwardIterator first, ForwardIterator last, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01917
Howard Hinnant3e519522010-05-11 19:42:16918template <class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18919 constexpr const T& // constexpr in C++14
920 min(const T& a, const T& b);
Howard Hinnant3e519522010-05-11 19:42:16921
922template <class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18923 constexpr const T& // constexpr in C++14
924 min(const T& a, const T& b, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16925
Howard Hinnant4eb27b72010-08-21 20:10:01926template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18927 constexpr T // constexpr in C++14
928 min(initializer_list<T> t);
Howard Hinnant4eb27b72010-08-21 20:10:01929
930template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18931 constexpr T // constexpr in C++14
932 min(initializer_list<T> t, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01933
Marshall Clow146c14a2016-03-07 22:43:49934template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18935 constexpr const T& clamp(const T& v, const T& lo, const T& hi); // C++17
Marshall Clow146c14a2016-03-07 22:43:49936
937template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18938 constexpr const T& clamp(const T& v, const T& lo, const T& hi, Compare comp); // C++17
Marshall Clow146c14a2016-03-07 22:43:49939
Howard Hinnant4eb27b72010-08-21 20:10:01940template <class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18941 constexpr ForwardIterator // constexpr in C++14
942 max_element(ForwardIterator first, ForwardIterator last);
Howard Hinnant4eb27b72010-08-21 20:10:01943
944template <class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18945 constexpr ForwardIterator // constexpr in C++14
946 max_element(ForwardIterator first, ForwardIterator last, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01947
Howard Hinnant3e519522010-05-11 19:42:16948template <class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18949 constexpr const T& // constexpr in C++14
950 max(const T& a, const T& b);
Howard Hinnant3e519522010-05-11 19:42:16951
952template <class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18953 constexpr const T& // constexpr in C++14
954 max(const T& a, const T& b, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16955
Howard Hinnant4eb27b72010-08-21 20:10:01956template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18957 constexpr T // constexpr in C++14
958 max(initializer_list<T> t);
Howard Hinnant3e519522010-05-11 19:42:16959
Howard Hinnant4eb27b72010-08-21 20:10:01960template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18961 constexpr T // constexpr in C++14
962 max(initializer_list<T> t, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16963
Howard Hinnant4eb27b72010-08-21 20:10:01964template<class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18965 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++14
966 minmax_element(ForwardIterator first, ForwardIterator last);
Howard Hinnant3e519522010-05-11 19:42:16967
Howard Hinnant4eb27b72010-08-21 20:10:01968template<class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18969 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++14
970 minmax_element(ForwardIterator first, ForwardIterator last, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01971
972template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18973 constexpr pair<const T&, const T&> // constexpr in C++14
974 minmax(const T& a, const T& b);
Howard Hinnant4eb27b72010-08-21 20:10:01975
976template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18977 constexpr pair<const T&, const T&> // constexpr in C++14
978 minmax(const T& a, const T& b, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01979
980template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18981 constexpr pair<T, T> // constexpr in C++14
982 minmax(initializer_list<T> t);
Howard Hinnant4eb27b72010-08-21 20:10:01983
984template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18985 constexpr pair<T, T> // constexpr in C++14
986 minmax(initializer_list<T> t, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16987
988template <class InputIterator1, class InputIterator2>
Marshall Clow1b9a4ff2018-01-22 20:44:33989 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16990 lexicographical_compare(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
991
992template <class InputIterator1, class InputIterator2, class Compare>
Marshall Clow1b9a4ff2018-01-22 20:44:33993 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16994 lexicographical_compare(InputIterator1 first1, InputIterator1 last1,
995 InputIterator2 first2, InputIterator2 last2, Compare comp);
996
997template <class BidirectionalIterator>
Arthur O'Dwyerf851db32020-12-17 05:01:08998 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16999 next_permutation(BidirectionalIterator first, BidirectionalIterator last);
1000
1001template <class BidirectionalIterator, class Compare>
Arthur O'Dwyerf851db32020-12-17 05:01:081002 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:161003 next_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
1004
1005template <class BidirectionalIterator>
Arthur O'Dwyerf851db32020-12-17 05:01:081006 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:161007 prev_permutation(BidirectionalIterator first, BidirectionalIterator last);
1008
1009template <class BidirectionalIterator, class Compare>
Arthur O'Dwyerf851db32020-12-17 05:01:081010 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:161011 prev_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:161012} // std
1013
1014*/
1015
Louis Dionne385cc252022-03-25 16:55:361016#include <__assert> // all public C++ headers provide the assertion handler
Arthur O'Dwyerea2206d2022-02-04 18:09:301017#include <__bits>
Howard Hinnant3e519522010-05-11 19:42:161018#include <__config>
Louis Dionne134723e2021-06-17 15:30:111019#include <__debug>
Howard Hinnanta1d07d52012-07-26 17:09:091020#include <cstddef>
Arthur O'Dwyerbfbd73f2021-05-19 15:57:041021#include <cstring>
Arthur O'Dwyerbfbd73f2021-05-19 15:57:041022#include <initializer_list>
Arthur O'Dwyerbfbd73f2021-05-19 15:57:041023#include <iterator>
1024#include <memory>
1025#include <type_traits>
Marshall Clowf56972e2018-09-12 19:41:401026#include <version>
Howard Hinnant5d1a7012013-08-14 18:00:201027
Louis Dionne134723e2021-06-17 15:30:111028#include <__algorithm/adjacent_find.h>
1029#include <__algorithm/all_of.h>
1030#include <__algorithm/any_of.h>
1031#include <__algorithm/binary_search.h>
1032#include <__algorithm/clamp.h>
1033#include <__algorithm/comp.h>
1034#include <__algorithm/comp_ref_type.h>
1035#include <__algorithm/copy.h>
1036#include <__algorithm/copy_backward.h>
1037#include <__algorithm/copy_if.h>
1038#include <__algorithm/copy_n.h>
1039#include <__algorithm/count.h>
1040#include <__algorithm/count_if.h>
1041#include <__algorithm/equal.h>
1042#include <__algorithm/equal_range.h>
Louis Dionne134723e2021-06-17 15:30:111043#include <__algorithm/fill.h>
Arthur O'Dwyer4d81a462022-01-07 14:45:051044#include <__algorithm/fill_n.h>
Louis Dionne134723e2021-06-17 15:30:111045#include <__algorithm/find.h>
1046#include <__algorithm/find_end.h>
1047#include <__algorithm/find_first_of.h>
1048#include <__algorithm/find_if.h>
1049#include <__algorithm/find_if_not.h>
1050#include <__algorithm/for_each.h>
1051#include <__algorithm/for_each_n.h>
Louis Dionne134723e2021-06-17 15:30:111052#include <__algorithm/generate.h>
Arthur O'Dwyer4d81a462022-01-07 14:45:051053#include <__algorithm/generate_n.h>
Louis Dionne134723e2021-06-17 15:30:111054#include <__algorithm/half_positive.h>
Nikolas Klauser68f41312022-02-21 22:07:021055#include <__algorithm/in_found_result.h>
Nikolas Klauser1e77b392022-02-11 16:01:581056#include <__algorithm/in_fun_result.h>
Nikolas Klauserf3514af2022-01-25 10:21:471057#include <__algorithm/in_in_out_result.h>
Nikolas Klauserd3729bb2022-01-14 01:55:511058#include <__algorithm/in_in_result.h>
Nikolas Klauser610979b2022-02-03 01:17:031059#include <__algorithm/in_out_out_result.h>
Konstantin Varlamov8d23b742022-01-11 06:49:371060#include <__algorithm/in_out_result.h>
Louis Dionne134723e2021-06-17 15:30:111061#include <__algorithm/includes.h>
1062#include <__algorithm/inplace_merge.h>
1063#include <__algorithm/is_heap.h>
1064#include <__algorithm/is_heap_until.h>
1065#include <__algorithm/is_partitioned.h>
1066#include <__algorithm/is_permutation.h>
1067#include <__algorithm/is_sorted.h>
1068#include <__algorithm/is_sorted_until.h>
Christopher Di Bella6adbc832021-06-05 02:47:471069#include <__algorithm/iter_swap.h>
Louis Dionne134723e2021-06-17 15:30:111070#include <__algorithm/lexicographical_compare.h>
1071#include <__algorithm/lower_bound.h>
1072#include <__algorithm/make_heap.h>
1073#include <__algorithm/max.h>
1074#include <__algorithm/max_element.h>
1075#include <__algorithm/merge.h>
1076#include <__algorithm/min.h>
1077#include <__algorithm/min_element.h>
Nikolas Klauser807766b2022-02-21 21:48:361078#include <__algorithm/min_max_result.h>
Louis Dionne134723e2021-06-17 15:30:111079#include <__algorithm/minmax.h>
1080#include <__algorithm/minmax_element.h>
1081#include <__algorithm/mismatch.h>
1082#include <__algorithm/move.h>
1083#include <__algorithm/move_backward.h>
1084#include <__algorithm/next_permutation.h>
1085#include <__algorithm/none_of.h>
1086#include <__algorithm/nth_element.h>
1087#include <__algorithm/partial_sort.h>
1088#include <__algorithm/partial_sort_copy.h>
1089#include <__algorithm/partition.h>
1090#include <__algorithm/partition_copy.h>
1091#include <__algorithm/partition_point.h>
1092#include <__algorithm/pop_heap.h>
1093#include <__algorithm/prev_permutation.h>
1094#include <__algorithm/push_heap.h>
Nikolas Klauser0e3dc1a2022-05-26 14:42:461095#include <__algorithm/ranges_all_of.h>
1096#include <__algorithm/ranges_any_of.h>
Nikolas Klauser81715862022-06-05 19:15:161097#include <__algorithm/ranges_binary_search.h>
Nikolas Klauser1d837502022-04-15 11:43:401098#include <__algorithm/ranges_copy.h>
1099#include <__algorithm/ranges_copy_backward.h>
1100#include <__algorithm/ranges_copy_if.h>
1101#include <__algorithm/ranges_copy_n.h>
Nikolas Klauser1306b102022-04-07 11:02:021102#include <__algorithm/ranges_count.h>
1103#include <__algorithm/ranges_count_if.h>
Nikolas Klauser569d6632022-05-25 09:09:431104#include <__algorithm/ranges_equal.h>
Nikolas Klauser7af89a32022-05-21 16:26:291105#include <__algorithm/ranges_fill.h>
1106#include <__algorithm/ranges_fill_n.h>
Nikolas Klauseree0f8c42022-03-12 00:45:351107#include <__algorithm/ranges_find.h>
1108#include <__algorithm/ranges_find_if.h>
1109#include <__algorithm/ranges_find_if_not.h>
Nikolas Klauser80045e92022-05-04 18:27:071110#include <__algorithm/ranges_for_each.h>
1111#include <__algorithm/ranges_for_each_n.h>
Nikolas Klauser37ba1b92022-05-04 12:19:091112#include <__algorithm/ranges_is_partitioned.h>
Nikolas Klauser11e3ad22022-05-26 14:08:551113#include <__algorithm/ranges_is_sorted.h>
1114#include <__algorithm/ranges_is_sorted_until.h>
Nikolas Klauser81715862022-06-05 19:15:161115#include <__algorithm/ranges_lower_bound.h>
Nikolas Klausere476df52022-04-03 07:17:011116#include <__algorithm/ranges_max.h>
Nikolas Klauser205557c2022-03-07 16:01:521117#include <__algorithm/ranges_max_element.h>
Nikolas Klauserf83d8332022-03-18 01:57:081118#include <__algorithm/ranges_min.h>
Nikolas Klauser3b470d12022-02-11 12:11:571119#include <__algorithm/ranges_min_element.h>
Nikolas Klauser58d9ab72022-04-13 20:59:091120#include <__algorithm/ranges_minmax.h>
1121#include <__algorithm/ranges_minmax_element.h>
Nikolas Klauserc2cd15a2022-03-08 22:12:351122#include <__algorithm/ranges_mismatch.h>
Nikolas Klauser0e3dc1a2022-05-26 14:42:461123#include <__algorithm/ranges_none_of.h>
Nikolas Klauser1d1a1912022-05-24 08:32:501124#include <__algorithm/ranges_reverse.h>
Nikolas Klauser9d905312022-02-10 12:33:031125#include <__algorithm/ranges_swap_ranges.h>
Nikolas Klauser3ba85482022-04-05 09:05:361126#include <__algorithm/ranges_transform.h>
Nikolas Klauser81715862022-06-05 19:15:161127#include <__algorithm/ranges_upper_bound.h>
Louis Dionne134723e2021-06-17 15:30:111128#include <__algorithm/remove.h>
1129#include <__algorithm/remove_copy.h>
1130#include <__algorithm/remove_copy_if.h>
1131#include <__algorithm/remove_if.h>
1132#include <__algorithm/replace.h>
1133#include <__algorithm/replace_copy.h>
1134#include <__algorithm/replace_copy_if.h>
1135#include <__algorithm/replace_if.h>
1136#include <__algorithm/reverse.h>
1137#include <__algorithm/reverse_copy.h>
1138#include <__algorithm/rotate.h>
1139#include <__algorithm/rotate_copy.h>
1140#include <__algorithm/sample.h>
1141#include <__algorithm/search.h>
1142#include <__algorithm/search_n.h>
1143#include <__algorithm/set_difference.h>
1144#include <__algorithm/set_intersection.h>
1145#include <__algorithm/set_symmetric_difference.h>
1146#include <__algorithm/set_union.h>
1147#include <__algorithm/shift_left.h>
1148#include <__algorithm/shift_right.h>
1149#include <__algorithm/shuffle.h>
1150#include <__algorithm/sift_down.h>
1151#include <__algorithm/sort.h>
1152#include <__algorithm/sort_heap.h>
1153#include <__algorithm/stable_partition.h>
1154#include <__algorithm/stable_sort.h>
Christopher Di Bella6adbc832021-06-05 02:47:471155#include <__algorithm/swap_ranges.h>
Louis Dionne134723e2021-06-17 15:30:111156#include <__algorithm/transform.h>
Louis Dionne134723e2021-06-17 15:30:111157#include <__algorithm/unique.h>
Arthur O'Dwyer4d81a462022-01-07 14:45:051158#include <__algorithm/unique_copy.h>
Louis Dionne134723e2021-06-17 15:30:111159#include <__algorithm/unwrap_iter.h>
1160#include <__algorithm/upper_bound.h>
Eric Fiselierc1bd9192014-08-10 23:53:081161
Howard Hinnant073458b2011-10-17 20:05:101162#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Arthur O'Dwyerfa6b9e42022-02-02 01:16:401163# pragma GCC system_header
Howard Hinnant073458b2011-10-17 20:05:101164#endif
Howard Hinnant3e519522010-05-11 19:42:161165
Louis Dionne0a06eb92019-08-05 18:29:141166#if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17
Louis Dionne95689242019-08-06 21:11:241167# include <__pstl_algorithm>
Louis Dionne0a06eb92019-08-05 18:29:141168#endif
1169
Louis Dionne4cd6ca12021-04-20 16:03:321170#endif // _LIBCPP_ALGORITHM