blob: aa2191464a83014efe5408bb8c8b8f1b079d44e4 [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 Klauserf74be4e2022-01-14 02:55:51 +0100308}
309
Marshall Clowd607fdb2018-01-15 17:20:36 +0000310 constexpr bool // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000311 all_of(InputIterator first, InputIterator last, Predicate pred);
312
313template <class InputIterator, class Predicate>
Marshall Clowd607fdb2018-01-15 17:20:36 +0000314 constexpr bool // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000315 any_of(InputIterator first, InputIterator last, Predicate pred);
316
317template <class InputIterator, class Predicate>
Marshall Clowd607fdb2018-01-15 17:20:36 +0000318 constexpr bool // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000319 none_of(InputIterator first, InputIterator last, Predicate pred);
320
321template <class InputIterator, class Function>
Marshall Clow5492c8a2018-01-22 20:44:33 +0000322 constexpr Function // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000323 for_each(InputIterator first, InputIterator last, Function f);
324
Marshall Clowde0169c2017-05-25 02:29:54 +0000325template<class InputIterator, class Size, class Function>
Marshall Clow5492c8a2018-01-22 20:44:33 +0000326 constexpr InputIterator // constexpr in C++20
327 for_each_n(InputIterator first, Size n, Function f); // C++17
Marshall Clowde0169c2017-05-25 02:29:54 +0000328
Howard Hinnantc51e1022010-05-11 19:42:16 +0000329template <class InputIterator, class T>
Marshall Clowee0161e2018-01-15 19:26:05 +0000330 constexpr InputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000331 find(InputIterator first, InputIterator last, const T& value);
332
333template <class InputIterator, class Predicate>
Marshall Clowee0161e2018-01-15 19:26:05 +0000334 constexpr InputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000335 find_if(InputIterator first, InputIterator last, Predicate pred);
336
337template<class InputIterator, class Predicate>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500338 constexpr InputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000339 find_if_not(InputIterator first, InputIterator last, Predicate pred);
340
341template <class ForwardIterator1, class ForwardIterator2>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500342 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000343 find_end(ForwardIterator1 first1, ForwardIterator1 last1,
344 ForwardIterator2 first2, ForwardIterator2 last2);
345
346template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500347 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000348 find_end(ForwardIterator1 first1, ForwardIterator1 last1,
349 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
350
351template <class ForwardIterator1, class ForwardIterator2>
Marshall Clowee0161e2018-01-15 19:26:05 +0000352 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000353 find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
354 ForwardIterator2 first2, ForwardIterator2 last2);
355
356template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clowee0161e2018-01-15 19:26:05 +0000357 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000358 find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
359 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
360
361template <class ForwardIterator>
Marshall Clowee0161e2018-01-15 19:26:05 +0000362 constexpr ForwardIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000363 adjacent_find(ForwardIterator first, ForwardIterator last);
364
365template <class ForwardIterator, class BinaryPredicate>
Marshall Clowee0161e2018-01-15 19:26:05 +0000366 constexpr ForwardIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000367 adjacent_find(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
368
369template <class InputIterator, class T>
Marshall Clow3c0558f2018-01-15 19:40:34 +0000370 constexpr typename iterator_traits<InputIterator>::difference_type // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000371 count(InputIterator first, InputIterator last, const T& value);
372
373template <class InputIterator, class Predicate>
Marshall Clow3c0558f2018-01-15 19:40:34 +0000374 constexpr typename iterator_traits<InputIterator>::difference_type // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000375 count_if(InputIterator first, InputIterator last, Predicate pred);
376
377template <class InputIterator1, class InputIterator2>
Marshall Clow30bf3022018-01-16 02:04:10 +0000378 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000379 mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
380
Marshall Clow96b42b22013-05-09 21:14:23 +0000381template <class InputIterator1, class InputIterator2>
Marshall Clow30bf3022018-01-16 02:04:10 +0000382 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Aditya Kumar3a0179a2016-08-25 11:52:38 +0000383 mismatch(InputIterator1 first1, InputIterator1 last1,
Marshall Clow96b42b22013-05-09 21:14:23 +0000384 InputIterator2 first2, InputIterator2 last2); // **C++14**
385
Howard Hinnantc51e1022010-05-11 19:42:16 +0000386template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow30bf3022018-01-16 02:04:10 +0000387 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000388 mismatch(InputIterator1 first1, InputIterator1 last1,
389 InputIterator2 first2, BinaryPredicate pred);
390
Marshall Clow96b42b22013-05-09 21:14:23 +0000391template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow30bf3022018-01-16 02:04:10 +0000392 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Marshall Clow96b42b22013-05-09 21:14:23 +0000393 mismatch(InputIterator1 first1, InputIterator1 last1,
394 InputIterator2 first2, InputIterator2 last2,
395 BinaryPredicate pred); // **C++14**
396
Howard Hinnantc51e1022010-05-11 19:42:16 +0000397template <class InputIterator1, class InputIterator2>
Marshall Clow30bf3022018-01-16 02:04:10 +0000398 constexpr bool // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000399 equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
400
Marshall Clow96b42b22013-05-09 21:14:23 +0000401template <class InputIterator1, class InputIterator2>
Marshall Clow30bf3022018-01-16 02:04:10 +0000402 constexpr bool // constexpr in C++20
Aditya Kumar3a0179a2016-08-25 11:52:38 +0000403 equal(InputIterator1 first1, InputIterator1 last1,
Marshall Clow96b42b22013-05-09 21:14:23 +0000404 InputIterator2 first2, InputIterator2 last2); // **C++14**
405
Howard Hinnantc51e1022010-05-11 19:42:16 +0000406template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow30bf3022018-01-16 02:04:10 +0000407 constexpr bool // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000408 equal(InputIterator1 first1, InputIterator1 last1,
409 InputIterator2 first2, BinaryPredicate pred);
410
Marshall Clow96b42b22013-05-09 21:14:23 +0000411template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow30bf3022018-01-16 02:04:10 +0000412 constexpr bool // constexpr in C++20
Marshall Clow96b42b22013-05-09 21:14:23 +0000413 equal(InputIterator1 first1, InputIterator1 last1,
414 InputIterator2 first2, InputIterator2 last2,
415 BinaryPredicate pred); // **C++14**
416
Howard Hinnantc51e1022010-05-11 19:42:16 +0000417template<class ForwardIterator1, class ForwardIterator2>
Marshall Clow96d050a2018-01-15 16:16:32 +0000418 constexpr bool // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000419 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
420 ForwardIterator2 first2);
421
Marshall Clow96b42b22013-05-09 21:14:23 +0000422template<class ForwardIterator1, class ForwardIterator2>
Marshall Clow96d050a2018-01-15 16:16:32 +0000423 constexpr bool // constexpr in C++20
Marshall Clow96b42b22013-05-09 21:14:23 +0000424 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
425 ForwardIterator2 first2, ForwardIterator2 last2); // **C++14**
426
Howard Hinnantc51e1022010-05-11 19:42:16 +0000427template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow96d050a2018-01-15 16:16:32 +0000428 constexpr bool // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000429 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
430 ForwardIterator2 first2, BinaryPredicate pred);
431
Marshall Clow96b42b22013-05-09 21:14:23 +0000432template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow96d050a2018-01-15 16:16:32 +0000433 constexpr bool // constexpr in C++20
Marshall Clow96b42b22013-05-09 21:14:23 +0000434 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
435 ForwardIterator2 first2, ForwardIterator2 last2,
436 BinaryPredicate pred); // **C++14**
437
Howard Hinnantc51e1022010-05-11 19:42:16 +0000438template <class ForwardIterator1, class ForwardIterator2>
Marshall Clow323fc5b2018-01-16 15:48:27 +0000439 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000440 search(ForwardIterator1 first1, ForwardIterator1 last1,
441 ForwardIterator2 first2, ForwardIterator2 last2);
442
443template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow323fc5b2018-01-16 15:48:27 +0000444 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000445 search(ForwardIterator1 first1, ForwardIterator1 last1,
446 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
447
448template <class ForwardIterator, class Size, class T>
Marshall Clow323fc5b2018-01-16 15:48:27 +0000449 constexpr ForwardIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000450 search_n(ForwardIterator first, ForwardIterator last, Size count, const T& value);
451
452template <class ForwardIterator, class Size, class T, class BinaryPredicate>
Marshall Clow323fc5b2018-01-16 15:48:27 +0000453 constexpr ForwardIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000454 search_n(ForwardIterator first, ForwardIterator last,
455 Size count, const T& value, BinaryPredicate pred);
456
457template <class InputIterator, class OutputIterator>
Louis Dionne65b433b2019-11-06 12:02:41 +0000458 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000459 copy(InputIterator first, InputIterator last, OutputIterator result);
460
461template<class InputIterator, class OutputIterator, class Predicate>
Louis Dionne65b433b2019-11-06 12:02:41 +0000462 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000463 copy_if(InputIterator first, InputIterator last,
464 OutputIterator result, Predicate pred);
465
466template<class InputIterator, class Size, class OutputIterator>
Louis Dionne65b433b2019-11-06 12:02:41 +0000467 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000468 copy_n(InputIterator first, Size n, OutputIterator result);
469
470template <class BidirectionalIterator1, class BidirectionalIterator2>
Louis Dionne65b433b2019-11-06 12:02:41 +0000471 constexpr BidirectionalIterator2 // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000472 copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last,
473 BidirectionalIterator2 result);
474
475template <class ForwardIterator1, class ForwardIterator2>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500476 constexpr ForwardIterator2 // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000477 swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2);
478
Nikolas Klauser4ceab5f2022-02-10 13:33:03 +0100479template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2>
480 requires indirectly_swappable<I1, I2>
481 constexpr ranges::swap_ranges_result<I1, I2>
482 ranges::swap_ranges(I1 first1, S1 last1, I2 first2, S2 last2);
483
484template<input_range R1, input_range R2>
485 requires indirectly_swappable<iterator_t<R1>, iterator_t<R2>>
486 constexpr ranges::swap_ranges_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>>
487 ranges::swap_ranges(R1&& r1, R2&& r2);
488
Howard Hinnantc51e1022010-05-11 19:42:16 +0000489template <class ForwardIterator1, class ForwardIterator2>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500490 constexpr void // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000491 iter_swap(ForwardIterator1 a, ForwardIterator2 b);
492
493template <class InputIterator, class OutputIterator, class UnaryOperation>
Marshall Clow31427c62018-01-19 17:45:39 +0000494 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000495 transform(InputIterator first, InputIterator last, OutputIterator result, UnaryOperation op);
496
497template <class InputIterator1, class InputIterator2, class OutputIterator, class BinaryOperation>
Marshall Clow31427c62018-01-19 17:45:39 +0000498 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000499 transform(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2,
500 OutputIterator result, BinaryOperation binary_op);
501
502template <class ForwardIterator, class T>
Marshall Clow01bbbd22018-01-19 18:07:29 +0000503 constexpr void // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000504 replace(ForwardIterator first, ForwardIterator last, const T& old_value, const T& new_value);
505
506template <class ForwardIterator, class Predicate, class T>
Marshall Clow01bbbd22018-01-19 18:07:29 +0000507 constexpr void // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000508 replace_if(ForwardIterator first, ForwardIterator last, Predicate pred, const T& new_value);
509
510template <class InputIterator, class OutputIterator, class T>
Marshall Clow01bbbd22018-01-19 18:07:29 +0000511 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000512 replace_copy(InputIterator first, InputIterator last, OutputIterator result,
513 const T& old_value, const T& new_value);
514
515template <class InputIterator, class OutputIterator, class Predicate, class T>
Marshall Clow01bbbd22018-01-19 18:07:29 +0000516 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000517 replace_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred, const T& new_value);
518
519template <class ForwardIterator, class T>
Marshall Clowe9cdc5c2018-01-20 20:14:32 +0000520 constexpr void // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000521 fill(ForwardIterator first, ForwardIterator last, const T& value);
522
523template <class OutputIterator, class Size, class T>
Marshall Clowe9cdc5c2018-01-20 20:14:32 +0000524 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000525 fill_n(OutputIterator first, Size n, const T& value);
526
527template <class ForwardIterator, class Generator>
Marshall Clowe9cdc5c2018-01-20 20:14:32 +0000528 constexpr void // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000529 generate(ForwardIterator first, ForwardIterator last, Generator gen);
530
531template <class OutputIterator, class Size, class Generator>
Marshall Clowe9cdc5c2018-01-20 20:14:32 +0000532 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000533 generate_n(OutputIterator first, Size n, Generator gen);
534
535template <class ForwardIterator, class T>
Marshall Clow7c0fbd82018-01-22 21:43:04 +0000536 constexpr ForwardIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000537 remove(ForwardIterator first, ForwardIterator last, const T& value);
538
539template <class ForwardIterator, class Predicate>
Marshall Clow7c0fbd82018-01-22 21:43:04 +0000540 constexpr ForwardIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000541 remove_if(ForwardIterator first, ForwardIterator last, Predicate pred);
542
543template <class InputIterator, class OutputIterator, class T>
Marshall Clow7c0fbd82018-01-22 21:43:04 +0000544 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000545 remove_copy(InputIterator first, InputIterator last, OutputIterator result, const T& value);
546
547template <class InputIterator, class OutputIterator, class Predicate>
Marshall Clow7c0fbd82018-01-22 21:43:04 +0000548 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000549 remove_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred);
550
551template <class ForwardIterator>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500552 constexpr ForwardIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000553 unique(ForwardIterator first, ForwardIterator last);
554
555template <class ForwardIterator, class BinaryPredicate>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500556 constexpr ForwardIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000557 unique(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
558
559template <class InputIterator, class OutputIterator>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500560 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000561 unique_copy(InputIterator first, InputIterator last, OutputIterator result);
562
563template <class InputIterator, class OutputIterator, class BinaryPredicate>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500564 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000565 unique_copy(InputIterator first, InputIterator last, OutputIterator result, BinaryPredicate pred);
566
567template <class BidirectionalIterator>
Arthur O'Dwyere50e7472020-12-17 00:01:08 -0500568 constexpr void // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000569 reverse(BidirectionalIterator first, BidirectionalIterator last);
570
571template <class BidirectionalIterator, class OutputIterator>
Marshall Clow7c0fbd82018-01-22 21:43:04 +0000572 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000573 reverse_copy(BidirectionalIterator first, BidirectionalIterator last, OutputIterator result);
574
575template <class ForwardIterator>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500576 constexpr ForwardIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000577 rotate(ForwardIterator first, ForwardIterator middle, ForwardIterator last);
578
579template <class ForwardIterator, class OutputIterator>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500580 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000581 rotate_copy(ForwardIterator first, ForwardIterator middle, ForwardIterator last, OutputIterator result);
582
583template <class RandomAccessIterator>
584 void
Marshall Clowfac06e52017-03-23 13:43:37 +0000585 random_shuffle(RandomAccessIterator first, RandomAccessIterator last); // deprecated in C++14, removed in C++17
Howard Hinnantc51e1022010-05-11 19:42:16 +0000586
587template <class RandomAccessIterator, class RandomNumberGenerator>
588 void
Marshall Clow83f35392014-03-03 06:14:19 +0000589 random_shuffle(RandomAccessIterator first, RandomAccessIterator last,
Marshall Clowfac06e52017-03-23 13:43:37 +0000590 RandomNumberGenerator& rand); // deprecated in C++14, removed in C++17
Howard Hinnantc51e1022010-05-11 19:42:16 +0000591
Eric Fiselier1208fcd2016-08-28 22:14:37 +0000592template<class PopulationIterator, class SampleIterator,
593 class Distance, class UniformRandomBitGenerator>
594 SampleIterator sample(PopulationIterator first, PopulationIterator last,
595 SampleIterator out, Distance n,
596 UniformRandomBitGenerator&& g); // C++17
597
Howard Hinnant578ac0f2010-05-26 17:49:34 +0000598template<class RandomAccessIterator, class UniformRandomNumberGenerator>
599 void shuffle(RandomAccessIterator first, RandomAccessIterator last,
Howard Hinnanta5e71782010-11-18 01:47:02 +0000600 UniformRandomNumberGenerator&& g);
Howard Hinnant578ac0f2010-05-26 17:49:34 +0000601
Arthur O'Dwyercea050d2020-12-26 01:39:03 -0500602template<class ForwardIterator>
603 constexpr ForwardIterator
604 shift_left(ForwardIterator first, ForwardIterator last,
605 typename iterator_traits<ForwardIterator>::difference_type n); // C++20
606
607template<class ForwardIterator>
608 constexpr ForwardIterator
609 shift_right(ForwardIterator first, ForwardIterator last,
610 typename iterator_traits<ForwardIterator>::difference_type n); // C++20
611
Howard Hinnantc51e1022010-05-11 19:42:16 +0000612template <class InputIterator, class Predicate>
Marshall Clow96d050a2018-01-15 16:16:32 +0000613 constexpr bool // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000614 is_partitioned(InputIterator first, InputIterator last, Predicate pred);
615
616template <class ForwardIterator, class Predicate>
Arthur O'Dwyere50e7472020-12-17 00:01:08 -0500617 constexpr ForwardIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000618 partition(ForwardIterator first, ForwardIterator last, Predicate pred);
619
620template <class InputIterator, class OutputIterator1,
621 class OutputIterator2, class Predicate>
Marshall Clow5492c8a2018-01-22 20:44:33 +0000622 constexpr pair<OutputIterator1, OutputIterator2> // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000623 partition_copy(InputIterator first, InputIterator last,
624 OutputIterator1 out_true, OutputIterator2 out_false,
625 Predicate pred);
626
627template <class ForwardIterator, class Predicate>
628 ForwardIterator
629 stable_partition(ForwardIterator first, ForwardIterator last, Predicate pred);
630
631template<class ForwardIterator, class Predicate>
Marshall Clowe00916c2018-01-16 02:34:41 +0000632 constexpr ForwardIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000633 partition_point(ForwardIterator first, ForwardIterator last, Predicate pred);
634
635template <class ForwardIterator>
Marshall Clow96d050a2018-01-15 16:16:32 +0000636 constexpr bool // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000637 is_sorted(ForwardIterator first, ForwardIterator last);
638
639template <class ForwardIterator, class Compare>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500640 constexpr bool // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000641 is_sorted(ForwardIterator first, ForwardIterator last, Compare comp);
642
643template<class ForwardIterator>
Marshall Clow3c0558f2018-01-15 19:40:34 +0000644 constexpr ForwardIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000645 is_sorted_until(ForwardIterator first, ForwardIterator last);
646
647template <class ForwardIterator, class Compare>
Marshall Clow3c0558f2018-01-15 19:40:34 +0000648 constexpr ForwardIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000649 is_sorted_until(ForwardIterator first, ForwardIterator last, Compare comp);
650
651template <class RandomAccessIterator>
Arthur O'Dwyer1bb0f672020-12-20 15:21:42 -0500652 constexpr void // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000653 sort(RandomAccessIterator first, RandomAccessIterator last);
654
655template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer1bb0f672020-12-20 15:21:42 -0500656 constexpr void // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000657 sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
658
659template <class RandomAccessIterator>
660 void
661 stable_sort(RandomAccessIterator first, RandomAccessIterator last);
662
663template <class RandomAccessIterator, class Compare>
664 void
665 stable_sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
666
667template <class RandomAccessIterator>
Arthur O'Dwyer2dfea5d2020-12-17 00:26:18 -0500668 constexpr void // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000669 partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last);
670
671template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer2dfea5d2020-12-17 00:26:18 -0500672 constexpr void // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000673 partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last, Compare comp);
674
675template <class InputIterator, class RandomAccessIterator>
Arthur O'Dwyer2dfea5d2020-12-17 00:26:18 -0500676 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000677 partial_sort_copy(InputIterator first, InputIterator last,
678 RandomAccessIterator result_first, RandomAccessIterator result_last);
679
680template <class InputIterator, class RandomAccessIterator, class Compare>
Arthur O'Dwyer2dfea5d2020-12-17 00:26:18 -0500681 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000682 partial_sort_copy(InputIterator first, InputIterator last,
683 RandomAccessIterator result_first, RandomAccessIterator result_last, Compare comp);
684
685template <class RandomAccessIterator>
Arthur O'Dwyer4f5717b2021-02-04 18:12:52 -0500686 constexpr void // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000687 nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last);
688
689template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer4f5717b2021-02-04 18:12:52 -0500690 constexpr void // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000691 nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last, Compare comp);
692
693template <class ForwardIterator, class T>
Marshall Clowe00916c2018-01-16 02:34:41 +0000694 constexpr ForwardIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000695 lower_bound(ForwardIterator first, ForwardIterator last, const T& value);
696
697template <class ForwardIterator, class T, class Compare>
Marshall Clowe00916c2018-01-16 02:34:41 +0000698 constexpr ForwardIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000699 lower_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
700
701template <class ForwardIterator, class T>
Marshall Clowe00916c2018-01-16 02:34:41 +0000702 constexpr ForwardIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000703 upper_bound(ForwardIterator first, ForwardIterator last, const T& value);
704
705template <class ForwardIterator, class T, class Compare>
Marshall Clowe00916c2018-01-16 02:34:41 +0000706 constexpr ForwardIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000707 upper_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
708
709template <class ForwardIterator, class T>
Marshall Clowe00916c2018-01-16 02:34:41 +0000710 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000711 equal_range(ForwardIterator first, ForwardIterator last, const T& value);
712
713template <class ForwardIterator, class T, class Compare>
Marshall Clowe00916c2018-01-16 02:34:41 +0000714 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000715 equal_range(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
716
717template <class ForwardIterator, class T>
Marshall Clowe00916c2018-01-16 02:34:41 +0000718 constexpr bool // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000719 binary_search(ForwardIterator first, ForwardIterator last, const T& value);
720
721template <class ForwardIterator, class T, class Compare>
Marshall Clowc0b7f972018-01-22 23:10:40 +0000722 constexpr bool // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000723 binary_search(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
724
725template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer5afc5692020-12-04 13:47:12 -0500726 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000727 merge(InputIterator1 first1, InputIterator1 last1,
728 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
729
730template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer5afc5692020-12-04 13:47:12 -0500731 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000732 merge(InputIterator1 first1, InputIterator1 last1,
733 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
734
735template <class BidirectionalIterator>
736 void
737 inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last);
738
739template <class BidirectionalIterator, class Compare>
740 void
741 inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last, Compare comp);
742
743template <class InputIterator1, class InputIterator2>
Marshall Clowc0b7f972018-01-22 23:10:40 +0000744 constexpr bool // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000745 includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
746
747template <class InputIterator1, class InputIterator2, class Compare>
Marshall Clowc0b7f972018-01-22 23:10:40 +0000748 constexpr bool // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000749 includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, Compare comp);
750
751template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer5afc5692020-12-04 13:47:12 -0500752 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000753 set_union(InputIterator1 first1, InputIterator1 last1,
754 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
755
756template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer5afc5692020-12-04 13:47:12 -0500757 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000758 set_union(InputIterator1 first1, InputIterator1 last1,
759 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
760
761template <class InputIterator1, class InputIterator2, class OutputIterator>
Marshall Clowc0b7f972018-01-22 23:10:40 +0000762 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000763 set_intersection(InputIterator1 first1, InputIterator1 last1,
764 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
765
766template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Marshall Clowc0b7f972018-01-22 23:10:40 +0000767 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000768 set_intersection(InputIterator1 first1, InputIterator1 last1,
769 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
770
771template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer5afc5692020-12-04 13:47:12 -0500772 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000773 set_difference(InputIterator1 first1, InputIterator1 last1,
774 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
775
776template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer5afc5692020-12-04 13:47:12 -0500777 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000778 set_difference(InputIterator1 first1, InputIterator1 last1,
779 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
780
781template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer5afc5692020-12-04 13:47:12 -0500782 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000783 set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
784 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
785
786template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer5afc5692020-12-04 13:47:12 -0500787 constexpr OutputIterator // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000788 set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
789 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
790
791template <class RandomAccessIterator>
Arthur O'Dwyer2dfea5d2020-12-17 00:26:18 -0500792 constexpr void // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000793 push_heap(RandomAccessIterator first, RandomAccessIterator last);
794
795template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer2dfea5d2020-12-17 00:26:18 -0500796 constexpr void // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000797 push_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
798
799template <class RandomAccessIterator>
Arthur O'Dwyer2dfea5d2020-12-17 00:26:18 -0500800 constexpr void // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000801 pop_heap(RandomAccessIterator first, RandomAccessIterator last);
802
803template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer2dfea5d2020-12-17 00:26:18 -0500804 constexpr void // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000805 pop_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
806
807template <class RandomAccessIterator>
Arthur O'Dwyer2dfea5d2020-12-17 00:26:18 -0500808 constexpr void // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000809 make_heap(RandomAccessIterator first, RandomAccessIterator last);
810
811template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer2dfea5d2020-12-17 00:26:18 -0500812 constexpr void // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000813 make_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
814
815template <class RandomAccessIterator>
Arthur O'Dwyer2dfea5d2020-12-17 00:26:18 -0500816 constexpr void // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000817 sort_heap(RandomAccessIterator first, RandomAccessIterator last);
818
819template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer2dfea5d2020-12-17 00:26:18 -0500820 constexpr void // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000821 sort_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
822
Howard Hinnant3b6579a2010-08-22 00:02:43 +0000823template <class RandomAccessIterator>
Marshall Clow96d050a2018-01-15 16:16:32 +0000824 constexpr bool // constexpr in C++20
Howard Hinnant3b6579a2010-08-22 00:02:43 +0000825 is_heap(RandomAccessIterator first, RandomAccessiterator last);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000826
Howard Hinnant3b6579a2010-08-22 00:02:43 +0000827template <class RandomAccessIterator, class Compare>
Marshall Clow96d050a2018-01-15 16:16:32 +0000828 constexpr bool // constexpr in C++20
Howard Hinnant3b6579a2010-08-22 00:02:43 +0000829 is_heap(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000830
Howard Hinnant3b6579a2010-08-22 00:02:43 +0000831template <class RandomAccessIterator>
Marshall Clow96d050a2018-01-15 16:16:32 +0000832 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnant3b6579a2010-08-22 00:02:43 +0000833 is_heap_until(RandomAccessIterator first, RandomAccessiterator last);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000834
Howard Hinnant3b6579a2010-08-22 00:02:43 +0000835template <class RandomAccessIterator, class Compare>
Marshall Clow96d050a2018-01-15 16:16:32 +0000836 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnant3b6579a2010-08-22 00:02:43 +0000837 is_heap_until(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000838
Howard Hinnantb120e7a2010-08-21 20:10:01 +0000839template <class ForwardIterator>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500840 constexpr ForwardIterator // constexpr in C++14
841 min_element(ForwardIterator first, ForwardIterator last);
Howard Hinnantb120e7a2010-08-21 20:10:01 +0000842
843template <class ForwardIterator, class Compare>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500844 constexpr ForwardIterator // constexpr in C++14
845 min_element(ForwardIterator first, ForwardIterator last, Compare comp);
Howard Hinnantb120e7a2010-08-21 20:10:01 +0000846
Howard Hinnantc51e1022010-05-11 19:42:16 +0000847template <class T>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500848 constexpr const T& // constexpr in C++14
849 min(const T& a, const T& b);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000850
851template <class T, class Compare>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500852 constexpr const T& // constexpr in C++14
853 min(const T& a, const T& b, Compare comp);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000854
Howard Hinnantb120e7a2010-08-21 20:10:01 +0000855template<class T>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500856 constexpr T // constexpr in C++14
857 min(initializer_list<T> t);
Howard Hinnantb120e7a2010-08-21 20:10:01 +0000858
859template<class T, class Compare>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500860 constexpr T // constexpr in C++14
861 min(initializer_list<T> t, Compare comp);
Howard Hinnantb120e7a2010-08-21 20:10:01 +0000862
Marshall Clow3e18d0e2016-03-07 22:43:49 +0000863template<class T>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500864 constexpr const T& clamp(const T& v, const T& lo, const T& hi); // C++17
Marshall Clow3e18d0e2016-03-07 22:43:49 +0000865
866template<class T, class Compare>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500867 constexpr const T& clamp(const T& v, const T& lo, const T& hi, Compare comp); // C++17
Marshall Clow3e18d0e2016-03-07 22:43:49 +0000868
Howard Hinnantb120e7a2010-08-21 20:10:01 +0000869template <class ForwardIterator>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500870 constexpr ForwardIterator // constexpr in C++14
871 max_element(ForwardIterator first, ForwardIterator last);
Howard Hinnantb120e7a2010-08-21 20:10:01 +0000872
873template <class ForwardIterator, class Compare>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500874 constexpr ForwardIterator // constexpr in C++14
875 max_element(ForwardIterator first, ForwardIterator last, Compare comp);
Howard Hinnantb120e7a2010-08-21 20:10:01 +0000876
Howard Hinnantc51e1022010-05-11 19:42:16 +0000877template <class T>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500878 constexpr const T& // constexpr in C++14
879 max(const T& a, const T& b);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000880
881template <class T, class Compare>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500882 constexpr const T& // constexpr in C++14
883 max(const T& a, const T& b, Compare comp);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000884
Howard Hinnantb120e7a2010-08-21 20:10:01 +0000885template<class T>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500886 constexpr T // constexpr in C++14
887 max(initializer_list<T> t);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000888
Howard Hinnantb120e7a2010-08-21 20:10:01 +0000889template<class T, class Compare>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500890 constexpr T // constexpr in C++14
891 max(initializer_list<T> t, Compare comp);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000892
Howard Hinnantb120e7a2010-08-21 20:10:01 +0000893template<class ForwardIterator>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500894 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++14
895 minmax_element(ForwardIterator first, ForwardIterator last);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000896
Howard Hinnantb120e7a2010-08-21 20:10:01 +0000897template<class ForwardIterator, class Compare>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500898 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++14
899 minmax_element(ForwardIterator first, ForwardIterator last, Compare comp);
Howard Hinnantb120e7a2010-08-21 20:10:01 +0000900
901template<class T>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500902 constexpr pair<const T&, const T&> // constexpr in C++14
903 minmax(const T& a, const T& b);
Howard Hinnantb120e7a2010-08-21 20:10:01 +0000904
905template<class T, class Compare>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500906 constexpr pair<const T&, const T&> // constexpr in C++14
907 minmax(const T& a, const T& b, Compare comp);
Howard Hinnantb120e7a2010-08-21 20:10:01 +0000908
909template<class T>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500910 constexpr pair<T, T> // constexpr in C++14
911 minmax(initializer_list<T> t);
Howard Hinnantb120e7a2010-08-21 20:10:01 +0000912
913template<class T, class Compare>
Arthur O'Dwyer20353a72020-12-02 20:02:18 -0500914 constexpr pair<T, T> // constexpr in C++14
915 minmax(initializer_list<T> t, Compare comp);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000916
917template <class InputIterator1, class InputIterator2>
Marshall Clow5492c8a2018-01-22 20:44:33 +0000918 constexpr bool // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000919 lexicographical_compare(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
920
921template <class InputIterator1, class InputIterator2, class Compare>
Marshall Clow5492c8a2018-01-22 20:44:33 +0000922 constexpr bool // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000923 lexicographical_compare(InputIterator1 first1, InputIterator1 last1,
924 InputIterator2 first2, InputIterator2 last2, Compare comp);
925
926template <class BidirectionalIterator>
Arthur O'Dwyere50e7472020-12-17 00:01:08 -0500927 constexpr bool // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000928 next_permutation(BidirectionalIterator first, BidirectionalIterator last);
929
930template <class BidirectionalIterator, class Compare>
Arthur O'Dwyere50e7472020-12-17 00:01:08 -0500931 constexpr bool // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000932 next_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
933
934template <class BidirectionalIterator>
Arthur O'Dwyere50e7472020-12-17 00:01:08 -0500935 constexpr bool // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000936 prev_permutation(BidirectionalIterator first, BidirectionalIterator last);
937
938template <class BidirectionalIterator, class Compare>
Arthur O'Dwyere50e7472020-12-17 00:01:08 -0500939 constexpr bool // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000940 prev_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000941} // std
942
943*/
944
Louis Dionneb4fce352022-03-25 12:55:36 -0400945#include <__assert> // all public C++ headers provide the assertion handler
Arthur O'Dwyer3693d7a2022-02-04 13:09:30 -0500946#include <__bits>
Howard Hinnantc51e1022010-05-11 19:42:16 +0000947#include <__config>
Louis Dionnea60dd872021-06-17 11:30:11 -0400948#include <__debug>
Howard Hinnant60e5cf42012-07-26 17:09:09 +0000949#include <cstddef>
Arthur O'Dwyeref181602021-05-19 11:57:04 -0400950#include <cstring>
Arthur O'Dwyeref181602021-05-19 11:57:04 -0400951#include <initializer_list>
952#include <iterator>
953#include <memory>
954#include <type_traits>
Marshall Clow0a1e7502018-09-12 19:41:40 +0000955#include <version>
Howard Hinnantea382952013-08-14 18:00:20 +0000956
Louis Dionnea60dd872021-06-17 11:30:11 -0400957#include <__algorithm/adjacent_find.h>
958#include <__algorithm/all_of.h>
959#include <__algorithm/any_of.h>
960#include <__algorithm/binary_search.h>
961#include <__algorithm/clamp.h>
962#include <__algorithm/comp.h>
963#include <__algorithm/comp_ref_type.h>
964#include <__algorithm/copy.h>
965#include <__algorithm/copy_backward.h>
966#include <__algorithm/copy_if.h>
967#include <__algorithm/copy_n.h>
968#include <__algorithm/count.h>
969#include <__algorithm/count_if.h>
970#include <__algorithm/equal.h>
971#include <__algorithm/equal_range.h>
Louis Dionnea60dd872021-06-17 11:30:11 -0400972#include <__algorithm/fill.h>
Arthur O'Dwyer65077c02022-01-07 09:45:05 -0500973#include <__algorithm/fill_n.h>
Louis Dionnea60dd872021-06-17 11:30:11 -0400974#include <__algorithm/find.h>
975#include <__algorithm/find_end.h>
976#include <__algorithm/find_first_of.h>
977#include <__algorithm/find_if.h>
978#include <__algorithm/find_if_not.h>
979#include <__algorithm/for_each.h>
980#include <__algorithm/for_each_n.h>
Louis Dionnea60dd872021-06-17 11:30:11 -0400981#include <__algorithm/generate.h>
Arthur O'Dwyer65077c02022-01-07 09:45:05 -0500982#include <__algorithm/generate_n.h>
Louis Dionnea60dd872021-06-17 11:30:11 -0400983#include <__algorithm/half_positive.h>
Nikolas Klauserdd5ad212022-02-21 23:07:02 +0100984#include <__algorithm/in_found_result.h>
Nikolas Klauser671b4752022-02-11 17:01:58 +0100985#include <__algorithm/in_fun_result.h>
Nikolas Klauser05e2cd82022-01-25 11:21:47 +0100986#include <__algorithm/in_in_out_result.h>
Nikolas Klauserf74be4e2022-01-14 02:55:51 +0100987#include <__algorithm/in_in_result.h>
Nikolas Klauser61ce8162022-02-03 02:17:03 +0100988#include <__algorithm/in_out_out_result.h>
Konstantin Varlamov74736812022-01-10 22:49:37 -0800989#include <__algorithm/in_out_result.h>
Louis Dionnea60dd872021-06-17 11:30:11 -0400990#include <__algorithm/includes.h>
991#include <__algorithm/inplace_merge.h>
992#include <__algorithm/is_heap.h>
993#include <__algorithm/is_heap_until.h>
994#include <__algorithm/is_partitioned.h>
995#include <__algorithm/is_permutation.h>
996#include <__algorithm/is_sorted.h>
997#include <__algorithm/is_sorted_until.h>
Christopher Di Bella41f26e82021-06-05 02:47:47 +0000998#include <__algorithm/iter_swap.h>
Louis Dionnea60dd872021-06-17 11:30:11 -0400999#include <__algorithm/lexicographical_compare.h>
1000#include <__algorithm/lower_bound.h>
1001#include <__algorithm/make_heap.h>
1002#include <__algorithm/max.h>
1003#include <__algorithm/max_element.h>
1004#include <__algorithm/merge.h>
1005#include <__algorithm/min.h>
1006#include <__algorithm/min_element.h>
Nikolas Klauser2e263162022-02-21 22:48:36 +01001007#include <__algorithm/min_max_result.h>
Louis Dionnea60dd872021-06-17 11:30:11 -04001008#include <__algorithm/minmax.h>
1009#include <__algorithm/minmax_element.h>
1010#include <__algorithm/mismatch.h>
1011#include <__algorithm/move.h>
1012#include <__algorithm/move_backward.h>
1013#include <__algorithm/next_permutation.h>
1014#include <__algorithm/none_of.h>
1015#include <__algorithm/nth_element.h>
1016#include <__algorithm/partial_sort.h>
1017#include <__algorithm/partial_sort_copy.h>
1018#include <__algorithm/partition.h>
1019#include <__algorithm/partition_copy.h>
1020#include <__algorithm/partition_point.h>
1021#include <__algorithm/pop_heap.h>
1022#include <__algorithm/prev_permutation.h>
1023#include <__algorithm/push_heap.h>
Nikolas Klauserd959d842022-04-15 13:43:40 +02001024#include <__algorithm/ranges_copy.h>
1025#include <__algorithm/ranges_copy_backward.h>
1026#include <__algorithm/ranges_copy_if.h>
1027#include <__algorithm/ranges_copy_n.h>
Nikolas Klauserf1373d02022-04-07 13:02:02 +02001028#include <__algorithm/ranges_count.h>
1029#include <__algorithm/ranges_count_if.h>
Nikolas Klauser353f1dd2022-05-25 11:09:43 +02001030#include <__algorithm/ranges_equal.h>
Nikolas Klausereb49c2a2022-05-21 18:26:29 +02001031#include <__algorithm/ranges_fill.h>
1032#include <__algorithm/ranges_fill_n.h>
Nikolas Klauser37d076e2022-03-12 01:45:35 +01001033#include <__algorithm/ranges_find.h>
1034#include <__algorithm/ranges_find_if.h>
1035#include <__algorithm/ranges_find_if_not.h>
Nikolas Klauser58de98c2022-05-04 20:27:07 +02001036#include <__algorithm/ranges_for_each.h>
1037#include <__algorithm/ranges_for_each_n.h>
Nikolas Klauserbb9049d2022-05-04 14:19:09 +02001038#include <__algorithm/ranges_is_partitioned.h>
Nikolas Klauser573cd6f2022-04-03 09:17:01 +02001039#include <__algorithm/ranges_max.h>
Nikolas Klauserf2a69ea2022-03-07 17:01:52 +01001040#include <__algorithm/ranges_max_element.h>
Nikolas Klauser3559e452022-03-18 02:57:08 +01001041#include <__algorithm/ranges_min.h>
Nikolas Klauser0a62a172022-02-11 13:11:57 +01001042#include <__algorithm/ranges_min_element.h>
Nikolas Klauser0a2f44f2022-04-13 22:59:09 +02001043#include <__algorithm/ranges_minmax.h>
1044#include <__algorithm/ranges_minmax_element.h>
Nikolas Klauser12fc9bf2022-03-08 23:12:35 +01001045#include <__algorithm/ranges_mismatch.h>
Nikolas Klauser52f20072022-05-24 10:32:50 +02001046#include <__algorithm/ranges_reverse.h>
Nikolas Klauser4ceab5f2022-02-10 13:33:03 +01001047#include <__algorithm/ranges_swap_ranges.h>
Nikolas Klauser559a1772022-04-05 11:05:36 +02001048#include <__algorithm/ranges_transform.h>
Louis Dionnea60dd872021-06-17 11:30:11 -04001049#include <__algorithm/remove.h>
1050#include <__algorithm/remove_copy.h>
1051#include <__algorithm/remove_copy_if.h>
1052#include <__algorithm/remove_if.h>
1053#include <__algorithm/replace.h>
1054#include <__algorithm/replace_copy.h>
1055#include <__algorithm/replace_copy_if.h>
1056#include <__algorithm/replace_if.h>
1057#include <__algorithm/reverse.h>
1058#include <__algorithm/reverse_copy.h>
1059#include <__algorithm/rotate.h>
1060#include <__algorithm/rotate_copy.h>
1061#include <__algorithm/sample.h>
1062#include <__algorithm/search.h>
1063#include <__algorithm/search_n.h>
1064#include <__algorithm/set_difference.h>
1065#include <__algorithm/set_intersection.h>
1066#include <__algorithm/set_symmetric_difference.h>
1067#include <__algorithm/set_union.h>
1068#include <__algorithm/shift_left.h>
1069#include <__algorithm/shift_right.h>
1070#include <__algorithm/shuffle.h>
1071#include <__algorithm/sift_down.h>
1072#include <__algorithm/sort.h>
1073#include <__algorithm/sort_heap.h>
1074#include <__algorithm/stable_partition.h>
1075#include <__algorithm/stable_sort.h>
Christopher Di Bella41f26e82021-06-05 02:47:47 +00001076#include <__algorithm/swap_ranges.h>
Louis Dionnea60dd872021-06-17 11:30:11 -04001077#include <__algorithm/transform.h>
Louis Dionnea60dd872021-06-17 11:30:11 -04001078#include <__algorithm/unique.h>
Arthur O'Dwyer65077c02022-01-07 09:45:05 -05001079#include <__algorithm/unique_copy.h>
Louis Dionnea60dd872021-06-17 11:30:11 -04001080#include <__algorithm/unwrap_iter.h>
1081#include <__algorithm/upper_bound.h>
Eric Fiselier14b6de92014-08-10 23:53:08 +00001082
Howard Hinnantaaaa52b2011-10-17 20:05:10 +00001083#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Arthur O'Dwyer6eeaa002022-02-01 20:16:40 -05001084# pragma GCC system_header
Howard Hinnantaaaa52b2011-10-17 20:05:10 +00001085#endif
Howard Hinnantc51e1022010-05-11 19:42:16 +00001086
Louis Dionne59d0b3c2019-08-05 18:29:14 +00001087#if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17
Louis Dionned53d8c02019-08-06 21:11:24 +00001088# include <__pstl_algorithm>
Louis Dionne59d0b3c2019-08-05 18:29:14 +00001089#endif
1090
Louis Dionne2b1ceaa2021-04-20 12:03:32 -04001091#endif // _LIBCPP_ALGORITHM