blob: 6b5bc0cd9acb96f57a9bfd97d5e2c81b704f5599 [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 Klauserd3729bb2022-01-14 01:55:5147}
48
Howard Hinnant3e519522010-05-11 19:42:1649template <class InputIterator, class Predicate>
Marshall Clow706ffef2018-01-15 17:20:3650 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1651 all_of(InputIterator first, InputIterator last, Predicate pred);
52
53template <class InputIterator, class Predicate>
Marshall Clow706ffef2018-01-15 17:20:3654 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1655 any_of(InputIterator first, InputIterator last, Predicate pred);
56
57template <class InputIterator, class Predicate>
Marshall Clow706ffef2018-01-15 17:20:3658 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1659 none_of(InputIterator first, InputIterator last, Predicate pred);
60
61template <class InputIterator, class Function>
Marshall Clow1b9a4ff2018-01-22 20:44:3362 constexpr Function // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1663 for_each(InputIterator first, InputIterator last, Function f);
64
Marshall Clowd5c65ff2017-05-25 02:29:5465template<class InputIterator, class Size, class Function>
Marshall Clow1b9a4ff2018-01-22 20:44:3366 constexpr InputIterator // constexpr in C++20
67 for_each_n(InputIterator first, Size n, Function f); // C++17
Marshall Clowd5c65ff2017-05-25 02:29:5468
Howard Hinnant3e519522010-05-11 19:42:1669template <class InputIterator, class T>
Marshall Clow86944282018-01-15 19:26:0570 constexpr InputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1671 find(InputIterator first, InputIterator last, const T& value);
72
73template <class InputIterator, class Predicate>
Marshall Clow86944282018-01-15 19:26:0574 constexpr InputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1675 find_if(InputIterator first, InputIterator last, Predicate pred);
76
77template<class InputIterator, class Predicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:1878 constexpr InputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1679 find_if_not(InputIterator first, InputIterator last, Predicate pred);
80
81template <class ForwardIterator1, class ForwardIterator2>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:1882 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1683 find_end(ForwardIterator1 first1, ForwardIterator1 last1,
84 ForwardIterator2 first2, ForwardIterator2 last2);
85
86template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:1887 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1688 find_end(ForwardIterator1 first1, ForwardIterator1 last1,
89 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
90
91template <class ForwardIterator1, class ForwardIterator2>
Marshall Clow86944282018-01-15 19:26:0592 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1693 find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
94 ForwardIterator2 first2, ForwardIterator2 last2);
95
96template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow86944282018-01-15 19:26:0597 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1698 find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
99 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
100
101template <class ForwardIterator>
Marshall Clow86944282018-01-15 19:26:05102 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16103 adjacent_find(ForwardIterator first, ForwardIterator last);
104
105template <class ForwardIterator, class BinaryPredicate>
Marshall Clow86944282018-01-15 19:26:05106 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16107 adjacent_find(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
108
109template <class InputIterator, class T>
Marshall Clow056f15e2018-01-15 19:40:34110 constexpr typename iterator_traits<InputIterator>::difference_type // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16111 count(InputIterator first, InputIterator last, const T& value);
112
113template <class InputIterator, class Predicate>
Marshall Clow056f15e2018-01-15 19:40:34114 constexpr typename iterator_traits<InputIterator>::difference_type // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16115 count_if(InputIterator first, InputIterator last, Predicate pred);
116
117template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:10118 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16119 mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
120
Marshall Clow0b0bbd22013-05-09 21:14:23121template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:10122 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Aditya Kumar331fb802016-08-25 11:52:38123 mismatch(InputIterator1 first1, InputIterator1 last1,
Marshall Clow0b0bbd22013-05-09 21:14:23124 InputIterator2 first2, InputIterator2 last2); // **C++14**
125
Howard Hinnant3e519522010-05-11 19:42:16126template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:10127 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16128 mismatch(InputIterator1 first1, InputIterator1 last1,
129 InputIterator2 first2, BinaryPredicate pred);
130
Marshall Clow0b0bbd22013-05-09 21:14:23131template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:10132 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23133 mismatch(InputIterator1 first1, InputIterator1 last1,
134 InputIterator2 first2, InputIterator2 last2,
135 BinaryPredicate pred); // **C++14**
136
Howard Hinnant3e519522010-05-11 19:42:16137template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:10138 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16139 equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
140
Marshall Clow0b0bbd22013-05-09 21:14:23141template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:10142 constexpr bool // constexpr in C++20
Aditya Kumar331fb802016-08-25 11:52:38143 equal(InputIterator1 first1, InputIterator1 last1,
Marshall Clow0b0bbd22013-05-09 21:14:23144 InputIterator2 first2, InputIterator2 last2); // **C++14**
145
Howard Hinnant3e519522010-05-11 19:42:16146template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:10147 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16148 equal(InputIterator1 first1, InputIterator1 last1,
149 InputIterator2 first2, BinaryPredicate pred);
150
Marshall Clow0b0bbd22013-05-09 21:14:23151template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:10152 constexpr bool // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23153 equal(InputIterator1 first1, InputIterator1 last1,
154 InputIterator2 first2, InputIterator2 last2,
155 BinaryPredicate pred); // **C++14**
156
Howard Hinnant3e519522010-05-11 19:42:16157template<class ForwardIterator1, class ForwardIterator2>
Marshall Clow49c76432018-01-15 16:16:32158 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16159 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
160 ForwardIterator2 first2);
161
Marshall Clow0b0bbd22013-05-09 21:14:23162template<class ForwardIterator1, class ForwardIterator2>
Marshall Clow49c76432018-01-15 16:16:32163 constexpr bool // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23164 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
165 ForwardIterator2 first2, ForwardIterator2 last2); // **C++14**
166
Howard Hinnant3e519522010-05-11 19:42:16167template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow49c76432018-01-15 16:16:32168 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16169 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
170 ForwardIterator2 first2, BinaryPredicate pred);
171
Marshall Clow0b0bbd22013-05-09 21:14:23172template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow49c76432018-01-15 16:16:32173 constexpr bool // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23174 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
175 ForwardIterator2 first2, ForwardIterator2 last2,
176 BinaryPredicate pred); // **C++14**
177
Howard Hinnant3e519522010-05-11 19:42:16178template <class ForwardIterator1, class ForwardIterator2>
Marshall Clow12f0a772018-01-16 15:48:27179 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16180 search(ForwardIterator1 first1, ForwardIterator1 last1,
181 ForwardIterator2 first2, ForwardIterator2 last2);
182
183template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow12f0a772018-01-16 15:48:27184 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16185 search(ForwardIterator1 first1, ForwardIterator1 last1,
186 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
187
188template <class ForwardIterator, class Size, class T>
Marshall Clow12f0a772018-01-16 15:48:27189 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16190 search_n(ForwardIterator first, ForwardIterator last, Size count, const T& value);
191
192template <class ForwardIterator, class Size, class T, class BinaryPredicate>
Marshall Clow12f0a772018-01-16 15:48:27193 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16194 search_n(ForwardIterator first, ForwardIterator last,
195 Size count, const T& value, BinaryPredicate pred);
196
197template <class InputIterator, class OutputIterator>
Louis Dionne13c90a52019-11-06 12:02:41198 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16199 copy(InputIterator first, InputIterator last, OutputIterator result);
200
201template<class InputIterator, class OutputIterator, class Predicate>
Louis Dionne13c90a52019-11-06 12:02:41202 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16203 copy_if(InputIterator first, InputIterator last,
204 OutputIterator result, Predicate pred);
205
206template<class InputIterator, class Size, class OutputIterator>
Louis Dionne13c90a52019-11-06 12:02:41207 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16208 copy_n(InputIterator first, Size n, OutputIterator result);
209
210template <class BidirectionalIterator1, class BidirectionalIterator2>
Louis Dionne13c90a52019-11-06 12:02:41211 constexpr BidirectionalIterator2 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16212 copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last,
213 BidirectionalIterator2 result);
214
215template <class ForwardIterator1, class ForwardIterator2>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18216 constexpr ForwardIterator2 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16217 swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2);
218
Nikolas Klauser9d905312022-02-10 12:33:03219template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2>
220 requires indirectly_swappable<I1, I2>
221 constexpr ranges::swap_ranges_result<I1, I2>
222 ranges::swap_ranges(I1 first1, S1 last1, I2 first2, S2 last2);
223
224template<input_range R1, input_range R2>
225 requires indirectly_swappable<iterator_t<R1>, iterator_t<R2>>
226 constexpr ranges::swap_ranges_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>>
227 ranges::swap_ranges(R1&& r1, R2&& r2);
228
Howard Hinnant3e519522010-05-11 19:42:16229template <class ForwardIterator1, class ForwardIterator2>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18230 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16231 iter_swap(ForwardIterator1 a, ForwardIterator2 b);
232
233template <class InputIterator, class OutputIterator, class UnaryOperation>
Marshall Clow99894b62018-01-19 17:45:39234 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16235 transform(InputIterator first, InputIterator last, OutputIterator result, UnaryOperation op);
236
237template <class InputIterator1, class InputIterator2, class OutputIterator, class BinaryOperation>
Marshall Clow99894b62018-01-19 17:45:39238 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16239 transform(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2,
240 OutputIterator result, BinaryOperation binary_op);
241
242template <class ForwardIterator, class T>
Marshall Clow12c74232018-01-19 18:07:29243 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16244 replace(ForwardIterator first, ForwardIterator last, const T& old_value, const T& new_value);
245
246template <class ForwardIterator, class Predicate, class T>
Marshall Clow12c74232018-01-19 18:07:29247 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16248 replace_if(ForwardIterator first, ForwardIterator last, Predicate pred, const T& new_value);
249
250template <class InputIterator, class OutputIterator, class T>
Marshall Clow12c74232018-01-19 18:07:29251 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16252 replace_copy(InputIterator first, InputIterator last, OutputIterator result,
253 const T& old_value, const T& new_value);
254
255template <class InputIterator, class OutputIterator, class Predicate, class T>
Marshall Clow12c74232018-01-19 18:07:29256 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16257 replace_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred, const T& new_value);
258
259template <class ForwardIterator, class T>
Marshall Clow4bfb9312018-01-20 20:14:32260 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16261 fill(ForwardIterator first, ForwardIterator last, const T& value);
262
263template <class OutputIterator, class Size, class T>
Marshall Clow4bfb9312018-01-20 20:14:32264 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16265 fill_n(OutputIterator first, Size n, const T& value);
266
267template <class ForwardIterator, class Generator>
Marshall Clow4bfb9312018-01-20 20:14:32268 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16269 generate(ForwardIterator first, ForwardIterator last, Generator gen);
270
271template <class OutputIterator, class Size, class Generator>
Marshall Clow4bfb9312018-01-20 20:14:32272 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16273 generate_n(OutputIterator first, Size n, Generator gen);
274
275template <class ForwardIterator, class T>
Marshall Clowe8ea8292018-01-22 21:43:04276 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16277 remove(ForwardIterator first, ForwardIterator last, const T& value);
278
279template <class ForwardIterator, class Predicate>
Marshall Clowe8ea8292018-01-22 21:43:04280 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16281 remove_if(ForwardIterator first, ForwardIterator last, Predicate pred);
282
283template <class InputIterator, class OutputIterator, class T>
Marshall Clowe8ea8292018-01-22 21:43:04284 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16285 remove_copy(InputIterator first, InputIterator last, OutputIterator result, const T& value);
286
287template <class InputIterator, class OutputIterator, class Predicate>
Marshall Clowe8ea8292018-01-22 21:43:04288 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16289 remove_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred);
290
291template <class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18292 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16293 unique(ForwardIterator first, ForwardIterator last);
294
295template <class ForwardIterator, class BinaryPredicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18296 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16297 unique(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
298
299template <class InputIterator, class OutputIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18300 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16301 unique_copy(InputIterator first, InputIterator last, OutputIterator result);
302
303template <class InputIterator, class OutputIterator, class BinaryPredicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18304 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16305 unique_copy(InputIterator first, InputIterator last, OutputIterator result, BinaryPredicate pred);
306
307template <class BidirectionalIterator>
Arthur O'Dwyerf851db32020-12-17 05:01:08308 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16309 reverse(BidirectionalIterator first, BidirectionalIterator last);
310
311template <class BidirectionalIterator, class OutputIterator>
Marshall Clowe8ea8292018-01-22 21:43:04312 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16313 reverse_copy(BidirectionalIterator first, BidirectionalIterator last, OutputIterator result);
314
315template <class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18316 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16317 rotate(ForwardIterator first, ForwardIterator middle, ForwardIterator last);
318
319template <class ForwardIterator, class OutputIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18320 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16321 rotate_copy(ForwardIterator first, ForwardIterator middle, ForwardIterator last, OutputIterator result);
322
323template <class RandomAccessIterator>
324 void
Marshall Clow0f37a412017-03-23 13:43:37325 random_shuffle(RandomAccessIterator first, RandomAccessIterator last); // deprecated in C++14, removed in C++17
Howard Hinnant3e519522010-05-11 19:42:16326
327template <class RandomAccessIterator, class RandomNumberGenerator>
328 void
Marshall Clow06965c12014-03-03 06:14:19329 random_shuffle(RandomAccessIterator first, RandomAccessIterator last,
Marshall Clow0f37a412017-03-23 13:43:37330 RandomNumberGenerator& rand); // deprecated in C++14, removed in C++17
Howard Hinnant3e519522010-05-11 19:42:16331
Eric Fiseliere7154702016-08-28 22:14:37332template<class PopulationIterator, class SampleIterator,
333 class Distance, class UniformRandomBitGenerator>
334 SampleIterator sample(PopulationIterator first, PopulationIterator last,
335 SampleIterator out, Distance n,
336 UniformRandomBitGenerator&& g); // C++17
337
Howard Hinnantf9d540b2010-05-26 17:49:34338template<class RandomAccessIterator, class UniformRandomNumberGenerator>
339 void shuffle(RandomAccessIterator first, RandomAccessIterator last,
Howard Hinnantfb340102010-11-18 01:47:02340 UniformRandomNumberGenerator&& g);
Howard Hinnantf9d540b2010-05-26 17:49:34341
Arthur O'Dwyer3fbd3ea2020-12-26 06:39:03342template<class ForwardIterator>
343 constexpr ForwardIterator
344 shift_left(ForwardIterator first, ForwardIterator last,
345 typename iterator_traits<ForwardIterator>::difference_type n); // C++20
346
347template<class ForwardIterator>
348 constexpr ForwardIterator
349 shift_right(ForwardIterator first, ForwardIterator last,
350 typename iterator_traits<ForwardIterator>::difference_type n); // C++20
351
Howard Hinnant3e519522010-05-11 19:42:16352template <class InputIterator, class Predicate>
Marshall Clow49c76432018-01-15 16:16:32353 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16354 is_partitioned(InputIterator first, InputIterator last, Predicate pred);
355
356template <class ForwardIterator, class Predicate>
Arthur O'Dwyerf851db32020-12-17 05:01:08357 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16358 partition(ForwardIterator first, ForwardIterator last, Predicate pred);
359
360template <class InputIterator, class OutputIterator1,
361 class OutputIterator2, class Predicate>
Marshall Clow1b9a4ff2018-01-22 20:44:33362 constexpr pair<OutputIterator1, OutputIterator2> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16363 partition_copy(InputIterator first, InputIterator last,
364 OutputIterator1 out_true, OutputIterator2 out_false,
365 Predicate pred);
366
367template <class ForwardIterator, class Predicate>
368 ForwardIterator
369 stable_partition(ForwardIterator first, ForwardIterator last, Predicate pred);
370
371template<class ForwardIterator, class Predicate>
Marshall Clowd57c03d2018-01-16 02:34:41372 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16373 partition_point(ForwardIterator first, ForwardIterator last, Predicate pred);
374
375template <class ForwardIterator>
Marshall Clow49c76432018-01-15 16:16:32376 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16377 is_sorted(ForwardIterator first, ForwardIterator last);
378
379template <class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18380 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16381 is_sorted(ForwardIterator first, ForwardIterator last, Compare comp);
382
383template<class ForwardIterator>
Marshall Clow056f15e2018-01-15 19:40:34384 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16385 is_sorted_until(ForwardIterator first, ForwardIterator last);
386
387template <class ForwardIterator, class Compare>
Marshall Clow056f15e2018-01-15 19:40:34388 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16389 is_sorted_until(ForwardIterator first, ForwardIterator last, Compare comp);
390
391template <class RandomAccessIterator>
Arthur O'Dwyer493f1402020-12-20 20:21:42392 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16393 sort(RandomAccessIterator first, RandomAccessIterator last);
394
395template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer493f1402020-12-20 20:21:42396 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16397 sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
398
399template <class RandomAccessIterator>
400 void
401 stable_sort(RandomAccessIterator first, RandomAccessIterator last);
402
403template <class RandomAccessIterator, class Compare>
404 void
405 stable_sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
406
407template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18408 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16409 partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last);
410
411template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18412 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16413 partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last, Compare comp);
414
415template <class InputIterator, class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18416 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16417 partial_sort_copy(InputIterator first, InputIterator last,
418 RandomAccessIterator result_first, RandomAccessIterator result_last);
419
420template <class InputIterator, class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18421 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16422 partial_sort_copy(InputIterator first, InputIterator last,
423 RandomAccessIterator result_first, RandomAccessIterator result_last, Compare comp);
424
425template <class RandomAccessIterator>
Arthur O'Dwyer5d956562021-02-04 23:12:52426 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16427 nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last);
428
429template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5d956562021-02-04 23:12:52430 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16431 nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last, Compare comp);
432
433template <class ForwardIterator, class T>
Marshall Clowd57c03d2018-01-16 02:34:41434 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16435 lower_bound(ForwardIterator first, ForwardIterator last, const T& value);
436
437template <class ForwardIterator, class T, class Compare>
Marshall Clowd57c03d2018-01-16 02:34:41438 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16439 lower_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
440
441template <class ForwardIterator, class T>
Marshall Clowd57c03d2018-01-16 02:34:41442 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16443 upper_bound(ForwardIterator first, ForwardIterator last, const T& value);
444
445template <class ForwardIterator, class T, class Compare>
Marshall Clowd57c03d2018-01-16 02:34:41446 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16447 upper_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
448
449template <class ForwardIterator, class T>
Marshall Clowd57c03d2018-01-16 02:34:41450 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16451 equal_range(ForwardIterator first, ForwardIterator last, const T& value);
452
453template <class ForwardIterator, class T, class Compare>
Marshall Clowd57c03d2018-01-16 02:34:41454 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16455 equal_range(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
456
457template <class ForwardIterator, class T>
Marshall Clowd57c03d2018-01-16 02:34:41458 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16459 binary_search(ForwardIterator first, ForwardIterator last, const T& value);
460
461template <class ForwardIterator, class T, class Compare>
Marshall Clow8da1a482018-01-22 23:10:40462 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16463 binary_search(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
464
465template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer14098cf2020-12-04 18:47:12466 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16467 merge(InputIterator1 first1, InputIterator1 last1,
468 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
469
470template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer14098cf2020-12-04 18:47:12471 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16472 merge(InputIterator1 first1, InputIterator1 last1,
473 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
474
475template <class BidirectionalIterator>
476 void
477 inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last);
478
479template <class BidirectionalIterator, class Compare>
480 void
481 inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last, Compare comp);
482
483template <class InputIterator1, class InputIterator2>
Marshall Clow8da1a482018-01-22 23:10:40484 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16485 includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
486
487template <class InputIterator1, class InputIterator2, class Compare>
Marshall Clow8da1a482018-01-22 23:10:40488 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16489 includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, Compare comp);
490
491template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer14098cf2020-12-04 18:47:12492 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16493 set_union(InputIterator1 first1, InputIterator1 last1,
494 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
495
496template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer14098cf2020-12-04 18:47:12497 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16498 set_union(InputIterator1 first1, InputIterator1 last1,
499 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
500
501template <class InputIterator1, class InputIterator2, class OutputIterator>
Marshall Clow8da1a482018-01-22 23:10:40502 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16503 set_intersection(InputIterator1 first1, InputIterator1 last1,
504 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
505
506template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Marshall Clow8da1a482018-01-22 23:10:40507 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16508 set_intersection(InputIterator1 first1, InputIterator1 last1,
509 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
510
511template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer14098cf2020-12-04 18:47:12512 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16513 set_difference(InputIterator1 first1, InputIterator1 last1,
514 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
515
516template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer14098cf2020-12-04 18:47:12517 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16518 set_difference(InputIterator1 first1, InputIterator1 last1,
519 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
520
521template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer14098cf2020-12-04 18:47:12522 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16523 set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
524 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
525
526template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer14098cf2020-12-04 18:47:12527 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16528 set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
529 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
530
531template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18532 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16533 push_heap(RandomAccessIterator first, RandomAccessIterator last);
534
535template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18536 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16537 push_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
538
539template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18540 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16541 pop_heap(RandomAccessIterator first, RandomAccessIterator last);
542
543template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18544 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16545 pop_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
546
547template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18548 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16549 make_heap(RandomAccessIterator first, RandomAccessIterator last);
550
551template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18552 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16553 make_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
554
555template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18556 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16557 sort_heap(RandomAccessIterator first, RandomAccessIterator last);
558
559template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18560 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16561 sort_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
562
Howard Hinnantb3371f62010-08-22 00:02:43563template <class RandomAccessIterator>
Marshall Clow49c76432018-01-15 16:16:32564 constexpr bool // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43565 is_heap(RandomAccessIterator first, RandomAccessiterator last);
Howard Hinnant3e519522010-05-11 19:42:16566
Howard Hinnantb3371f62010-08-22 00:02:43567template <class RandomAccessIterator, class Compare>
Marshall Clow49c76432018-01-15 16:16:32568 constexpr bool // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43569 is_heap(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16570
Howard Hinnantb3371f62010-08-22 00:02:43571template <class RandomAccessIterator>
Marshall Clow49c76432018-01-15 16:16:32572 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43573 is_heap_until(RandomAccessIterator first, RandomAccessiterator last);
Howard Hinnant3e519522010-05-11 19:42:16574
Howard Hinnantb3371f62010-08-22 00:02:43575template <class RandomAccessIterator, class Compare>
Marshall Clow49c76432018-01-15 16:16:32576 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43577 is_heap_until(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16578
Howard Hinnant4eb27b72010-08-21 20:10:01579template <class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18580 constexpr ForwardIterator // constexpr in C++14
581 min_element(ForwardIterator first, ForwardIterator last);
Howard Hinnant4eb27b72010-08-21 20:10:01582
583template <class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18584 constexpr ForwardIterator // constexpr in C++14
585 min_element(ForwardIterator first, ForwardIterator last, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01586
Howard Hinnant3e519522010-05-11 19:42:16587template <class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18588 constexpr const T& // constexpr in C++14
589 min(const T& a, const T& b);
Howard Hinnant3e519522010-05-11 19:42:16590
591template <class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18592 constexpr const T& // constexpr in C++14
593 min(const T& a, const T& b, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16594
Howard Hinnant4eb27b72010-08-21 20:10:01595template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18596 constexpr T // constexpr in C++14
597 min(initializer_list<T> t);
Howard Hinnant4eb27b72010-08-21 20:10:01598
599template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18600 constexpr T // constexpr in C++14
601 min(initializer_list<T> t, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01602
Marshall Clow146c14a2016-03-07 22:43:49603template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18604 constexpr const T& clamp(const T& v, const T& lo, const T& hi); // C++17
Marshall Clow146c14a2016-03-07 22:43:49605
606template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18607 constexpr const T& clamp(const T& v, const T& lo, const T& hi, Compare comp); // C++17
Marshall Clow146c14a2016-03-07 22:43:49608
Howard Hinnant4eb27b72010-08-21 20:10:01609template <class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18610 constexpr ForwardIterator // constexpr in C++14
611 max_element(ForwardIterator first, ForwardIterator last);
Howard Hinnant4eb27b72010-08-21 20:10:01612
613template <class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18614 constexpr ForwardIterator // constexpr in C++14
615 max_element(ForwardIterator first, ForwardIterator last, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01616
Howard Hinnant3e519522010-05-11 19:42:16617template <class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18618 constexpr const T& // constexpr in C++14
619 max(const T& a, const T& b);
Howard Hinnant3e519522010-05-11 19:42:16620
621template <class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18622 constexpr const T& // constexpr in C++14
623 max(const T& a, const T& b, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16624
Howard Hinnant4eb27b72010-08-21 20:10:01625template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18626 constexpr T // constexpr in C++14
627 max(initializer_list<T> t);
Howard Hinnant3e519522010-05-11 19:42:16628
Howard Hinnant4eb27b72010-08-21 20:10:01629template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18630 constexpr T // constexpr in C++14
631 max(initializer_list<T> t, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16632
Howard Hinnant4eb27b72010-08-21 20:10:01633template<class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18634 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++14
635 minmax_element(ForwardIterator first, ForwardIterator last);
Howard Hinnant3e519522010-05-11 19:42:16636
Howard Hinnant4eb27b72010-08-21 20:10:01637template<class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18638 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++14
639 minmax_element(ForwardIterator first, ForwardIterator last, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01640
641template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18642 constexpr pair<const T&, const T&> // constexpr in C++14
643 minmax(const T& a, const T& b);
Howard Hinnant4eb27b72010-08-21 20:10:01644
645template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18646 constexpr pair<const T&, const T&> // constexpr in C++14
647 minmax(const T& a, const T& b, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01648
649template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18650 constexpr pair<T, T> // constexpr in C++14
651 minmax(initializer_list<T> t);
Howard Hinnant4eb27b72010-08-21 20:10:01652
653template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18654 constexpr pair<T, T> // constexpr in C++14
655 minmax(initializer_list<T> t, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16656
657template <class InputIterator1, class InputIterator2>
Marshall Clow1b9a4ff2018-01-22 20:44:33658 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16659 lexicographical_compare(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
660
661template <class InputIterator1, class InputIterator2, class Compare>
Marshall Clow1b9a4ff2018-01-22 20:44:33662 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16663 lexicographical_compare(InputIterator1 first1, InputIterator1 last1,
664 InputIterator2 first2, InputIterator2 last2, Compare comp);
665
666template <class BidirectionalIterator>
Arthur O'Dwyerf851db32020-12-17 05:01:08667 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16668 next_permutation(BidirectionalIterator first, BidirectionalIterator last);
669
670template <class BidirectionalIterator, class Compare>
Arthur O'Dwyerf851db32020-12-17 05:01:08671 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16672 next_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
673
674template <class BidirectionalIterator>
Arthur O'Dwyerf851db32020-12-17 05:01:08675 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16676 prev_permutation(BidirectionalIterator first, BidirectionalIterator last);
677
678template <class BidirectionalIterator, class Compare>
Arthur O'Dwyerf851db32020-12-17 05:01:08679 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16680 prev_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16681} // std
682
683*/
684
Arthur O'Dwyerea2206d2022-02-04 18:09:30685#include <__bits>
Howard Hinnant3e519522010-05-11 19:42:16686#include <__config>
Louis Dionne134723e2021-06-17 15:30:11687#include <__debug>
Howard Hinnanta1d07d52012-07-26 17:09:09688#include <cstddef>
Arthur O'Dwyerbfbd73f2021-05-19 15:57:04689#include <cstring>
690#include <functional>
691#include <initializer_list>
Arthur O'Dwyerbfbd73f2021-05-19 15:57:04692#include <iterator>
693#include <memory>
694#include <type_traits>
Marshall Clowf56972e2018-09-12 19:41:40695#include <version>
Howard Hinnant5d1a7012013-08-14 18:00:20696
Nikolas Klauser52915d72022-03-05 18:17:07697#include <utility> // TODO: Remove this
698
Louis Dionne134723e2021-06-17 15:30:11699#include <__algorithm/adjacent_find.h>
700#include <__algorithm/all_of.h>
701#include <__algorithm/any_of.h>
702#include <__algorithm/binary_search.h>
703#include <__algorithm/clamp.h>
704#include <__algorithm/comp.h>
705#include <__algorithm/comp_ref_type.h>
706#include <__algorithm/copy.h>
707#include <__algorithm/copy_backward.h>
708#include <__algorithm/copy_if.h>
709#include <__algorithm/copy_n.h>
710#include <__algorithm/count.h>
711#include <__algorithm/count_if.h>
712#include <__algorithm/equal.h>
713#include <__algorithm/equal_range.h>
Louis Dionne134723e2021-06-17 15:30:11714#include <__algorithm/fill.h>
Arthur O'Dwyer4d81a462022-01-07 14:45:05715#include <__algorithm/fill_n.h>
Louis Dionne134723e2021-06-17 15:30:11716#include <__algorithm/find.h>
717#include <__algorithm/find_end.h>
718#include <__algorithm/find_first_of.h>
719#include <__algorithm/find_if.h>
720#include <__algorithm/find_if_not.h>
721#include <__algorithm/for_each.h>
722#include <__algorithm/for_each_n.h>
Louis Dionne134723e2021-06-17 15:30:11723#include <__algorithm/generate.h>
Arthur O'Dwyer4d81a462022-01-07 14:45:05724#include <__algorithm/generate_n.h>
Louis Dionne134723e2021-06-17 15:30:11725#include <__algorithm/half_positive.h>
Nikolas Klauser68f41312022-02-21 22:07:02726#include <__algorithm/in_found_result.h>
Nikolas Klauser1e77b392022-02-11 16:01:58727#include <__algorithm/in_fun_result.h>
Nikolas Klauserf3514af2022-01-25 10:21:47728#include <__algorithm/in_in_out_result.h>
Nikolas Klauserd3729bb2022-01-14 01:55:51729#include <__algorithm/in_in_result.h>
Nikolas Klauser610979b2022-02-03 01:17:03730#include <__algorithm/in_out_out_result.h>
Konstantin Varlamov8d23b742022-01-11 06:49:37731#include <__algorithm/in_out_result.h>
Louis Dionne134723e2021-06-17 15:30:11732#include <__algorithm/includes.h>
733#include <__algorithm/inplace_merge.h>
734#include <__algorithm/is_heap.h>
735#include <__algorithm/is_heap_until.h>
736#include <__algorithm/is_partitioned.h>
737#include <__algorithm/is_permutation.h>
738#include <__algorithm/is_sorted.h>
739#include <__algorithm/is_sorted_until.h>
Christopher Di Bella6adbc832021-06-05 02:47:47740#include <__algorithm/iter_swap.h>
Louis Dionne134723e2021-06-17 15:30:11741#include <__algorithm/lexicographical_compare.h>
742#include <__algorithm/lower_bound.h>
743#include <__algorithm/make_heap.h>
744#include <__algorithm/max.h>
745#include <__algorithm/max_element.h>
746#include <__algorithm/merge.h>
747#include <__algorithm/min.h>
748#include <__algorithm/min_element.h>
Nikolas Klauser807766b2022-02-21 21:48:36749#include <__algorithm/min_max_result.h>
Louis Dionne134723e2021-06-17 15:30:11750#include <__algorithm/minmax.h>
751#include <__algorithm/minmax_element.h>
752#include <__algorithm/mismatch.h>
753#include <__algorithm/move.h>
754#include <__algorithm/move_backward.h>
755#include <__algorithm/next_permutation.h>
756#include <__algorithm/none_of.h>
757#include <__algorithm/nth_element.h>
758#include <__algorithm/partial_sort.h>
759#include <__algorithm/partial_sort_copy.h>
760#include <__algorithm/partition.h>
761#include <__algorithm/partition_copy.h>
762#include <__algorithm/partition_point.h>
763#include <__algorithm/pop_heap.h>
764#include <__algorithm/prev_permutation.h>
765#include <__algorithm/push_heap.h>
Nikolas Klauser205557c2022-03-07 16:01:52766#include <__algorithm/ranges_max_element.h>
Nikolas Klauser3b470d12022-02-11 12:11:57767#include <__algorithm/ranges_min_element.h>
Nikolas Klauser9d905312022-02-10 12:33:03768#include <__algorithm/ranges_swap_ranges.h>
Louis Dionne134723e2021-06-17 15:30:11769#include <__algorithm/remove.h>
770#include <__algorithm/remove_copy.h>
771#include <__algorithm/remove_copy_if.h>
772#include <__algorithm/remove_if.h>
773#include <__algorithm/replace.h>
774#include <__algorithm/replace_copy.h>
775#include <__algorithm/replace_copy_if.h>
776#include <__algorithm/replace_if.h>
777#include <__algorithm/reverse.h>
778#include <__algorithm/reverse_copy.h>
779#include <__algorithm/rotate.h>
780#include <__algorithm/rotate_copy.h>
781#include <__algorithm/sample.h>
782#include <__algorithm/search.h>
783#include <__algorithm/search_n.h>
784#include <__algorithm/set_difference.h>
785#include <__algorithm/set_intersection.h>
786#include <__algorithm/set_symmetric_difference.h>
787#include <__algorithm/set_union.h>
788#include <__algorithm/shift_left.h>
789#include <__algorithm/shift_right.h>
790#include <__algorithm/shuffle.h>
791#include <__algorithm/sift_down.h>
792#include <__algorithm/sort.h>
793#include <__algorithm/sort_heap.h>
794#include <__algorithm/stable_partition.h>
795#include <__algorithm/stable_sort.h>
Christopher Di Bella6adbc832021-06-05 02:47:47796#include <__algorithm/swap_ranges.h>
Louis Dionne134723e2021-06-17 15:30:11797#include <__algorithm/transform.h>
Louis Dionne134723e2021-06-17 15:30:11798#include <__algorithm/unique.h>
Arthur O'Dwyer4d81a462022-01-07 14:45:05799#include <__algorithm/unique_copy.h>
Louis Dionne134723e2021-06-17 15:30:11800#include <__algorithm/unwrap_iter.h>
801#include <__algorithm/upper_bound.h>
Eric Fiselierc1bd9192014-08-10 23:53:08802
Howard Hinnant073458b2011-10-17 20:05:10803#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Arthur O'Dwyerfa6b9e42022-02-02 01:16:40804# pragma GCC system_header
Howard Hinnant073458b2011-10-17 20:05:10805#endif
Howard Hinnant3e519522010-05-11 19:42:16806
Louis Dionne0a06eb92019-08-05 18:29:14807#if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17
Louis Dionne95689242019-08-06 21:11:24808# include <__pstl_algorithm>
Louis Dionne0a06eb92019-08-05 18:29:14809#endif
810
Louis Dionne4cd6ca12021-04-20 16:03:32811#endif // _LIBCPP_ALGORITHM