blob: 919c7ccbb8216c0e866259058fbca7a5ccfdf6b8 [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
48 template <input_iterator I1, sentinel_for<_I1> S1, input_iterator I2, sentinel_for<_I2> S2,
49 class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
50 requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
51 constexpr mismatch_result<_I1, _I2>
52 mismatch()(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}) // since C++20
53
54 template <input_range R1, input_range R2,
55 class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
56 requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
57 constexpr mismatch_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>>
58 mismatch(R1&& r1, R2&& r2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}) // since C++20
Nikolas Klauseree0f8c42022-03-12 00:45:3559
Nikolas Klauseree0f8c42022-03-12 00:45:3560 requires indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
61 constexpr I find(I first, S last, const T& value, Proj proj = {}); // since C++20
62
63 template<input_range R, class T, class Proj = identity>
64 requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*>
65 constexpr borrowed_iterator_t<R>
66 find(R&& r, const T& value, Proj proj = {}); // since C++20
67
68 template<input_iterator I, sentinel_for<I> S, class Proj = identity,
69 indirect_unary_predicate<projected<I, Proj>> Pred>
70 constexpr I find_if(I first, S last, Pred pred, Proj proj = {}); // since C++20
71
72 template<input_range R, class Proj = identity,
73 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
74 constexpr borrowed_iterator_t<R>
75 find_if(R&& r, Pred pred, 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_not(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_not(R&& r, Pred pred, Proj proj = {}); // since C++20
Nikolas Klauserf83d8332022-03-18 01:57:0885
Nikolas Klausere476df52022-04-03 07:17:0186 template<class T, class Proj = identity,
87 indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
88 constexpr const T& min(const T& a, const T& b, Comp comp = {}, Proj proj = {}); // since C++20
Nikolas Klauserf83d8332022-03-18 01:57:0889
Nikolas Klausere476df52022-04-03 07:17:0190 template<copyable T, class Proj = identity,
91 indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
92 constexpr T min(initializer_list<T> r, Comp comp = {}, Proj proj = {}); // since C++20
Nikolas Klauserf83d8332022-03-18 01:57:0893
94 template<input_range R, class Proj = identity,
95 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
96 requires indirectly_copyable_storable<iterator_t<R>, range_value_t<R>*>
97 constexpr range_value_t<R>
98 min(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
Nikolas Klausere476df52022-04-03 07:17:0199
100 template<class T, class Proj = identity,
101 indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
102 constexpr const T& max(const T& a, const T& b, Comp comp = {}, Proj proj = {}); // since C++20
103
104 template<copyable T, class Proj = identity,
105 indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
106 constexpr T max(initializer_list<T> r, Comp comp = {}, Proj proj = {}); // since C++20
107
108 template<input_range R, class Proj = identity,
109 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
110 requires indirectly_copyable_storable<iterator_t<R>, range_value_t<R>*>
111 constexpr range_value_t<R>
112 max(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
Nikolas Klauser3ba85482022-04-05 09:05:36113
114 template<class I, class O>
115 using unary_transform_result = in_out_result<I, O>; // since C++20
116
117 template<class I1, class I2, class O>
118 using binary_transform_result = in_in_out_result<I1, I2, O>; // since C++20
119
120 template<input_iterator I, sentinel_for<I> S, weakly_incrementable O,
121 copy_constructible F, class Proj = identity>
122 requires indirectly_writable<O, indirect_result_t<F&, projected<I, Proj>>>
123 constexpr ranges::unary_transform_result<I, O>
124 transform(I first1, S last1, O result, F op, Proj proj = {}); // since C++20
125
126 template<input_range R, weakly_incrementable O, copy_constructible F,
127 class Proj = identity>
128 requires indirectly_writable<O, indirect_result_t<F&, projected<iterator_t<R>, Proj>>>
129 constexpr ranges::unary_transform_result<borrowed_iterator_t<R>, O>
130 transform(R&& r, O result, F op, Proj proj = {}); // since C++20
131
132 template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
133 weakly_incrementable O, copy_constructible F, class Proj1 = identity,
134 class Proj2 = identity>
135 requires indirectly_writable<O, indirect_result_t<F&, projected<I1, Proj1>,
136 projected<I2, Proj2>>>
137 constexpr ranges::binary_transform_result<I1, I2, O>
138 transform(I1 first1, S1 last1, I2 first2, S2 last2, O result,
139 F binary_op, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
140
141 template<input_range R1, input_range R2, weakly_incrementable O,
142 copy_constructible F, class Proj1 = identity, class Proj2 = identity>
143 requires indirectly_writable<O, indirect_result_t<F&, projected<iterator_t<R1>, Proj1>,
144 projected<iterator_t<R2>, Proj2>>>
145 constexpr ranges::binary_transform_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>, O>
146 transform(R1&& r1, R2&& r2, O result,
147 F binary_op, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
Nikolas Klauser1306b102022-04-07 11:02:02148
149 template<input_iterator I, sentinel_for<I> S, class T, class Proj = identity>
150 requires indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
151 constexpr iter_difference_t<I>
152 count(I first, S last, const T& value, Proj proj = {}); // since C++20
153
154 template<input_range R, class T, class Proj = identity>
155 requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*>
156 constexpr range_difference_t<R>
157 count(R&& r, const T& value, Proj proj = {}); // since C++20
158
159 template<input_iterator I, sentinel_for<I> S, class Proj = identity,
160 indirect_unary_predicate<projected<I, Proj>> Pred>
161 constexpr iter_difference_t<I>
162 count_if(I first, S last, Pred pred, Proj proj = {}); // since C++20
163
164 template<input_range R, class Proj = identity,
165 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
166 constexpr range_difference_t<R>
167 count_if(R&& r, Pred pred, Proj proj = {}); // since C++20
Nikolas Klauser58d9ab72022-04-13 20:59:09168
169 template<class T, class Proj = identity,
170 indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
171 constexpr ranges::minmax_result<const T&>
172 minmax(const T& a, const T& b, Comp comp = {}, Proj proj = {}); // since C++20
173
174 template<copyable T, class Proj = identity,
175 indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
176 constexpr ranges::minmax_result<T>
177 minmax(initializer_list<T> r, Comp comp = {}, Proj proj = {}); // since C++20
178
179 template<input_range R, class Proj = identity,
180 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
181 requires indirectly_copyable_storable<iterator_t<R>, range_value_t<R>*>
182 constexpr ranges::minmax_result<range_value_t<R>>
183 minmax(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
184
185 template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
186 indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
187 constexpr ranges::minmax_element_result<I>
188 minmax_element(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
189
190 template<forward_range R, class Proj = identity,
191 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
192 constexpr ranges::minmax_element_result<borrowed_iterator_t<R>>
193 minmax_element(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
Nikolas Klauserd3729bb2022-01-14 01:55:51194}
195
Marshall Clow706ffef2018-01-15 17:20:36196 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16197 all_of(InputIterator first, InputIterator last, Predicate pred);
198
199template <class InputIterator, class Predicate>
Marshall Clow706ffef2018-01-15 17:20:36200 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16201 any_of(InputIterator first, InputIterator last, Predicate pred);
202
203template <class InputIterator, class Predicate>
Marshall Clow706ffef2018-01-15 17:20:36204 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16205 none_of(InputIterator first, InputIterator last, Predicate pred);
206
207template <class InputIterator, class Function>
Marshall Clow1b9a4ff2018-01-22 20:44:33208 constexpr Function // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16209 for_each(InputIterator first, InputIterator last, Function f);
210
Marshall Clowd5c65ff2017-05-25 02:29:54211template<class InputIterator, class Size, class Function>
Marshall Clow1b9a4ff2018-01-22 20:44:33212 constexpr InputIterator // constexpr in C++20
213 for_each_n(InputIterator first, Size n, Function f); // C++17
Marshall Clowd5c65ff2017-05-25 02:29:54214
Howard Hinnant3e519522010-05-11 19:42:16215template <class InputIterator, class T>
Marshall Clow86944282018-01-15 19:26:05216 constexpr InputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16217 find(InputIterator first, InputIterator last, const T& value);
218
219template <class InputIterator, class Predicate>
Marshall Clow86944282018-01-15 19:26:05220 constexpr InputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16221 find_if(InputIterator first, InputIterator last, Predicate pred);
222
223template<class InputIterator, class Predicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18224 constexpr InputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16225 find_if_not(InputIterator first, InputIterator last, Predicate pred);
226
227template <class ForwardIterator1, class ForwardIterator2>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18228 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16229 find_end(ForwardIterator1 first1, ForwardIterator1 last1,
230 ForwardIterator2 first2, ForwardIterator2 last2);
231
232template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18233 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16234 find_end(ForwardIterator1 first1, ForwardIterator1 last1,
235 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
236
237template <class ForwardIterator1, class ForwardIterator2>
Marshall Clow86944282018-01-15 19:26:05238 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16239 find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
240 ForwardIterator2 first2, ForwardIterator2 last2);
241
242template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow86944282018-01-15 19:26:05243 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16244 find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
245 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
246
247template <class ForwardIterator>
Marshall Clow86944282018-01-15 19:26:05248 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16249 adjacent_find(ForwardIterator first, ForwardIterator last);
250
251template <class ForwardIterator, class BinaryPredicate>
Marshall Clow86944282018-01-15 19:26:05252 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16253 adjacent_find(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
254
255template <class InputIterator, class T>
Marshall Clow056f15e2018-01-15 19:40:34256 constexpr typename iterator_traits<InputIterator>::difference_type // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16257 count(InputIterator first, InputIterator last, const T& value);
258
259template <class InputIterator, class Predicate>
Marshall Clow056f15e2018-01-15 19:40:34260 constexpr typename iterator_traits<InputIterator>::difference_type // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16261 count_if(InputIterator first, InputIterator last, Predicate pred);
262
263template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:10264 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16265 mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
266
Marshall Clow0b0bbd22013-05-09 21:14:23267template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:10268 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Aditya Kumar331fb802016-08-25 11:52:38269 mismatch(InputIterator1 first1, InputIterator1 last1,
Marshall Clow0b0bbd22013-05-09 21:14:23270 InputIterator2 first2, InputIterator2 last2); // **C++14**
271
Howard Hinnant3e519522010-05-11 19:42:16272template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:10273 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16274 mismatch(InputIterator1 first1, InputIterator1 last1,
275 InputIterator2 first2, BinaryPredicate pred);
276
Marshall Clow0b0bbd22013-05-09 21:14:23277template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:10278 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23279 mismatch(InputIterator1 first1, InputIterator1 last1,
280 InputIterator2 first2, InputIterator2 last2,
281 BinaryPredicate pred); // **C++14**
282
Howard Hinnant3e519522010-05-11 19:42:16283template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:10284 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16285 equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
286
Marshall Clow0b0bbd22013-05-09 21:14:23287template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:10288 constexpr bool // constexpr in C++20
Aditya Kumar331fb802016-08-25 11:52:38289 equal(InputIterator1 first1, InputIterator1 last1,
Marshall Clow0b0bbd22013-05-09 21:14:23290 InputIterator2 first2, InputIterator2 last2); // **C++14**
291
Howard Hinnant3e519522010-05-11 19:42:16292template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:10293 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16294 equal(InputIterator1 first1, InputIterator1 last1,
295 InputIterator2 first2, BinaryPredicate pred);
296
Marshall Clow0b0bbd22013-05-09 21:14:23297template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:10298 constexpr bool // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23299 equal(InputIterator1 first1, InputIterator1 last1,
300 InputIterator2 first2, InputIterator2 last2,
301 BinaryPredicate pred); // **C++14**
302
Howard Hinnant3e519522010-05-11 19:42:16303template<class ForwardIterator1, class ForwardIterator2>
Marshall Clow49c76432018-01-15 16:16:32304 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16305 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
306 ForwardIterator2 first2);
307
Marshall Clow0b0bbd22013-05-09 21:14:23308template<class ForwardIterator1, class ForwardIterator2>
Marshall Clow49c76432018-01-15 16:16:32309 constexpr bool // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23310 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
311 ForwardIterator2 first2, ForwardIterator2 last2); // **C++14**
312
Howard Hinnant3e519522010-05-11 19:42:16313template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow49c76432018-01-15 16:16:32314 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16315 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
316 ForwardIterator2 first2, BinaryPredicate pred);
317
Marshall Clow0b0bbd22013-05-09 21:14:23318template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow49c76432018-01-15 16:16:32319 constexpr bool // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23320 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
321 ForwardIterator2 first2, ForwardIterator2 last2,
322 BinaryPredicate pred); // **C++14**
323
Howard Hinnant3e519522010-05-11 19:42:16324template <class ForwardIterator1, class ForwardIterator2>
Marshall Clow12f0a772018-01-16 15:48:27325 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16326 search(ForwardIterator1 first1, ForwardIterator1 last1,
327 ForwardIterator2 first2, ForwardIterator2 last2);
328
329template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow12f0a772018-01-16 15:48:27330 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16331 search(ForwardIterator1 first1, ForwardIterator1 last1,
332 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
333
334template <class ForwardIterator, class Size, class T>
Marshall Clow12f0a772018-01-16 15:48:27335 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16336 search_n(ForwardIterator first, ForwardIterator last, Size count, const T& value);
337
338template <class ForwardIterator, class Size, class T, class BinaryPredicate>
Marshall Clow12f0a772018-01-16 15:48:27339 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16340 search_n(ForwardIterator first, ForwardIterator last,
341 Size count, const T& value, BinaryPredicate pred);
342
343template <class InputIterator, class OutputIterator>
Louis Dionne13c90a52019-11-06 12:02:41344 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16345 copy(InputIterator first, InputIterator last, OutputIterator result);
346
347template<class InputIterator, class OutputIterator, class Predicate>
Louis Dionne13c90a52019-11-06 12:02:41348 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16349 copy_if(InputIterator first, InputIterator last,
350 OutputIterator result, Predicate pred);
351
352template<class InputIterator, class Size, class OutputIterator>
Louis Dionne13c90a52019-11-06 12:02:41353 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16354 copy_n(InputIterator first, Size n, OutputIterator result);
355
356template <class BidirectionalIterator1, class BidirectionalIterator2>
Louis Dionne13c90a52019-11-06 12:02:41357 constexpr BidirectionalIterator2 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16358 copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last,
359 BidirectionalIterator2 result);
360
361template <class ForwardIterator1, class ForwardIterator2>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18362 constexpr ForwardIterator2 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16363 swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2);
364
Nikolas Klauser9d905312022-02-10 12:33:03365template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2>
366 requires indirectly_swappable<I1, I2>
367 constexpr ranges::swap_ranges_result<I1, I2>
368 ranges::swap_ranges(I1 first1, S1 last1, I2 first2, S2 last2);
369
370template<input_range R1, input_range R2>
371 requires indirectly_swappable<iterator_t<R1>, iterator_t<R2>>
372 constexpr ranges::swap_ranges_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>>
373 ranges::swap_ranges(R1&& r1, R2&& r2);
374
Howard Hinnant3e519522010-05-11 19:42:16375template <class ForwardIterator1, class ForwardIterator2>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18376 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16377 iter_swap(ForwardIterator1 a, ForwardIterator2 b);
378
379template <class InputIterator, class OutputIterator, class UnaryOperation>
Marshall Clow99894b62018-01-19 17:45:39380 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16381 transform(InputIterator first, InputIterator last, OutputIterator result, UnaryOperation op);
382
383template <class InputIterator1, class InputIterator2, class OutputIterator, class BinaryOperation>
Marshall Clow99894b62018-01-19 17:45:39384 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16385 transform(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2,
386 OutputIterator result, BinaryOperation binary_op);
387
388template <class ForwardIterator, class T>
Marshall Clow12c74232018-01-19 18:07:29389 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16390 replace(ForwardIterator first, ForwardIterator last, const T& old_value, const T& new_value);
391
392template <class ForwardIterator, class Predicate, class T>
Marshall Clow12c74232018-01-19 18:07:29393 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16394 replace_if(ForwardIterator first, ForwardIterator last, Predicate pred, const T& new_value);
395
396template <class InputIterator, class OutputIterator, class T>
Marshall Clow12c74232018-01-19 18:07:29397 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16398 replace_copy(InputIterator first, InputIterator last, OutputIterator result,
399 const T& old_value, const T& new_value);
400
401template <class InputIterator, class OutputIterator, class Predicate, class T>
Marshall Clow12c74232018-01-19 18:07:29402 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16403 replace_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred, const T& new_value);
404
405template <class ForwardIterator, class T>
Marshall Clow4bfb9312018-01-20 20:14:32406 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16407 fill(ForwardIterator first, ForwardIterator last, const T& value);
408
409template <class OutputIterator, class Size, class T>
Marshall Clow4bfb9312018-01-20 20:14:32410 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16411 fill_n(OutputIterator first, Size n, const T& value);
412
413template <class ForwardIterator, class Generator>
Marshall Clow4bfb9312018-01-20 20:14:32414 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16415 generate(ForwardIterator first, ForwardIterator last, Generator gen);
416
417template <class OutputIterator, class Size, class Generator>
Marshall Clow4bfb9312018-01-20 20:14:32418 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16419 generate_n(OutputIterator first, Size n, Generator gen);
420
421template <class ForwardIterator, class T>
Marshall Clowe8ea8292018-01-22 21:43:04422 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16423 remove(ForwardIterator first, ForwardIterator last, const T& value);
424
425template <class ForwardIterator, class Predicate>
Marshall Clowe8ea8292018-01-22 21:43:04426 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16427 remove_if(ForwardIterator first, ForwardIterator last, Predicate pred);
428
429template <class InputIterator, class OutputIterator, class T>
Marshall Clowe8ea8292018-01-22 21:43:04430 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16431 remove_copy(InputIterator first, InputIterator last, OutputIterator result, const T& value);
432
433template <class InputIterator, class OutputIterator, class Predicate>
Marshall Clowe8ea8292018-01-22 21:43:04434 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16435 remove_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred);
436
437template <class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18438 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16439 unique(ForwardIterator first, ForwardIterator last);
440
441template <class ForwardIterator, class BinaryPredicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18442 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16443 unique(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
444
445template <class InputIterator, class OutputIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18446 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16447 unique_copy(InputIterator first, InputIterator last, OutputIterator result);
448
449template <class InputIterator, class OutputIterator, class BinaryPredicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18450 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16451 unique_copy(InputIterator first, InputIterator last, OutputIterator result, BinaryPredicate pred);
452
453template <class BidirectionalIterator>
Arthur O'Dwyerf851db32020-12-17 05:01:08454 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16455 reverse(BidirectionalIterator first, BidirectionalIterator last);
456
457template <class BidirectionalIterator, class OutputIterator>
Marshall Clowe8ea8292018-01-22 21:43:04458 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16459 reverse_copy(BidirectionalIterator first, BidirectionalIterator last, OutputIterator result);
460
461template <class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18462 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16463 rotate(ForwardIterator first, ForwardIterator middle, ForwardIterator last);
464
465template <class ForwardIterator, class OutputIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18466 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16467 rotate_copy(ForwardIterator first, ForwardIterator middle, ForwardIterator last, OutputIterator result);
468
469template <class RandomAccessIterator>
470 void
Marshall Clow0f37a412017-03-23 13:43:37471 random_shuffle(RandomAccessIterator first, RandomAccessIterator last); // deprecated in C++14, removed in C++17
Howard Hinnant3e519522010-05-11 19:42:16472
473template <class RandomAccessIterator, class RandomNumberGenerator>
474 void
Marshall Clow06965c12014-03-03 06:14:19475 random_shuffle(RandomAccessIterator first, RandomAccessIterator last,
Marshall Clow0f37a412017-03-23 13:43:37476 RandomNumberGenerator& rand); // deprecated in C++14, removed in C++17
Howard Hinnant3e519522010-05-11 19:42:16477
Eric Fiseliere7154702016-08-28 22:14:37478template<class PopulationIterator, class SampleIterator,
479 class Distance, class UniformRandomBitGenerator>
480 SampleIterator sample(PopulationIterator first, PopulationIterator last,
481 SampleIterator out, Distance n,
482 UniformRandomBitGenerator&& g); // C++17
483
Howard Hinnantf9d540b2010-05-26 17:49:34484template<class RandomAccessIterator, class UniformRandomNumberGenerator>
485 void shuffle(RandomAccessIterator first, RandomAccessIterator last,
Howard Hinnantfb340102010-11-18 01:47:02486 UniformRandomNumberGenerator&& g);
Howard Hinnantf9d540b2010-05-26 17:49:34487
Arthur O'Dwyer3fbd3ea2020-12-26 06:39:03488template<class ForwardIterator>
489 constexpr ForwardIterator
490 shift_left(ForwardIterator first, ForwardIterator last,
491 typename iterator_traits<ForwardIterator>::difference_type n); // C++20
492
493template<class ForwardIterator>
494 constexpr ForwardIterator
495 shift_right(ForwardIterator first, ForwardIterator last,
496 typename iterator_traits<ForwardIterator>::difference_type n); // C++20
497
Howard Hinnant3e519522010-05-11 19:42:16498template <class InputIterator, class Predicate>
Marshall Clow49c76432018-01-15 16:16:32499 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16500 is_partitioned(InputIterator first, InputIterator last, Predicate pred);
501
502template <class ForwardIterator, class Predicate>
Arthur O'Dwyerf851db32020-12-17 05:01:08503 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16504 partition(ForwardIterator first, ForwardIterator last, Predicate pred);
505
506template <class InputIterator, class OutputIterator1,
507 class OutputIterator2, class Predicate>
Marshall Clow1b9a4ff2018-01-22 20:44:33508 constexpr pair<OutputIterator1, OutputIterator2> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16509 partition_copy(InputIterator first, InputIterator last,
510 OutputIterator1 out_true, OutputIterator2 out_false,
511 Predicate pred);
512
513template <class ForwardIterator, class Predicate>
514 ForwardIterator
515 stable_partition(ForwardIterator first, ForwardIterator last, Predicate pred);
516
517template<class ForwardIterator, class Predicate>
Marshall Clowd57c03d2018-01-16 02:34:41518 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16519 partition_point(ForwardIterator first, ForwardIterator last, Predicate pred);
520
521template <class ForwardIterator>
Marshall Clow49c76432018-01-15 16:16:32522 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16523 is_sorted(ForwardIterator first, ForwardIterator last);
524
525template <class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18526 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16527 is_sorted(ForwardIterator first, ForwardIterator last, Compare comp);
528
529template<class ForwardIterator>
Marshall Clow056f15e2018-01-15 19:40:34530 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16531 is_sorted_until(ForwardIterator first, ForwardIterator last);
532
533template <class ForwardIterator, class Compare>
Marshall Clow056f15e2018-01-15 19:40:34534 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16535 is_sorted_until(ForwardIterator first, ForwardIterator last, Compare comp);
536
537template <class RandomAccessIterator>
Arthur O'Dwyer493f1402020-12-20 20:21:42538 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16539 sort(RandomAccessIterator first, RandomAccessIterator last);
540
541template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer493f1402020-12-20 20:21:42542 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16543 sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
544
545template <class RandomAccessIterator>
546 void
547 stable_sort(RandomAccessIterator first, RandomAccessIterator last);
548
549template <class RandomAccessIterator, class Compare>
550 void
551 stable_sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
552
553template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18554 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16555 partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last);
556
557template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18558 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16559 partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last, Compare comp);
560
561template <class InputIterator, class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18562 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16563 partial_sort_copy(InputIterator first, InputIterator last,
564 RandomAccessIterator result_first, RandomAccessIterator result_last);
565
566template <class InputIterator, class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18567 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16568 partial_sort_copy(InputIterator first, InputIterator last,
569 RandomAccessIterator result_first, RandomAccessIterator result_last, Compare comp);
570
571template <class RandomAccessIterator>
Arthur O'Dwyer5d956562021-02-04 23:12:52572 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16573 nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last);
574
575template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5d956562021-02-04 23:12:52576 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16577 nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last, Compare comp);
578
579template <class ForwardIterator, class T>
Marshall Clowd57c03d2018-01-16 02:34:41580 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16581 lower_bound(ForwardIterator first, ForwardIterator last, const T& value);
582
583template <class ForwardIterator, class T, class Compare>
Marshall Clowd57c03d2018-01-16 02:34:41584 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16585 lower_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
586
587template <class ForwardIterator, class T>
Marshall Clowd57c03d2018-01-16 02:34:41588 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16589 upper_bound(ForwardIterator first, ForwardIterator last, const T& value);
590
591template <class ForwardIterator, class T, class Compare>
Marshall Clowd57c03d2018-01-16 02:34:41592 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16593 upper_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
594
595template <class ForwardIterator, class T>
Marshall Clowd57c03d2018-01-16 02:34:41596 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16597 equal_range(ForwardIterator first, ForwardIterator last, const T& value);
598
599template <class ForwardIterator, class T, class Compare>
Marshall Clowd57c03d2018-01-16 02:34:41600 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16601 equal_range(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
602
603template <class ForwardIterator, class T>
Marshall Clowd57c03d2018-01-16 02:34:41604 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16605 binary_search(ForwardIterator first, ForwardIterator last, const T& value);
606
607template <class ForwardIterator, class T, class Compare>
Marshall Clow8da1a482018-01-22 23:10:40608 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16609 binary_search(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
610
611template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer14098cf2020-12-04 18:47:12612 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16613 merge(InputIterator1 first1, InputIterator1 last1,
614 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
615
616template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer14098cf2020-12-04 18:47:12617 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16618 merge(InputIterator1 first1, InputIterator1 last1,
619 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
620
621template <class BidirectionalIterator>
622 void
623 inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last);
624
625template <class BidirectionalIterator, class Compare>
626 void
627 inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last, Compare comp);
628
629template <class InputIterator1, class InputIterator2>
Marshall Clow8da1a482018-01-22 23:10:40630 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16631 includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
632
633template <class InputIterator1, class InputIterator2, class Compare>
Marshall Clow8da1a482018-01-22 23:10:40634 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16635 includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, Compare comp);
636
637template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer14098cf2020-12-04 18:47:12638 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16639 set_union(InputIterator1 first1, InputIterator1 last1,
640 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
641
642template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer14098cf2020-12-04 18:47:12643 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16644 set_union(InputIterator1 first1, InputIterator1 last1,
645 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
646
647template <class InputIterator1, class InputIterator2, class OutputIterator>
Marshall Clow8da1a482018-01-22 23:10:40648 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16649 set_intersection(InputIterator1 first1, InputIterator1 last1,
650 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
651
652template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Marshall Clow8da1a482018-01-22 23:10:40653 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16654 set_intersection(InputIterator1 first1, InputIterator1 last1,
655 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
656
657template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer14098cf2020-12-04 18:47:12658 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16659 set_difference(InputIterator1 first1, InputIterator1 last1,
660 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
661
662template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer14098cf2020-12-04 18:47:12663 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16664 set_difference(InputIterator1 first1, InputIterator1 last1,
665 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
666
667template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer14098cf2020-12-04 18:47:12668 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16669 set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
670 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
671
672template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer14098cf2020-12-04 18:47:12673 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16674 set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
675 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
676
677template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18678 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16679 push_heap(RandomAccessIterator first, RandomAccessIterator last);
680
681template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18682 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16683 push_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
684
685template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18686 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16687 pop_heap(RandomAccessIterator first, RandomAccessIterator last);
688
689template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18690 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16691 pop_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
692
693template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18694 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16695 make_heap(RandomAccessIterator first, RandomAccessIterator last);
696
697template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18698 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16699 make_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
700
701template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18702 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16703 sort_heap(RandomAccessIterator first, RandomAccessIterator last);
704
705template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18706 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16707 sort_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
708
Howard Hinnantb3371f62010-08-22 00:02:43709template <class RandomAccessIterator>
Marshall Clow49c76432018-01-15 16:16:32710 constexpr bool // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43711 is_heap(RandomAccessIterator first, RandomAccessiterator last);
Howard Hinnant3e519522010-05-11 19:42:16712
Howard Hinnantb3371f62010-08-22 00:02:43713template <class RandomAccessIterator, class Compare>
Marshall Clow49c76432018-01-15 16:16:32714 constexpr bool // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43715 is_heap(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16716
Howard Hinnantb3371f62010-08-22 00:02:43717template <class RandomAccessIterator>
Marshall Clow49c76432018-01-15 16:16:32718 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43719 is_heap_until(RandomAccessIterator first, RandomAccessiterator last);
Howard Hinnant3e519522010-05-11 19:42:16720
Howard Hinnantb3371f62010-08-22 00:02:43721template <class RandomAccessIterator, class Compare>
Marshall Clow49c76432018-01-15 16:16:32722 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43723 is_heap_until(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16724
Howard Hinnant4eb27b72010-08-21 20:10:01725template <class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18726 constexpr ForwardIterator // constexpr in C++14
727 min_element(ForwardIterator first, ForwardIterator last);
Howard Hinnant4eb27b72010-08-21 20:10:01728
729template <class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18730 constexpr ForwardIterator // constexpr in C++14
731 min_element(ForwardIterator first, ForwardIterator last, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01732
Howard Hinnant3e519522010-05-11 19:42:16733template <class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18734 constexpr const T& // constexpr in C++14
735 min(const T& a, const T& b);
Howard Hinnant3e519522010-05-11 19:42:16736
737template <class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18738 constexpr const T& // constexpr in C++14
739 min(const T& a, const T& b, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16740
Howard Hinnant4eb27b72010-08-21 20:10:01741template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18742 constexpr T // constexpr in C++14
743 min(initializer_list<T> t);
Howard Hinnant4eb27b72010-08-21 20:10:01744
745template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18746 constexpr T // constexpr in C++14
747 min(initializer_list<T> t, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01748
Marshall Clow146c14a2016-03-07 22:43:49749template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18750 constexpr const T& clamp(const T& v, const T& lo, const T& hi); // C++17
Marshall Clow146c14a2016-03-07 22:43:49751
752template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18753 constexpr const T& clamp(const T& v, const T& lo, const T& hi, Compare comp); // C++17
Marshall Clow146c14a2016-03-07 22:43:49754
Howard Hinnant4eb27b72010-08-21 20:10:01755template <class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18756 constexpr ForwardIterator // constexpr in C++14
757 max_element(ForwardIterator first, ForwardIterator last);
Howard Hinnant4eb27b72010-08-21 20:10:01758
759template <class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18760 constexpr ForwardIterator // constexpr in C++14
761 max_element(ForwardIterator first, ForwardIterator last, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01762
Howard Hinnant3e519522010-05-11 19:42:16763template <class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18764 constexpr const T& // constexpr in C++14
765 max(const T& a, const T& b);
Howard Hinnant3e519522010-05-11 19:42:16766
767template <class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18768 constexpr const T& // constexpr in C++14
769 max(const T& a, const T& b, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16770
Howard Hinnant4eb27b72010-08-21 20:10:01771template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18772 constexpr T // constexpr in C++14
773 max(initializer_list<T> t);
Howard Hinnant3e519522010-05-11 19:42:16774
Howard Hinnant4eb27b72010-08-21 20:10:01775template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18776 constexpr T // constexpr in C++14
777 max(initializer_list<T> t, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16778
Howard Hinnant4eb27b72010-08-21 20:10:01779template<class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18780 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++14
781 minmax_element(ForwardIterator first, ForwardIterator last);
Howard Hinnant3e519522010-05-11 19:42:16782
Howard Hinnant4eb27b72010-08-21 20:10:01783template<class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18784 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++14
785 minmax_element(ForwardIterator first, ForwardIterator last, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01786
787template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18788 constexpr pair<const T&, const T&> // constexpr in C++14
789 minmax(const T& a, const T& b);
Howard Hinnant4eb27b72010-08-21 20:10:01790
791template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18792 constexpr pair<const T&, const T&> // constexpr in C++14
793 minmax(const T& a, const T& b, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01794
795template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18796 constexpr pair<T, T> // constexpr in C++14
797 minmax(initializer_list<T> t);
Howard Hinnant4eb27b72010-08-21 20:10:01798
799template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18800 constexpr pair<T, T> // constexpr in C++14
801 minmax(initializer_list<T> t, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16802
803template <class InputIterator1, class InputIterator2>
Marshall Clow1b9a4ff2018-01-22 20:44:33804 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16805 lexicographical_compare(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
806
807template <class InputIterator1, class InputIterator2, class Compare>
Marshall Clow1b9a4ff2018-01-22 20:44:33808 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16809 lexicographical_compare(InputIterator1 first1, InputIterator1 last1,
810 InputIterator2 first2, InputIterator2 last2, Compare comp);
811
812template <class BidirectionalIterator>
Arthur O'Dwyerf851db32020-12-17 05:01:08813 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16814 next_permutation(BidirectionalIterator first, BidirectionalIterator last);
815
816template <class BidirectionalIterator, class Compare>
Arthur O'Dwyerf851db32020-12-17 05:01:08817 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16818 next_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
819
820template <class BidirectionalIterator>
Arthur O'Dwyerf851db32020-12-17 05:01:08821 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16822 prev_permutation(BidirectionalIterator first, BidirectionalIterator last);
823
824template <class BidirectionalIterator, class Compare>
Arthur O'Dwyerf851db32020-12-17 05:01:08825 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16826 prev_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16827} // std
828
829*/
830
Louis Dionne385cc252022-03-25 16:55:36831#include <__assert> // all public C++ headers provide the assertion handler
Arthur O'Dwyerea2206d2022-02-04 18:09:30832#include <__bits>
Howard Hinnant3e519522010-05-11 19:42:16833#include <__config>
Louis Dionne134723e2021-06-17 15:30:11834#include <__debug>
Howard Hinnanta1d07d52012-07-26 17:09:09835#include <cstddef>
Arthur O'Dwyerbfbd73f2021-05-19 15:57:04836#include <cstring>
837#include <functional>
838#include <initializer_list>
Arthur O'Dwyerbfbd73f2021-05-19 15:57:04839#include <iterator>
840#include <memory>
841#include <type_traits>
Marshall Clowf56972e2018-09-12 19:41:40842#include <version>
Howard Hinnant5d1a7012013-08-14 18:00:20843
Louis Dionne134723e2021-06-17 15:30:11844#include <__algorithm/adjacent_find.h>
845#include <__algorithm/all_of.h>
846#include <__algorithm/any_of.h>
847#include <__algorithm/binary_search.h>
848#include <__algorithm/clamp.h>
849#include <__algorithm/comp.h>
850#include <__algorithm/comp_ref_type.h>
851#include <__algorithm/copy.h>
852#include <__algorithm/copy_backward.h>
853#include <__algorithm/copy_if.h>
854#include <__algorithm/copy_n.h>
855#include <__algorithm/count.h>
856#include <__algorithm/count_if.h>
857#include <__algorithm/equal.h>
858#include <__algorithm/equal_range.h>
Louis Dionne134723e2021-06-17 15:30:11859#include <__algorithm/fill.h>
Arthur O'Dwyer4d81a462022-01-07 14:45:05860#include <__algorithm/fill_n.h>
Louis Dionne134723e2021-06-17 15:30:11861#include <__algorithm/find.h>
862#include <__algorithm/find_end.h>
863#include <__algorithm/find_first_of.h>
864#include <__algorithm/find_if.h>
865#include <__algorithm/find_if_not.h>
866#include <__algorithm/for_each.h>
867#include <__algorithm/for_each_n.h>
Louis Dionne134723e2021-06-17 15:30:11868#include <__algorithm/generate.h>
Arthur O'Dwyer4d81a462022-01-07 14:45:05869#include <__algorithm/generate_n.h>
Louis Dionne134723e2021-06-17 15:30:11870#include <__algorithm/half_positive.h>
Nikolas Klauser68f41312022-02-21 22:07:02871#include <__algorithm/in_found_result.h>
Nikolas Klauser1e77b392022-02-11 16:01:58872#include <__algorithm/in_fun_result.h>
Nikolas Klauserf3514af2022-01-25 10:21:47873#include <__algorithm/in_in_out_result.h>
Nikolas Klauserd3729bb2022-01-14 01:55:51874#include <__algorithm/in_in_result.h>
Nikolas Klauser610979b2022-02-03 01:17:03875#include <__algorithm/in_out_out_result.h>
Konstantin Varlamov8d23b742022-01-11 06:49:37876#include <__algorithm/in_out_result.h>
Louis Dionne134723e2021-06-17 15:30:11877#include <__algorithm/includes.h>
878#include <__algorithm/inplace_merge.h>
879#include <__algorithm/is_heap.h>
880#include <__algorithm/is_heap_until.h>
881#include <__algorithm/is_partitioned.h>
882#include <__algorithm/is_permutation.h>
883#include <__algorithm/is_sorted.h>
884#include <__algorithm/is_sorted_until.h>
Christopher Di Bella6adbc832021-06-05 02:47:47885#include <__algorithm/iter_swap.h>
Louis Dionne134723e2021-06-17 15:30:11886#include <__algorithm/lexicographical_compare.h>
887#include <__algorithm/lower_bound.h>
888#include <__algorithm/make_heap.h>
889#include <__algorithm/max.h>
890#include <__algorithm/max_element.h>
891#include <__algorithm/merge.h>
892#include <__algorithm/min.h>
893#include <__algorithm/min_element.h>
Nikolas Klauser807766b2022-02-21 21:48:36894#include <__algorithm/min_max_result.h>
Louis Dionne134723e2021-06-17 15:30:11895#include <__algorithm/minmax.h>
896#include <__algorithm/minmax_element.h>
897#include <__algorithm/mismatch.h>
898#include <__algorithm/move.h>
899#include <__algorithm/move_backward.h>
900#include <__algorithm/next_permutation.h>
901#include <__algorithm/none_of.h>
902#include <__algorithm/nth_element.h>
903#include <__algorithm/partial_sort.h>
904#include <__algorithm/partial_sort_copy.h>
905#include <__algorithm/partition.h>
906#include <__algorithm/partition_copy.h>
907#include <__algorithm/partition_point.h>
908#include <__algorithm/pop_heap.h>
909#include <__algorithm/prev_permutation.h>
910#include <__algorithm/push_heap.h>
Nikolas Klauser1306b102022-04-07 11:02:02911#include <__algorithm/ranges_count.h>
912#include <__algorithm/ranges_count_if.h>
Nikolas Klauseree0f8c42022-03-12 00:45:35913#include <__algorithm/ranges_find.h>
914#include <__algorithm/ranges_find_if.h>
915#include <__algorithm/ranges_find_if_not.h>
Nikolas Klausere476df52022-04-03 07:17:01916#include <__algorithm/ranges_max.h>
Nikolas Klauser205557c2022-03-07 16:01:52917#include <__algorithm/ranges_max_element.h>
Nikolas Klauserf83d8332022-03-18 01:57:08918#include <__algorithm/ranges_min.h>
Nikolas Klauser3b470d12022-02-11 12:11:57919#include <__algorithm/ranges_min_element.h>
Nikolas Klauser58d9ab72022-04-13 20:59:09920#include <__algorithm/ranges_minmax.h>
921#include <__algorithm/ranges_minmax_element.h>
Nikolas Klauserc2cd15a2022-03-08 22:12:35922#include <__algorithm/ranges_mismatch.h>
Nikolas Klauser9d905312022-02-10 12:33:03923#include <__algorithm/ranges_swap_ranges.h>
Nikolas Klauser3ba85482022-04-05 09:05:36924#include <__algorithm/ranges_transform.h>
Louis Dionne134723e2021-06-17 15:30:11925#include <__algorithm/remove.h>
926#include <__algorithm/remove_copy.h>
927#include <__algorithm/remove_copy_if.h>
928#include <__algorithm/remove_if.h>
929#include <__algorithm/replace.h>
930#include <__algorithm/replace_copy.h>
931#include <__algorithm/replace_copy_if.h>
932#include <__algorithm/replace_if.h>
933#include <__algorithm/reverse.h>
934#include <__algorithm/reverse_copy.h>
935#include <__algorithm/rotate.h>
936#include <__algorithm/rotate_copy.h>
937#include <__algorithm/sample.h>
938#include <__algorithm/search.h>
939#include <__algorithm/search_n.h>
940#include <__algorithm/set_difference.h>
941#include <__algorithm/set_intersection.h>
942#include <__algorithm/set_symmetric_difference.h>
943#include <__algorithm/set_union.h>
944#include <__algorithm/shift_left.h>
945#include <__algorithm/shift_right.h>
946#include <__algorithm/shuffle.h>
947#include <__algorithm/sift_down.h>
948#include <__algorithm/sort.h>
949#include <__algorithm/sort_heap.h>
950#include <__algorithm/stable_partition.h>
951#include <__algorithm/stable_sort.h>
Christopher Di Bella6adbc832021-06-05 02:47:47952#include <__algorithm/swap_ranges.h>
Louis Dionne134723e2021-06-17 15:30:11953#include <__algorithm/transform.h>
Louis Dionne134723e2021-06-17 15:30:11954#include <__algorithm/unique.h>
Arthur O'Dwyer4d81a462022-01-07 14:45:05955#include <__algorithm/unique_copy.h>
Louis Dionne134723e2021-06-17 15:30:11956#include <__algorithm/unwrap_iter.h>
957#include <__algorithm/upper_bound.h>
Eric Fiselierc1bd9192014-08-10 23:53:08958
Howard Hinnant073458b2011-10-17 20:05:10959#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Arthur O'Dwyerfa6b9e42022-02-02 01:16:40960# pragma GCC system_header
Howard Hinnant073458b2011-10-17 20:05:10961#endif
Howard Hinnant3e519522010-05-11 19:42:16962
Louis Dionne0a06eb92019-08-05 18:29:14963#if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17
Louis Dionne95689242019-08-06 21:11:24964# include <__pstl_algorithm>
Louis Dionne0a06eb92019-08-05 18:29:14965#endif
966
Louis Dionne4cd6ca12021-04-20 16:03:32967#endif // _LIBCPP_ALGORITHM