blob: 401e91841bdc1a2879d6b5ec75d0ecccb6e89661 [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 Klauserd3729bb2022-01-14 01:55:51168}
169
Marshall Clow706ffef2018-01-15 17:20:36170 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16171 all_of(InputIterator first, InputIterator last, Predicate pred);
172
173template <class InputIterator, class Predicate>
Marshall Clow706ffef2018-01-15 17:20:36174 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16175 any_of(InputIterator first, InputIterator last, Predicate pred);
176
177template <class InputIterator, class Predicate>
Marshall Clow706ffef2018-01-15 17:20:36178 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16179 none_of(InputIterator first, InputIterator last, Predicate pred);
180
181template <class InputIterator, class Function>
Marshall Clow1b9a4ff2018-01-22 20:44:33182 constexpr Function // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16183 for_each(InputIterator first, InputIterator last, Function f);
184
Marshall Clowd5c65ff2017-05-25 02:29:54185template<class InputIterator, class Size, class Function>
Marshall Clow1b9a4ff2018-01-22 20:44:33186 constexpr InputIterator // constexpr in C++20
187 for_each_n(InputIterator first, Size n, Function f); // C++17
Marshall Clowd5c65ff2017-05-25 02:29:54188
Howard Hinnant3e519522010-05-11 19:42:16189template <class InputIterator, class T>
Marshall Clow86944282018-01-15 19:26:05190 constexpr InputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16191 find(InputIterator first, InputIterator last, const T& value);
192
193template <class InputIterator, class Predicate>
Marshall Clow86944282018-01-15 19:26:05194 constexpr InputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16195 find_if(InputIterator first, InputIterator last, Predicate pred);
196
197template<class InputIterator, class Predicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18198 constexpr InputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16199 find_if_not(InputIterator first, InputIterator last, Predicate pred);
200
201template <class ForwardIterator1, class ForwardIterator2>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18202 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16203 find_end(ForwardIterator1 first1, ForwardIterator1 last1,
204 ForwardIterator2 first2, ForwardIterator2 last2);
205
206template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18207 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16208 find_end(ForwardIterator1 first1, ForwardIterator1 last1,
209 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
210
211template <class ForwardIterator1, class ForwardIterator2>
Marshall Clow86944282018-01-15 19:26:05212 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16213 find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
214 ForwardIterator2 first2, ForwardIterator2 last2);
215
216template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow86944282018-01-15 19:26:05217 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16218 find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
219 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
220
221template <class ForwardIterator>
Marshall Clow86944282018-01-15 19:26:05222 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16223 adjacent_find(ForwardIterator first, ForwardIterator last);
224
225template <class ForwardIterator, class BinaryPredicate>
Marshall Clow86944282018-01-15 19:26:05226 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16227 adjacent_find(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
228
229template <class InputIterator, class T>
Marshall Clow056f15e2018-01-15 19:40:34230 constexpr typename iterator_traits<InputIterator>::difference_type // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16231 count(InputIterator first, InputIterator last, const T& value);
232
233template <class InputIterator, class Predicate>
Marshall Clow056f15e2018-01-15 19:40:34234 constexpr typename iterator_traits<InputIterator>::difference_type // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16235 count_if(InputIterator first, InputIterator last, Predicate pred);
236
237template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:10238 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16239 mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
240
Marshall Clow0b0bbd22013-05-09 21:14:23241template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:10242 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Aditya Kumar331fb802016-08-25 11:52:38243 mismatch(InputIterator1 first1, InputIterator1 last1,
Marshall Clow0b0bbd22013-05-09 21:14:23244 InputIterator2 first2, InputIterator2 last2); // **C++14**
245
Howard Hinnant3e519522010-05-11 19:42:16246template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:10247 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16248 mismatch(InputIterator1 first1, InputIterator1 last1,
249 InputIterator2 first2, BinaryPredicate pred);
250
Marshall Clow0b0bbd22013-05-09 21:14:23251template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:10252 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23253 mismatch(InputIterator1 first1, InputIterator1 last1,
254 InputIterator2 first2, InputIterator2 last2,
255 BinaryPredicate pred); // **C++14**
256
Howard Hinnant3e519522010-05-11 19:42:16257template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:10258 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16259 equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
260
Marshall Clow0b0bbd22013-05-09 21:14:23261template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:10262 constexpr bool // constexpr in C++20
Aditya Kumar331fb802016-08-25 11:52:38263 equal(InputIterator1 first1, InputIterator1 last1,
Marshall Clow0b0bbd22013-05-09 21:14:23264 InputIterator2 first2, InputIterator2 last2); // **C++14**
265
Howard Hinnant3e519522010-05-11 19:42:16266template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:10267 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16268 equal(InputIterator1 first1, InputIterator1 last1,
269 InputIterator2 first2, BinaryPredicate pred);
270
Marshall Clow0b0bbd22013-05-09 21:14:23271template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:10272 constexpr bool // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23273 equal(InputIterator1 first1, InputIterator1 last1,
274 InputIterator2 first2, InputIterator2 last2,
275 BinaryPredicate pred); // **C++14**
276
Howard Hinnant3e519522010-05-11 19:42:16277template<class ForwardIterator1, class ForwardIterator2>
Marshall Clow49c76432018-01-15 16:16:32278 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16279 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
280 ForwardIterator2 first2);
281
Marshall Clow0b0bbd22013-05-09 21:14:23282template<class ForwardIterator1, class ForwardIterator2>
Marshall Clow49c76432018-01-15 16:16:32283 constexpr bool // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23284 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
285 ForwardIterator2 first2, ForwardIterator2 last2); // **C++14**
286
Howard Hinnant3e519522010-05-11 19:42:16287template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow49c76432018-01-15 16:16:32288 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16289 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
290 ForwardIterator2 first2, BinaryPredicate pred);
291
Marshall Clow0b0bbd22013-05-09 21:14:23292template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow49c76432018-01-15 16:16:32293 constexpr bool // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23294 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
295 ForwardIterator2 first2, ForwardIterator2 last2,
296 BinaryPredicate pred); // **C++14**
297
Howard Hinnant3e519522010-05-11 19:42:16298template <class ForwardIterator1, class ForwardIterator2>
Marshall Clow12f0a772018-01-16 15:48:27299 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16300 search(ForwardIterator1 first1, ForwardIterator1 last1,
301 ForwardIterator2 first2, ForwardIterator2 last2);
302
303template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow12f0a772018-01-16 15:48:27304 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16305 search(ForwardIterator1 first1, ForwardIterator1 last1,
306 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
307
308template <class ForwardIterator, class Size, class T>
Marshall Clow12f0a772018-01-16 15:48:27309 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16310 search_n(ForwardIterator first, ForwardIterator last, Size count, const T& value);
311
312template <class ForwardIterator, class Size, class T, class BinaryPredicate>
Marshall Clow12f0a772018-01-16 15:48:27313 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16314 search_n(ForwardIterator first, ForwardIterator last,
315 Size count, const T& value, BinaryPredicate pred);
316
317template <class InputIterator, class OutputIterator>
Louis Dionne13c90a52019-11-06 12:02:41318 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16319 copy(InputIterator first, InputIterator last, OutputIterator result);
320
321template<class InputIterator, class OutputIterator, class Predicate>
Louis Dionne13c90a52019-11-06 12:02:41322 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16323 copy_if(InputIterator first, InputIterator last,
324 OutputIterator result, Predicate pred);
325
326template<class InputIterator, class Size, class OutputIterator>
Louis Dionne13c90a52019-11-06 12:02:41327 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16328 copy_n(InputIterator first, Size n, OutputIterator result);
329
330template <class BidirectionalIterator1, class BidirectionalIterator2>
Louis Dionne13c90a52019-11-06 12:02:41331 constexpr BidirectionalIterator2 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16332 copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last,
333 BidirectionalIterator2 result);
334
335template <class ForwardIterator1, class ForwardIterator2>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18336 constexpr ForwardIterator2 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16337 swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2);
338
Nikolas Klauser9d905312022-02-10 12:33:03339template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2>
340 requires indirectly_swappable<I1, I2>
341 constexpr ranges::swap_ranges_result<I1, I2>
342 ranges::swap_ranges(I1 first1, S1 last1, I2 first2, S2 last2);
343
344template<input_range R1, input_range R2>
345 requires indirectly_swappable<iterator_t<R1>, iterator_t<R2>>
346 constexpr ranges::swap_ranges_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>>
347 ranges::swap_ranges(R1&& r1, R2&& r2);
348
Howard Hinnant3e519522010-05-11 19:42:16349template <class ForwardIterator1, class ForwardIterator2>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18350 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16351 iter_swap(ForwardIterator1 a, ForwardIterator2 b);
352
353template <class InputIterator, class OutputIterator, class UnaryOperation>
Marshall Clow99894b62018-01-19 17:45:39354 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16355 transform(InputIterator first, InputIterator last, OutputIterator result, UnaryOperation op);
356
357template <class InputIterator1, class InputIterator2, class OutputIterator, class BinaryOperation>
Marshall Clow99894b62018-01-19 17:45:39358 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16359 transform(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2,
360 OutputIterator result, BinaryOperation binary_op);
361
362template <class ForwardIterator, class T>
Marshall Clow12c74232018-01-19 18:07:29363 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16364 replace(ForwardIterator first, ForwardIterator last, const T& old_value, const T& new_value);
365
366template <class ForwardIterator, class Predicate, class T>
Marshall Clow12c74232018-01-19 18:07:29367 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16368 replace_if(ForwardIterator first, ForwardIterator last, Predicate pred, const T& new_value);
369
370template <class InputIterator, class OutputIterator, class T>
Marshall Clow12c74232018-01-19 18:07:29371 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16372 replace_copy(InputIterator first, InputIterator last, OutputIterator result,
373 const T& old_value, const T& new_value);
374
375template <class InputIterator, class OutputIterator, class Predicate, class T>
Marshall Clow12c74232018-01-19 18:07:29376 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16377 replace_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred, const T& new_value);
378
379template <class ForwardIterator, class T>
Marshall Clow4bfb9312018-01-20 20:14:32380 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16381 fill(ForwardIterator first, ForwardIterator last, const T& value);
382
383template <class OutputIterator, class Size, class T>
Marshall Clow4bfb9312018-01-20 20:14:32384 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16385 fill_n(OutputIterator first, Size n, const T& value);
386
387template <class ForwardIterator, class Generator>
Marshall Clow4bfb9312018-01-20 20:14:32388 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16389 generate(ForwardIterator first, ForwardIterator last, Generator gen);
390
391template <class OutputIterator, class Size, class Generator>
Marshall Clow4bfb9312018-01-20 20:14:32392 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16393 generate_n(OutputIterator first, Size n, Generator gen);
394
395template <class ForwardIterator, class T>
Marshall Clowe8ea8292018-01-22 21:43:04396 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16397 remove(ForwardIterator first, ForwardIterator last, const T& value);
398
399template <class ForwardIterator, class Predicate>
Marshall Clowe8ea8292018-01-22 21:43:04400 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16401 remove_if(ForwardIterator first, ForwardIterator last, Predicate pred);
402
403template <class InputIterator, class OutputIterator, class T>
Marshall Clowe8ea8292018-01-22 21:43:04404 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16405 remove_copy(InputIterator first, InputIterator last, OutputIterator result, const T& value);
406
407template <class InputIterator, class OutputIterator, class Predicate>
Marshall Clowe8ea8292018-01-22 21:43:04408 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16409 remove_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred);
410
411template <class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18412 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16413 unique(ForwardIterator first, ForwardIterator last);
414
415template <class ForwardIterator, class BinaryPredicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18416 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16417 unique(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
418
419template <class InputIterator, class OutputIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18420 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16421 unique_copy(InputIterator first, InputIterator last, OutputIterator result);
422
423template <class InputIterator, class OutputIterator, class BinaryPredicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18424 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16425 unique_copy(InputIterator first, InputIterator last, OutputIterator result, BinaryPredicate pred);
426
427template <class BidirectionalIterator>
Arthur O'Dwyerf851db32020-12-17 05:01:08428 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16429 reverse(BidirectionalIterator first, BidirectionalIterator last);
430
431template <class BidirectionalIterator, class OutputIterator>
Marshall Clowe8ea8292018-01-22 21:43:04432 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16433 reverse_copy(BidirectionalIterator first, BidirectionalIterator last, OutputIterator result);
434
435template <class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18436 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16437 rotate(ForwardIterator first, ForwardIterator middle, ForwardIterator last);
438
439template <class ForwardIterator, class OutputIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18440 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16441 rotate_copy(ForwardIterator first, ForwardIterator middle, ForwardIterator last, OutputIterator result);
442
443template <class RandomAccessIterator>
444 void
Marshall Clow0f37a412017-03-23 13:43:37445 random_shuffle(RandomAccessIterator first, RandomAccessIterator last); // deprecated in C++14, removed in C++17
Howard Hinnant3e519522010-05-11 19:42:16446
447template <class RandomAccessIterator, class RandomNumberGenerator>
448 void
Marshall Clow06965c12014-03-03 06:14:19449 random_shuffle(RandomAccessIterator first, RandomAccessIterator last,
Marshall Clow0f37a412017-03-23 13:43:37450 RandomNumberGenerator& rand); // deprecated in C++14, removed in C++17
Howard Hinnant3e519522010-05-11 19:42:16451
Eric Fiseliere7154702016-08-28 22:14:37452template<class PopulationIterator, class SampleIterator,
453 class Distance, class UniformRandomBitGenerator>
454 SampleIterator sample(PopulationIterator first, PopulationIterator last,
455 SampleIterator out, Distance n,
456 UniformRandomBitGenerator&& g); // C++17
457
Howard Hinnantf9d540b2010-05-26 17:49:34458template<class RandomAccessIterator, class UniformRandomNumberGenerator>
459 void shuffle(RandomAccessIterator first, RandomAccessIterator last,
Howard Hinnantfb340102010-11-18 01:47:02460 UniformRandomNumberGenerator&& g);
Howard Hinnantf9d540b2010-05-26 17:49:34461
Arthur O'Dwyer3fbd3ea2020-12-26 06:39:03462template<class ForwardIterator>
463 constexpr ForwardIterator
464 shift_left(ForwardIterator first, ForwardIterator last,
465 typename iterator_traits<ForwardIterator>::difference_type n); // C++20
466
467template<class ForwardIterator>
468 constexpr ForwardIterator
469 shift_right(ForwardIterator first, ForwardIterator last,
470 typename iterator_traits<ForwardIterator>::difference_type n); // C++20
471
Howard Hinnant3e519522010-05-11 19:42:16472template <class InputIterator, class Predicate>
Marshall Clow49c76432018-01-15 16:16:32473 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16474 is_partitioned(InputIterator first, InputIterator last, Predicate pred);
475
476template <class ForwardIterator, class Predicate>
Arthur O'Dwyerf851db32020-12-17 05:01:08477 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16478 partition(ForwardIterator first, ForwardIterator last, Predicate pred);
479
480template <class InputIterator, class OutputIterator1,
481 class OutputIterator2, class Predicate>
Marshall Clow1b9a4ff2018-01-22 20:44:33482 constexpr pair<OutputIterator1, OutputIterator2> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16483 partition_copy(InputIterator first, InputIterator last,
484 OutputIterator1 out_true, OutputIterator2 out_false,
485 Predicate pred);
486
487template <class ForwardIterator, class Predicate>
488 ForwardIterator
489 stable_partition(ForwardIterator first, ForwardIterator last, Predicate pred);
490
491template<class ForwardIterator, class Predicate>
Marshall Clowd57c03d2018-01-16 02:34:41492 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16493 partition_point(ForwardIterator first, ForwardIterator last, Predicate pred);
494
495template <class ForwardIterator>
Marshall Clow49c76432018-01-15 16:16:32496 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16497 is_sorted(ForwardIterator first, ForwardIterator last);
498
499template <class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18500 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16501 is_sorted(ForwardIterator first, ForwardIterator last, Compare comp);
502
503template<class ForwardIterator>
Marshall Clow056f15e2018-01-15 19:40:34504 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16505 is_sorted_until(ForwardIterator first, ForwardIterator last);
506
507template <class ForwardIterator, class Compare>
Marshall Clow056f15e2018-01-15 19:40:34508 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16509 is_sorted_until(ForwardIterator first, ForwardIterator last, Compare comp);
510
511template <class RandomAccessIterator>
Arthur O'Dwyer493f1402020-12-20 20:21:42512 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16513 sort(RandomAccessIterator first, RandomAccessIterator last);
514
515template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer493f1402020-12-20 20:21:42516 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16517 sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
518
519template <class RandomAccessIterator>
520 void
521 stable_sort(RandomAccessIterator first, RandomAccessIterator last);
522
523template <class RandomAccessIterator, class Compare>
524 void
525 stable_sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
526
527template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18528 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16529 partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last);
530
531template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18532 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16533 partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last, Compare comp);
534
535template <class InputIterator, class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18536 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16537 partial_sort_copy(InputIterator first, InputIterator last,
538 RandomAccessIterator result_first, RandomAccessIterator result_last);
539
540template <class InputIterator, class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18541 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16542 partial_sort_copy(InputIterator first, InputIterator last,
543 RandomAccessIterator result_first, RandomAccessIterator result_last, Compare comp);
544
545template <class RandomAccessIterator>
Arthur O'Dwyer5d956562021-02-04 23:12:52546 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16547 nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last);
548
549template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5d956562021-02-04 23:12:52550 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16551 nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last, Compare comp);
552
553template <class ForwardIterator, class T>
Marshall Clowd57c03d2018-01-16 02:34:41554 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16555 lower_bound(ForwardIterator first, ForwardIterator last, const T& value);
556
557template <class ForwardIterator, class T, class Compare>
Marshall Clowd57c03d2018-01-16 02:34:41558 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16559 lower_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
560
561template <class ForwardIterator, class T>
Marshall Clowd57c03d2018-01-16 02:34:41562 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16563 upper_bound(ForwardIterator first, ForwardIterator last, const T& value);
564
565template <class ForwardIterator, class T, class Compare>
Marshall Clowd57c03d2018-01-16 02:34:41566 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16567 upper_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
568
569template <class ForwardIterator, class T>
Marshall Clowd57c03d2018-01-16 02:34:41570 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16571 equal_range(ForwardIterator first, ForwardIterator last, const T& value);
572
573template <class ForwardIterator, class T, class Compare>
Marshall Clowd57c03d2018-01-16 02:34:41574 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16575 equal_range(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
576
577template <class ForwardIterator, class T>
Marshall Clowd57c03d2018-01-16 02:34:41578 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16579 binary_search(ForwardIterator first, ForwardIterator last, const T& value);
580
581template <class ForwardIterator, class T, class Compare>
Marshall Clow8da1a482018-01-22 23:10:40582 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16583 binary_search(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
584
585template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer14098cf2020-12-04 18:47:12586 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16587 merge(InputIterator1 first1, InputIterator1 last1,
588 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
589
590template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer14098cf2020-12-04 18:47:12591 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16592 merge(InputIterator1 first1, InputIterator1 last1,
593 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
594
595template <class BidirectionalIterator>
596 void
597 inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last);
598
599template <class BidirectionalIterator, class Compare>
600 void
601 inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last, Compare comp);
602
603template <class InputIterator1, class InputIterator2>
Marshall Clow8da1a482018-01-22 23:10:40604 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16605 includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
606
607template <class InputIterator1, class InputIterator2, class Compare>
Marshall Clow8da1a482018-01-22 23:10:40608 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16609 includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, 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 set_union(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 set_union(InputIterator1 first1, InputIterator1 last1,
619 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
620
621template <class InputIterator1, class InputIterator2, class OutputIterator>
Marshall Clow8da1a482018-01-22 23:10:40622 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16623 set_intersection(InputIterator1 first1, InputIterator1 last1,
624 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
625
626template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Marshall Clow8da1a482018-01-22 23:10:40627 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16628 set_intersection(InputIterator1 first1, InputIterator1 last1,
629 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
630
631template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer14098cf2020-12-04 18:47:12632 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16633 set_difference(InputIterator1 first1, InputIterator1 last1,
634 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
635
636template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer14098cf2020-12-04 18:47:12637 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16638 set_difference(InputIterator1 first1, InputIterator1 last1,
639 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
640
641template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer14098cf2020-12-04 18:47:12642 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16643 set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
644 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
645
646template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer14098cf2020-12-04 18:47:12647 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16648 set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
649 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
650
651template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18652 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16653 push_heap(RandomAccessIterator first, RandomAccessIterator last);
654
655template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18656 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16657 push_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
658
659template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18660 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16661 pop_heap(RandomAccessIterator first, RandomAccessIterator last);
662
663template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18664 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16665 pop_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
666
667template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18668 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16669 make_heap(RandomAccessIterator first, RandomAccessIterator last);
670
671template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18672 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16673 make_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
674
675template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18676 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16677 sort_heap(RandomAccessIterator first, RandomAccessIterator last);
678
679template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18680 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16681 sort_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
682
Howard Hinnantb3371f62010-08-22 00:02:43683template <class RandomAccessIterator>
Marshall Clow49c76432018-01-15 16:16:32684 constexpr bool // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43685 is_heap(RandomAccessIterator first, RandomAccessiterator last);
Howard Hinnant3e519522010-05-11 19:42:16686
Howard Hinnantb3371f62010-08-22 00:02:43687template <class RandomAccessIterator, class Compare>
Marshall Clow49c76432018-01-15 16:16:32688 constexpr bool // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43689 is_heap(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16690
Howard Hinnantb3371f62010-08-22 00:02:43691template <class RandomAccessIterator>
Marshall Clow49c76432018-01-15 16:16:32692 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43693 is_heap_until(RandomAccessIterator first, RandomAccessiterator last);
Howard Hinnant3e519522010-05-11 19:42:16694
Howard Hinnantb3371f62010-08-22 00:02:43695template <class RandomAccessIterator, class Compare>
Marshall Clow49c76432018-01-15 16:16:32696 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43697 is_heap_until(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16698
Howard Hinnant4eb27b72010-08-21 20:10:01699template <class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18700 constexpr ForwardIterator // constexpr in C++14
701 min_element(ForwardIterator first, ForwardIterator last);
Howard Hinnant4eb27b72010-08-21 20:10:01702
703template <class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18704 constexpr ForwardIterator // constexpr in C++14
705 min_element(ForwardIterator first, ForwardIterator last, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01706
Howard Hinnant3e519522010-05-11 19:42:16707template <class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18708 constexpr const T& // constexpr in C++14
709 min(const T& a, const T& b);
Howard Hinnant3e519522010-05-11 19:42:16710
711template <class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18712 constexpr const T& // constexpr in C++14
713 min(const T& a, const T& b, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16714
Howard Hinnant4eb27b72010-08-21 20:10:01715template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18716 constexpr T // constexpr in C++14
717 min(initializer_list<T> t);
Howard Hinnant4eb27b72010-08-21 20:10:01718
719template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18720 constexpr T // constexpr in C++14
721 min(initializer_list<T> t, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01722
Marshall Clow146c14a2016-03-07 22:43:49723template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18724 constexpr const T& clamp(const T& v, const T& lo, const T& hi); // C++17
Marshall Clow146c14a2016-03-07 22:43:49725
726template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18727 constexpr const T& clamp(const T& v, const T& lo, const T& hi, Compare comp); // C++17
Marshall Clow146c14a2016-03-07 22:43:49728
Howard Hinnant4eb27b72010-08-21 20:10:01729template <class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18730 constexpr ForwardIterator // constexpr in C++14
731 max_element(ForwardIterator first, ForwardIterator last);
Howard Hinnant4eb27b72010-08-21 20:10:01732
733template <class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18734 constexpr ForwardIterator // constexpr in C++14
735 max_element(ForwardIterator first, ForwardIterator last, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01736
Howard Hinnant3e519522010-05-11 19:42:16737template <class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18738 constexpr const T& // constexpr in C++14
739 max(const T& a, const T& b);
Howard Hinnant3e519522010-05-11 19:42:16740
741template <class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18742 constexpr const T& // constexpr in C++14
743 max(const T& a, const T& b, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16744
Howard Hinnant4eb27b72010-08-21 20:10:01745template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18746 constexpr T // constexpr in C++14
747 max(initializer_list<T> t);
Howard Hinnant3e519522010-05-11 19:42:16748
Howard Hinnant4eb27b72010-08-21 20:10:01749template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18750 constexpr T // constexpr in C++14
751 max(initializer_list<T> t, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16752
Howard Hinnant4eb27b72010-08-21 20:10:01753template<class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18754 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++14
755 minmax_element(ForwardIterator first, ForwardIterator last);
Howard Hinnant3e519522010-05-11 19:42:16756
Howard Hinnant4eb27b72010-08-21 20:10:01757template<class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18758 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++14
759 minmax_element(ForwardIterator first, ForwardIterator last, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01760
761template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18762 constexpr pair<const T&, const T&> // constexpr in C++14
763 minmax(const T& a, const T& b);
Howard Hinnant4eb27b72010-08-21 20:10:01764
765template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18766 constexpr pair<const T&, const T&> // constexpr in C++14
767 minmax(const T& a, const T& b, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01768
769template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18770 constexpr pair<T, T> // constexpr in C++14
771 minmax(initializer_list<T> t);
Howard Hinnant4eb27b72010-08-21 20:10:01772
773template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18774 constexpr pair<T, T> // constexpr in C++14
775 minmax(initializer_list<T> t, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16776
777template <class InputIterator1, class InputIterator2>
Marshall Clow1b9a4ff2018-01-22 20:44:33778 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16779 lexicographical_compare(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
780
781template <class InputIterator1, class InputIterator2, class Compare>
Marshall Clow1b9a4ff2018-01-22 20:44:33782 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16783 lexicographical_compare(InputIterator1 first1, InputIterator1 last1,
784 InputIterator2 first2, InputIterator2 last2, Compare comp);
785
786template <class BidirectionalIterator>
Arthur O'Dwyerf851db32020-12-17 05:01:08787 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16788 next_permutation(BidirectionalIterator first, BidirectionalIterator last);
789
790template <class BidirectionalIterator, class Compare>
Arthur O'Dwyerf851db32020-12-17 05:01:08791 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16792 next_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
793
794template <class BidirectionalIterator>
Arthur O'Dwyerf851db32020-12-17 05:01:08795 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16796 prev_permutation(BidirectionalIterator first, BidirectionalIterator last);
797
798template <class BidirectionalIterator, class Compare>
Arthur O'Dwyerf851db32020-12-17 05:01:08799 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16800 prev_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16801} // std
802
803*/
804
Louis Dionne385cc252022-03-25 16:55:36805#include <__assert> // all public C++ headers provide the assertion handler
Arthur O'Dwyerea2206d2022-02-04 18:09:30806#include <__bits>
Howard Hinnant3e519522010-05-11 19:42:16807#include <__config>
Louis Dionne134723e2021-06-17 15:30:11808#include <__debug>
Howard Hinnanta1d07d52012-07-26 17:09:09809#include <cstddef>
Arthur O'Dwyerbfbd73f2021-05-19 15:57:04810#include <cstring>
811#include <functional>
812#include <initializer_list>
Arthur O'Dwyerbfbd73f2021-05-19 15:57:04813#include <iterator>
814#include <memory>
815#include <type_traits>
Marshall Clowf56972e2018-09-12 19:41:40816#include <version>
Howard Hinnant5d1a7012013-08-14 18:00:20817
Louis Dionne134723e2021-06-17 15:30:11818#include <__algorithm/adjacent_find.h>
819#include <__algorithm/all_of.h>
820#include <__algorithm/any_of.h>
821#include <__algorithm/binary_search.h>
822#include <__algorithm/clamp.h>
823#include <__algorithm/comp.h>
824#include <__algorithm/comp_ref_type.h>
825#include <__algorithm/copy.h>
826#include <__algorithm/copy_backward.h>
827#include <__algorithm/copy_if.h>
828#include <__algorithm/copy_n.h>
829#include <__algorithm/count.h>
830#include <__algorithm/count_if.h>
831#include <__algorithm/equal.h>
832#include <__algorithm/equal_range.h>
Louis Dionne134723e2021-06-17 15:30:11833#include <__algorithm/fill.h>
Arthur O'Dwyer4d81a462022-01-07 14:45:05834#include <__algorithm/fill_n.h>
Louis Dionne134723e2021-06-17 15:30:11835#include <__algorithm/find.h>
836#include <__algorithm/find_end.h>
837#include <__algorithm/find_first_of.h>
838#include <__algorithm/find_if.h>
839#include <__algorithm/find_if_not.h>
840#include <__algorithm/for_each.h>
841#include <__algorithm/for_each_n.h>
Louis Dionne134723e2021-06-17 15:30:11842#include <__algorithm/generate.h>
Arthur O'Dwyer4d81a462022-01-07 14:45:05843#include <__algorithm/generate_n.h>
Louis Dionne134723e2021-06-17 15:30:11844#include <__algorithm/half_positive.h>
Nikolas Klauser68f41312022-02-21 22:07:02845#include <__algorithm/in_found_result.h>
Nikolas Klauser1e77b392022-02-11 16:01:58846#include <__algorithm/in_fun_result.h>
Nikolas Klauserf3514af2022-01-25 10:21:47847#include <__algorithm/in_in_out_result.h>
Nikolas Klauserd3729bb2022-01-14 01:55:51848#include <__algorithm/in_in_result.h>
Nikolas Klauser610979b2022-02-03 01:17:03849#include <__algorithm/in_out_out_result.h>
Konstantin Varlamov8d23b742022-01-11 06:49:37850#include <__algorithm/in_out_result.h>
Louis Dionne134723e2021-06-17 15:30:11851#include <__algorithm/includes.h>
852#include <__algorithm/inplace_merge.h>
853#include <__algorithm/is_heap.h>
854#include <__algorithm/is_heap_until.h>
855#include <__algorithm/is_partitioned.h>
856#include <__algorithm/is_permutation.h>
857#include <__algorithm/is_sorted.h>
858#include <__algorithm/is_sorted_until.h>
Christopher Di Bella6adbc832021-06-05 02:47:47859#include <__algorithm/iter_swap.h>
Louis Dionne134723e2021-06-17 15:30:11860#include <__algorithm/lexicographical_compare.h>
861#include <__algorithm/lower_bound.h>
862#include <__algorithm/make_heap.h>
863#include <__algorithm/max.h>
864#include <__algorithm/max_element.h>
865#include <__algorithm/merge.h>
866#include <__algorithm/min.h>
867#include <__algorithm/min_element.h>
Nikolas Klauser807766b2022-02-21 21:48:36868#include <__algorithm/min_max_result.h>
Louis Dionne134723e2021-06-17 15:30:11869#include <__algorithm/minmax.h>
870#include <__algorithm/minmax_element.h>
871#include <__algorithm/mismatch.h>
872#include <__algorithm/move.h>
873#include <__algorithm/move_backward.h>
874#include <__algorithm/next_permutation.h>
875#include <__algorithm/none_of.h>
876#include <__algorithm/nth_element.h>
877#include <__algorithm/partial_sort.h>
878#include <__algorithm/partial_sort_copy.h>
879#include <__algorithm/partition.h>
880#include <__algorithm/partition_copy.h>
881#include <__algorithm/partition_point.h>
882#include <__algorithm/pop_heap.h>
883#include <__algorithm/prev_permutation.h>
884#include <__algorithm/push_heap.h>
Nikolas Klauser1306b102022-04-07 11:02:02885#include <__algorithm/ranges_count.h>
886#include <__algorithm/ranges_count_if.h>
Nikolas Klauseree0f8c42022-03-12 00:45:35887#include <__algorithm/ranges_find.h>
888#include <__algorithm/ranges_find_if.h>
889#include <__algorithm/ranges_find_if_not.h>
Nikolas Klausere476df52022-04-03 07:17:01890#include <__algorithm/ranges_max.h>
Nikolas Klauser205557c2022-03-07 16:01:52891#include <__algorithm/ranges_max_element.h>
Nikolas Klauserf83d8332022-03-18 01:57:08892#include <__algorithm/ranges_min.h>
Nikolas Klauser3b470d12022-02-11 12:11:57893#include <__algorithm/ranges_min_element.h>
Nikolas Klauserc2cd15a2022-03-08 22:12:35894#include <__algorithm/ranges_mismatch.h>
Nikolas Klauser9d905312022-02-10 12:33:03895#include <__algorithm/ranges_swap_ranges.h>
Nikolas Klauser3ba85482022-04-05 09:05:36896#include <__algorithm/ranges_transform.h>
Louis Dionne134723e2021-06-17 15:30:11897#include <__algorithm/remove.h>
898#include <__algorithm/remove_copy.h>
899#include <__algorithm/remove_copy_if.h>
900#include <__algorithm/remove_if.h>
901#include <__algorithm/replace.h>
902#include <__algorithm/replace_copy.h>
903#include <__algorithm/replace_copy_if.h>
904#include <__algorithm/replace_if.h>
905#include <__algorithm/reverse.h>
906#include <__algorithm/reverse_copy.h>
907#include <__algorithm/rotate.h>
908#include <__algorithm/rotate_copy.h>
909#include <__algorithm/sample.h>
910#include <__algorithm/search.h>
911#include <__algorithm/search_n.h>
912#include <__algorithm/set_difference.h>
913#include <__algorithm/set_intersection.h>
914#include <__algorithm/set_symmetric_difference.h>
915#include <__algorithm/set_union.h>
916#include <__algorithm/shift_left.h>
917#include <__algorithm/shift_right.h>
918#include <__algorithm/shuffle.h>
919#include <__algorithm/sift_down.h>
920#include <__algorithm/sort.h>
921#include <__algorithm/sort_heap.h>
922#include <__algorithm/stable_partition.h>
923#include <__algorithm/stable_sort.h>
Christopher Di Bella6adbc832021-06-05 02:47:47924#include <__algorithm/swap_ranges.h>
Louis Dionne134723e2021-06-17 15:30:11925#include <__algorithm/transform.h>
Louis Dionne134723e2021-06-17 15:30:11926#include <__algorithm/unique.h>
Arthur O'Dwyer4d81a462022-01-07 14:45:05927#include <__algorithm/unique_copy.h>
Louis Dionne134723e2021-06-17 15:30:11928#include <__algorithm/unwrap_iter.h>
929#include <__algorithm/upper_bound.h>
Eric Fiselierc1bd9192014-08-10 23:53:08930
Howard Hinnant073458b2011-10-17 20:05:10931#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Arthur O'Dwyerfa6b9e42022-02-02 01:16:40932# pragma GCC system_header
Howard Hinnant073458b2011-10-17 20:05:10933#endif
Howard Hinnant3e519522010-05-11 19:42:16934
Louis Dionne0a06eb92019-08-05 18:29:14935#if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17
Louis Dionne95689242019-08-06 21:11:24936# include <__pstl_algorithm>
Louis Dionne0a06eb92019-08-05 18:29:14937#endif
938
Louis Dionne4cd6ca12021-04-20 16:03:32939#endif // _LIBCPP_ALGORITHM