blob: 9149995caef7a0977469e7d8b14c88a1c31fd787 [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 Klauser3b470d12022-02-11 12:11:5737 template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
38 indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less> // since C++20
39 constexpr I min_element(I first, S last, Comp comp = {}, Proj proj = {});
40
41 template<forward_range R, class Proj = identity,
42 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less> // since C++20
43 constexpr borrowed_iterator_t<R> min_element(R&& r, Comp comp = {}, Proj proj = {});
Nikolas Klauserd3729bb2022-01-14 01:55:5144}
45
Howard Hinnant3e519522010-05-11 19:42:1646template <class InputIterator, class Predicate>
Marshall Clow706ffef2018-01-15 17:20:3647 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1648 all_of(InputIterator first, InputIterator last, Predicate pred);
49
50template <class InputIterator, class Predicate>
Marshall Clow706ffef2018-01-15 17:20:3651 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1652 any_of(InputIterator first, InputIterator last, Predicate pred);
53
54template <class InputIterator, class Predicate>
Marshall Clow706ffef2018-01-15 17:20:3655 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1656 none_of(InputIterator first, InputIterator last, Predicate pred);
57
58template <class InputIterator, class Function>
Marshall Clow1b9a4ff2018-01-22 20:44:3359 constexpr Function // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1660 for_each(InputIterator first, InputIterator last, Function f);
61
Marshall Clowd5c65ff2017-05-25 02:29:5462template<class InputIterator, class Size, class Function>
Marshall Clow1b9a4ff2018-01-22 20:44:3363 constexpr InputIterator // constexpr in C++20
64 for_each_n(InputIterator first, Size n, Function f); // C++17
Marshall Clowd5c65ff2017-05-25 02:29:5465
Howard Hinnant3e519522010-05-11 19:42:1666template <class InputIterator, class T>
Marshall Clow86944282018-01-15 19:26:0567 constexpr InputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1668 find(InputIterator first, InputIterator last, const T& value);
69
70template <class InputIterator, class Predicate>
Marshall Clow86944282018-01-15 19:26:0571 constexpr InputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1672 find_if(InputIterator first, InputIterator last, Predicate pred);
73
74template<class InputIterator, class Predicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:1875 constexpr InputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1676 find_if_not(InputIterator first, InputIterator last, Predicate pred);
77
78template <class ForwardIterator1, class ForwardIterator2>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:1879 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1680 find_end(ForwardIterator1 first1, ForwardIterator1 last1,
81 ForwardIterator2 first2, ForwardIterator2 last2);
82
83template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:1884 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1685 find_end(ForwardIterator1 first1, ForwardIterator1 last1,
86 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
87
88template <class ForwardIterator1, class ForwardIterator2>
Marshall Clow86944282018-01-15 19:26:0589 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1690 find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
91 ForwardIterator2 first2, ForwardIterator2 last2);
92
93template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow86944282018-01-15 19:26:0594 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1695 find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
96 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
97
98template <class ForwardIterator>
Marshall Clow86944282018-01-15 19:26:0599 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16100 adjacent_find(ForwardIterator first, ForwardIterator last);
101
102template <class ForwardIterator, class BinaryPredicate>
Marshall Clow86944282018-01-15 19:26:05103 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16104 adjacent_find(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
105
106template <class InputIterator, class T>
Marshall Clow056f15e2018-01-15 19:40:34107 constexpr typename iterator_traits<InputIterator>::difference_type // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16108 count(InputIterator first, InputIterator last, const T& value);
109
110template <class InputIterator, class Predicate>
Marshall Clow056f15e2018-01-15 19:40:34111 constexpr typename iterator_traits<InputIterator>::difference_type // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16112 count_if(InputIterator first, InputIterator last, Predicate pred);
113
114template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:10115 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16116 mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
117
Marshall Clow0b0bbd22013-05-09 21:14:23118template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:10119 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Aditya Kumar331fb802016-08-25 11:52:38120 mismatch(InputIterator1 first1, InputIterator1 last1,
Marshall Clow0b0bbd22013-05-09 21:14:23121 InputIterator2 first2, InputIterator2 last2); // **C++14**
122
Howard Hinnant3e519522010-05-11 19:42:16123template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:10124 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16125 mismatch(InputIterator1 first1, InputIterator1 last1,
126 InputIterator2 first2, BinaryPredicate pred);
127
Marshall Clow0b0bbd22013-05-09 21:14:23128template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:10129 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23130 mismatch(InputIterator1 first1, InputIterator1 last1,
131 InputIterator2 first2, InputIterator2 last2,
132 BinaryPredicate pred); // **C++14**
133
Howard Hinnant3e519522010-05-11 19:42:16134template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:10135 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16136 equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
137
Marshall Clow0b0bbd22013-05-09 21:14:23138template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:10139 constexpr bool // constexpr in C++20
Aditya Kumar331fb802016-08-25 11:52:38140 equal(InputIterator1 first1, InputIterator1 last1,
Marshall Clow0b0bbd22013-05-09 21:14:23141 InputIterator2 first2, InputIterator2 last2); // **C++14**
142
Howard Hinnant3e519522010-05-11 19:42:16143template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:10144 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16145 equal(InputIterator1 first1, InputIterator1 last1,
146 InputIterator2 first2, BinaryPredicate pred);
147
Marshall Clow0b0bbd22013-05-09 21:14:23148template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:10149 constexpr bool // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23150 equal(InputIterator1 first1, InputIterator1 last1,
151 InputIterator2 first2, InputIterator2 last2,
152 BinaryPredicate pred); // **C++14**
153
Howard Hinnant3e519522010-05-11 19:42:16154template<class ForwardIterator1, class ForwardIterator2>
Marshall Clow49c76432018-01-15 16:16:32155 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16156 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
157 ForwardIterator2 first2);
158
Marshall Clow0b0bbd22013-05-09 21:14:23159template<class ForwardIterator1, class ForwardIterator2>
Marshall Clow49c76432018-01-15 16:16:32160 constexpr bool // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23161 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
162 ForwardIterator2 first2, ForwardIterator2 last2); // **C++14**
163
Howard Hinnant3e519522010-05-11 19:42:16164template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow49c76432018-01-15 16:16:32165 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16166 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
167 ForwardIterator2 first2, BinaryPredicate pred);
168
Marshall Clow0b0bbd22013-05-09 21:14:23169template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow49c76432018-01-15 16:16:32170 constexpr bool // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23171 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
172 ForwardIterator2 first2, ForwardIterator2 last2,
173 BinaryPredicate pred); // **C++14**
174
Howard Hinnant3e519522010-05-11 19:42:16175template <class ForwardIterator1, class ForwardIterator2>
Marshall Clow12f0a772018-01-16 15:48:27176 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16177 search(ForwardIterator1 first1, ForwardIterator1 last1,
178 ForwardIterator2 first2, ForwardIterator2 last2);
179
180template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow12f0a772018-01-16 15:48:27181 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16182 search(ForwardIterator1 first1, ForwardIterator1 last1,
183 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
184
185template <class ForwardIterator, class Size, class T>
Marshall Clow12f0a772018-01-16 15:48:27186 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16187 search_n(ForwardIterator first, ForwardIterator last, Size count, const T& value);
188
189template <class ForwardIterator, class Size, class T, class BinaryPredicate>
Marshall Clow12f0a772018-01-16 15:48:27190 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16191 search_n(ForwardIterator first, ForwardIterator last,
192 Size count, const T& value, BinaryPredicate pred);
193
194template <class InputIterator, class OutputIterator>
Louis Dionne13c90a52019-11-06 12:02:41195 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16196 copy(InputIterator first, InputIterator last, OutputIterator result);
197
198template<class InputIterator, class OutputIterator, class Predicate>
Louis Dionne13c90a52019-11-06 12:02:41199 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16200 copy_if(InputIterator first, InputIterator last,
201 OutputIterator result, Predicate pred);
202
203template<class InputIterator, class Size, class OutputIterator>
Louis Dionne13c90a52019-11-06 12:02:41204 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16205 copy_n(InputIterator first, Size n, OutputIterator result);
206
207template <class BidirectionalIterator1, class BidirectionalIterator2>
Louis Dionne13c90a52019-11-06 12:02:41208 constexpr BidirectionalIterator2 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16209 copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last,
210 BidirectionalIterator2 result);
211
212template <class ForwardIterator1, class ForwardIterator2>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18213 constexpr ForwardIterator2 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16214 swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2);
215
Nikolas Klauser9d905312022-02-10 12:33:03216template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2>
217 requires indirectly_swappable<I1, I2>
218 constexpr ranges::swap_ranges_result<I1, I2>
219 ranges::swap_ranges(I1 first1, S1 last1, I2 first2, S2 last2);
220
221template<input_range R1, input_range R2>
222 requires indirectly_swappable<iterator_t<R1>, iterator_t<R2>>
223 constexpr ranges::swap_ranges_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>>
224 ranges::swap_ranges(R1&& r1, R2&& r2);
225
Howard Hinnant3e519522010-05-11 19:42:16226template <class ForwardIterator1, class ForwardIterator2>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18227 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16228 iter_swap(ForwardIterator1 a, ForwardIterator2 b);
229
230template <class InputIterator, class OutputIterator, class UnaryOperation>
Marshall Clow99894b62018-01-19 17:45:39231 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16232 transform(InputIterator first, InputIterator last, OutputIterator result, UnaryOperation op);
233
234template <class InputIterator1, class InputIterator2, class OutputIterator, class BinaryOperation>
Marshall Clow99894b62018-01-19 17:45:39235 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16236 transform(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2,
237 OutputIterator result, BinaryOperation binary_op);
238
239template <class ForwardIterator, class T>
Marshall Clow12c74232018-01-19 18:07:29240 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16241 replace(ForwardIterator first, ForwardIterator last, const T& old_value, const T& new_value);
242
243template <class ForwardIterator, class Predicate, class T>
Marshall Clow12c74232018-01-19 18:07:29244 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16245 replace_if(ForwardIterator first, ForwardIterator last, Predicate pred, const T& new_value);
246
247template <class InputIterator, class OutputIterator, class T>
Marshall Clow12c74232018-01-19 18:07:29248 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16249 replace_copy(InputIterator first, InputIterator last, OutputIterator result,
250 const T& old_value, const T& new_value);
251
252template <class InputIterator, class OutputIterator, class Predicate, class T>
Marshall Clow12c74232018-01-19 18:07:29253 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16254 replace_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred, const T& new_value);
255
256template <class ForwardIterator, class T>
Marshall Clow4bfb9312018-01-20 20:14:32257 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16258 fill(ForwardIterator first, ForwardIterator last, const T& value);
259
260template <class OutputIterator, class Size, class T>
Marshall Clow4bfb9312018-01-20 20:14:32261 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16262 fill_n(OutputIterator first, Size n, const T& value);
263
264template <class ForwardIterator, class Generator>
Marshall Clow4bfb9312018-01-20 20:14:32265 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16266 generate(ForwardIterator first, ForwardIterator last, Generator gen);
267
268template <class OutputIterator, class Size, class Generator>
Marshall Clow4bfb9312018-01-20 20:14:32269 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16270 generate_n(OutputIterator first, Size n, Generator gen);
271
272template <class ForwardIterator, class T>
Marshall Clowe8ea8292018-01-22 21:43:04273 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16274 remove(ForwardIterator first, ForwardIterator last, const T& value);
275
276template <class ForwardIterator, class Predicate>
Marshall Clowe8ea8292018-01-22 21:43:04277 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16278 remove_if(ForwardIterator first, ForwardIterator last, Predicate pred);
279
280template <class InputIterator, class OutputIterator, class T>
Marshall Clowe8ea8292018-01-22 21:43:04281 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16282 remove_copy(InputIterator first, InputIterator last, OutputIterator result, const T& value);
283
284template <class InputIterator, class OutputIterator, class Predicate>
Marshall Clowe8ea8292018-01-22 21:43:04285 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16286 remove_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred);
287
288template <class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18289 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16290 unique(ForwardIterator first, ForwardIterator last);
291
292template <class ForwardIterator, class BinaryPredicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18293 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16294 unique(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
295
296template <class InputIterator, class OutputIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18297 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16298 unique_copy(InputIterator first, InputIterator last, OutputIterator result);
299
300template <class InputIterator, class OutputIterator, class BinaryPredicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18301 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16302 unique_copy(InputIterator first, InputIterator last, OutputIterator result, BinaryPredicate pred);
303
304template <class BidirectionalIterator>
Arthur O'Dwyerf851db32020-12-17 05:01:08305 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16306 reverse(BidirectionalIterator first, BidirectionalIterator last);
307
308template <class BidirectionalIterator, class OutputIterator>
Marshall Clowe8ea8292018-01-22 21:43:04309 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16310 reverse_copy(BidirectionalIterator first, BidirectionalIterator last, OutputIterator result);
311
312template <class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18313 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16314 rotate(ForwardIterator first, ForwardIterator middle, ForwardIterator last);
315
316template <class ForwardIterator, class OutputIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18317 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16318 rotate_copy(ForwardIterator first, ForwardIterator middle, ForwardIterator last, OutputIterator result);
319
320template <class RandomAccessIterator>
321 void
Marshall Clow0f37a412017-03-23 13:43:37322 random_shuffle(RandomAccessIterator first, RandomAccessIterator last); // deprecated in C++14, removed in C++17
Howard Hinnant3e519522010-05-11 19:42:16323
324template <class RandomAccessIterator, class RandomNumberGenerator>
325 void
Marshall Clow06965c12014-03-03 06:14:19326 random_shuffle(RandomAccessIterator first, RandomAccessIterator last,
Marshall Clow0f37a412017-03-23 13:43:37327 RandomNumberGenerator& rand); // deprecated in C++14, removed in C++17
Howard Hinnant3e519522010-05-11 19:42:16328
Eric Fiseliere7154702016-08-28 22:14:37329template<class PopulationIterator, class SampleIterator,
330 class Distance, class UniformRandomBitGenerator>
331 SampleIterator sample(PopulationIterator first, PopulationIterator last,
332 SampleIterator out, Distance n,
333 UniformRandomBitGenerator&& g); // C++17
334
Howard Hinnantf9d540b2010-05-26 17:49:34335template<class RandomAccessIterator, class UniformRandomNumberGenerator>
336 void shuffle(RandomAccessIterator first, RandomAccessIterator last,
Howard Hinnantfb340102010-11-18 01:47:02337 UniformRandomNumberGenerator&& g);
Howard Hinnantf9d540b2010-05-26 17:49:34338
Arthur O'Dwyer3fbd3ea2020-12-26 06:39:03339template<class ForwardIterator>
340 constexpr ForwardIterator
341 shift_left(ForwardIterator first, ForwardIterator last,
342 typename iterator_traits<ForwardIterator>::difference_type n); // C++20
343
344template<class ForwardIterator>
345 constexpr ForwardIterator
346 shift_right(ForwardIterator first, ForwardIterator last,
347 typename iterator_traits<ForwardIterator>::difference_type n); // C++20
348
Howard Hinnant3e519522010-05-11 19:42:16349template <class InputIterator, class Predicate>
Marshall Clow49c76432018-01-15 16:16:32350 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16351 is_partitioned(InputIterator first, InputIterator last, Predicate pred);
352
353template <class ForwardIterator, class Predicate>
Arthur O'Dwyerf851db32020-12-17 05:01:08354 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16355 partition(ForwardIterator first, ForwardIterator last, Predicate pred);
356
357template <class InputIterator, class OutputIterator1,
358 class OutputIterator2, class Predicate>
Marshall Clow1b9a4ff2018-01-22 20:44:33359 constexpr pair<OutputIterator1, OutputIterator2> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16360 partition_copy(InputIterator first, InputIterator last,
361 OutputIterator1 out_true, OutputIterator2 out_false,
362 Predicate pred);
363
364template <class ForwardIterator, class Predicate>
365 ForwardIterator
366 stable_partition(ForwardIterator first, ForwardIterator last, Predicate pred);
367
368template<class ForwardIterator, class Predicate>
Marshall Clowd57c03d2018-01-16 02:34:41369 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16370 partition_point(ForwardIterator first, ForwardIterator last, Predicate pred);
371
372template <class ForwardIterator>
Marshall Clow49c76432018-01-15 16:16:32373 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16374 is_sorted(ForwardIterator first, ForwardIterator last);
375
376template <class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18377 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16378 is_sorted(ForwardIterator first, ForwardIterator last, Compare comp);
379
380template<class ForwardIterator>
Marshall Clow056f15e2018-01-15 19:40:34381 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16382 is_sorted_until(ForwardIterator first, ForwardIterator last);
383
384template <class ForwardIterator, class Compare>
Marshall Clow056f15e2018-01-15 19:40:34385 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16386 is_sorted_until(ForwardIterator first, ForwardIterator last, Compare comp);
387
388template <class RandomAccessIterator>
Arthur O'Dwyer493f1402020-12-20 20:21:42389 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16390 sort(RandomAccessIterator first, RandomAccessIterator last);
391
392template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer493f1402020-12-20 20:21:42393 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16394 sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
395
396template <class RandomAccessIterator>
397 void
398 stable_sort(RandomAccessIterator first, RandomAccessIterator last);
399
400template <class RandomAccessIterator, class Compare>
401 void
402 stable_sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
403
404template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18405 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16406 partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last);
407
408template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18409 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16410 partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last, Compare comp);
411
412template <class InputIterator, class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18413 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16414 partial_sort_copy(InputIterator first, InputIterator last,
415 RandomAccessIterator result_first, RandomAccessIterator result_last);
416
417template <class InputIterator, class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18418 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16419 partial_sort_copy(InputIterator first, InputIterator last,
420 RandomAccessIterator result_first, RandomAccessIterator result_last, Compare comp);
421
422template <class RandomAccessIterator>
Arthur O'Dwyer5d956562021-02-04 23:12:52423 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16424 nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last);
425
426template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5d956562021-02-04 23:12:52427 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16428 nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last, Compare comp);
429
430template <class ForwardIterator, class T>
Marshall Clowd57c03d2018-01-16 02:34:41431 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16432 lower_bound(ForwardIterator first, ForwardIterator last, const T& value);
433
434template <class ForwardIterator, class T, class Compare>
Marshall Clowd57c03d2018-01-16 02:34:41435 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16436 lower_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
437
438template <class ForwardIterator, class T>
Marshall Clowd57c03d2018-01-16 02:34:41439 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16440 upper_bound(ForwardIterator first, ForwardIterator last, const T& value);
441
442template <class ForwardIterator, class T, class Compare>
Marshall Clowd57c03d2018-01-16 02:34:41443 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16444 upper_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
445
446template <class ForwardIterator, class T>
Marshall Clowd57c03d2018-01-16 02:34:41447 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16448 equal_range(ForwardIterator first, ForwardIterator last, const T& value);
449
450template <class ForwardIterator, class T, class Compare>
Marshall Clowd57c03d2018-01-16 02:34:41451 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16452 equal_range(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
453
454template <class ForwardIterator, class T>
Marshall Clowd57c03d2018-01-16 02:34:41455 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16456 binary_search(ForwardIterator first, ForwardIterator last, const T& value);
457
458template <class ForwardIterator, class T, class Compare>
Marshall Clow8da1a482018-01-22 23:10:40459 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16460 binary_search(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
461
462template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer14098cf2020-12-04 18:47:12463 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16464 merge(InputIterator1 first1, InputIterator1 last1,
465 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
466
467template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer14098cf2020-12-04 18:47:12468 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16469 merge(InputIterator1 first1, InputIterator1 last1,
470 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
471
472template <class BidirectionalIterator>
473 void
474 inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last);
475
476template <class BidirectionalIterator, class Compare>
477 void
478 inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last, Compare comp);
479
480template <class InputIterator1, class InputIterator2>
Marshall Clow8da1a482018-01-22 23:10:40481 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16482 includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
483
484template <class InputIterator1, class InputIterator2, class Compare>
Marshall Clow8da1a482018-01-22 23:10:40485 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16486 includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, Compare comp);
487
488template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer14098cf2020-12-04 18:47:12489 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16490 set_union(InputIterator1 first1, InputIterator1 last1,
491 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
492
493template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer14098cf2020-12-04 18:47:12494 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16495 set_union(InputIterator1 first1, InputIterator1 last1,
496 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
497
498template <class InputIterator1, class InputIterator2, class OutputIterator>
Marshall Clow8da1a482018-01-22 23:10:40499 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16500 set_intersection(InputIterator1 first1, InputIterator1 last1,
501 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
502
503template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Marshall Clow8da1a482018-01-22 23:10:40504 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16505 set_intersection(InputIterator1 first1, InputIterator1 last1,
506 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
507
508template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer14098cf2020-12-04 18:47:12509 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16510 set_difference(InputIterator1 first1, InputIterator1 last1,
511 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
512
513template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer14098cf2020-12-04 18:47:12514 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16515 set_difference(InputIterator1 first1, InputIterator1 last1,
516 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
517
518template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer14098cf2020-12-04 18:47:12519 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16520 set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
521 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
522
523template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer14098cf2020-12-04 18:47:12524 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16525 set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
526 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
527
528template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18529 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16530 push_heap(RandomAccessIterator first, RandomAccessIterator last);
531
532template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18533 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16534 push_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
535
536template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18537 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16538 pop_heap(RandomAccessIterator first, RandomAccessIterator last);
539
540template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18541 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16542 pop_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
543
544template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18545 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16546 make_heap(RandomAccessIterator first, RandomAccessIterator last);
547
548template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18549 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16550 make_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
551
552template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18553 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16554 sort_heap(RandomAccessIterator first, RandomAccessIterator last);
555
556template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18557 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16558 sort_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
559
Howard Hinnantb3371f62010-08-22 00:02:43560template <class RandomAccessIterator>
Marshall Clow49c76432018-01-15 16:16:32561 constexpr bool // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43562 is_heap(RandomAccessIterator first, RandomAccessiterator last);
Howard Hinnant3e519522010-05-11 19:42:16563
Howard Hinnantb3371f62010-08-22 00:02:43564template <class RandomAccessIterator, class Compare>
Marshall Clow49c76432018-01-15 16:16:32565 constexpr bool // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43566 is_heap(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16567
Howard Hinnantb3371f62010-08-22 00:02:43568template <class RandomAccessIterator>
Marshall Clow49c76432018-01-15 16:16:32569 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43570 is_heap_until(RandomAccessIterator first, RandomAccessiterator last);
Howard Hinnant3e519522010-05-11 19:42:16571
Howard Hinnantb3371f62010-08-22 00:02:43572template <class RandomAccessIterator, class Compare>
Marshall Clow49c76432018-01-15 16:16:32573 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43574 is_heap_until(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16575
Howard Hinnant4eb27b72010-08-21 20:10:01576template <class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18577 constexpr ForwardIterator // constexpr in C++14
578 min_element(ForwardIterator first, ForwardIterator last);
Howard Hinnant4eb27b72010-08-21 20:10:01579
580template <class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18581 constexpr ForwardIterator // constexpr in C++14
582 min_element(ForwardIterator first, ForwardIterator last, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01583
Howard Hinnant3e519522010-05-11 19:42:16584template <class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18585 constexpr const T& // constexpr in C++14
586 min(const T& a, const T& b);
Howard Hinnant3e519522010-05-11 19:42:16587
588template <class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18589 constexpr const T& // constexpr in C++14
590 min(const T& a, const T& b, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16591
Howard Hinnant4eb27b72010-08-21 20:10:01592template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18593 constexpr T // constexpr in C++14
594 min(initializer_list<T> t);
Howard Hinnant4eb27b72010-08-21 20:10:01595
596template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18597 constexpr T // constexpr in C++14
598 min(initializer_list<T> t, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01599
Marshall Clow146c14a2016-03-07 22:43:49600template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18601 constexpr const T& clamp(const T& v, const T& lo, const T& hi); // C++17
Marshall Clow146c14a2016-03-07 22:43:49602
603template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18604 constexpr const T& clamp(const T& v, const T& lo, const T& hi, Compare comp); // C++17
Marshall Clow146c14a2016-03-07 22:43:49605
Howard Hinnant4eb27b72010-08-21 20:10:01606template <class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18607 constexpr ForwardIterator // constexpr in C++14
608 max_element(ForwardIterator first, ForwardIterator last);
Howard Hinnant4eb27b72010-08-21 20:10:01609
610template <class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18611 constexpr ForwardIterator // constexpr in C++14
612 max_element(ForwardIterator first, ForwardIterator last, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01613
Howard Hinnant3e519522010-05-11 19:42:16614template <class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18615 constexpr const T& // constexpr in C++14
616 max(const T& a, const T& b);
Howard Hinnant3e519522010-05-11 19:42:16617
618template <class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18619 constexpr const T& // constexpr in C++14
620 max(const T& a, const T& b, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16621
Howard Hinnant4eb27b72010-08-21 20:10:01622template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18623 constexpr T // constexpr in C++14
624 max(initializer_list<T> t);
Howard Hinnant3e519522010-05-11 19:42:16625
Howard Hinnant4eb27b72010-08-21 20:10:01626template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18627 constexpr T // constexpr in C++14
628 max(initializer_list<T> t, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16629
Howard Hinnant4eb27b72010-08-21 20:10:01630template<class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18631 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++14
632 minmax_element(ForwardIterator first, ForwardIterator last);
Howard Hinnant3e519522010-05-11 19:42:16633
Howard Hinnant4eb27b72010-08-21 20:10:01634template<class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18635 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++14
636 minmax_element(ForwardIterator first, ForwardIterator last, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01637
638template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18639 constexpr pair<const T&, const T&> // constexpr in C++14
640 minmax(const T& a, const T& b);
Howard Hinnant4eb27b72010-08-21 20:10:01641
642template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18643 constexpr pair<const T&, const T&> // constexpr in C++14
644 minmax(const T& a, const T& b, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01645
646template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18647 constexpr pair<T, T> // constexpr in C++14
648 minmax(initializer_list<T> t);
Howard Hinnant4eb27b72010-08-21 20:10:01649
650template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18651 constexpr pair<T, T> // constexpr in C++14
652 minmax(initializer_list<T> t, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16653
654template <class InputIterator1, class InputIterator2>
Marshall Clow1b9a4ff2018-01-22 20:44:33655 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16656 lexicographical_compare(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
657
658template <class InputIterator1, class InputIterator2, class Compare>
Marshall Clow1b9a4ff2018-01-22 20:44:33659 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16660 lexicographical_compare(InputIterator1 first1, InputIterator1 last1,
661 InputIterator2 first2, InputIterator2 last2, Compare comp);
662
663template <class BidirectionalIterator>
Arthur O'Dwyerf851db32020-12-17 05:01:08664 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16665 next_permutation(BidirectionalIterator first, BidirectionalIterator last);
666
667template <class BidirectionalIterator, class Compare>
Arthur O'Dwyerf851db32020-12-17 05:01:08668 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16669 next_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
670
671template <class BidirectionalIterator>
Arthur O'Dwyerf851db32020-12-17 05:01:08672 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16673 prev_permutation(BidirectionalIterator first, BidirectionalIterator last);
674
675template <class BidirectionalIterator, class Compare>
Arthur O'Dwyerf851db32020-12-17 05:01:08676 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16677 prev_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16678} // std
679
680*/
681
Arthur O'Dwyerea2206d2022-02-04 18:09:30682#include <__bits>
Howard Hinnant3e519522010-05-11 19:42:16683#include <__config>
Louis Dionne134723e2021-06-17 15:30:11684#include <__debug>
Howard Hinnanta1d07d52012-07-26 17:09:09685#include <cstddef>
Arthur O'Dwyerbfbd73f2021-05-19 15:57:04686#include <cstring>
687#include <functional>
688#include <initializer_list>
Arthur O'Dwyerbfbd73f2021-05-19 15:57:04689#include <iterator>
690#include <memory>
691#include <type_traits>
Arthur O'Dwyerea2206d2022-02-04 18:09:30692#include <utility>
Marshall Clowf56972e2018-09-12 19:41:40693#include <version>
Howard Hinnant5d1a7012013-08-14 18:00:20694
Louis Dionne134723e2021-06-17 15:30:11695#include <__algorithm/adjacent_find.h>
696#include <__algorithm/all_of.h>
697#include <__algorithm/any_of.h>
698#include <__algorithm/binary_search.h>
699#include <__algorithm/clamp.h>
700#include <__algorithm/comp.h>
701#include <__algorithm/comp_ref_type.h>
702#include <__algorithm/copy.h>
703#include <__algorithm/copy_backward.h>
704#include <__algorithm/copy_if.h>
705#include <__algorithm/copy_n.h>
706#include <__algorithm/count.h>
707#include <__algorithm/count_if.h>
708#include <__algorithm/equal.h>
709#include <__algorithm/equal_range.h>
Louis Dionne134723e2021-06-17 15:30:11710#include <__algorithm/fill.h>
Arthur O'Dwyer4d81a462022-01-07 14:45:05711#include <__algorithm/fill_n.h>
Louis Dionne134723e2021-06-17 15:30:11712#include <__algorithm/find.h>
713#include <__algorithm/find_end.h>
714#include <__algorithm/find_first_of.h>
715#include <__algorithm/find_if.h>
716#include <__algorithm/find_if_not.h>
717#include <__algorithm/for_each.h>
718#include <__algorithm/for_each_n.h>
Louis Dionne134723e2021-06-17 15:30:11719#include <__algorithm/generate.h>
Arthur O'Dwyer4d81a462022-01-07 14:45:05720#include <__algorithm/generate_n.h>
Louis Dionne134723e2021-06-17 15:30:11721#include <__algorithm/half_positive.h>
Nikolas Klauser1e77b392022-02-11 16:01:58722#include <__algorithm/in_fun_result.h>
Nikolas Klauserf3514af2022-01-25 10:21:47723#include <__algorithm/in_in_out_result.h>
Nikolas Klauserd3729bb2022-01-14 01:55:51724#include <__algorithm/in_in_result.h>
Nikolas Klauser610979b2022-02-03 01:17:03725#include <__algorithm/in_out_out_result.h>
Konstantin Varlamov8d23b742022-01-11 06:49:37726#include <__algorithm/in_out_result.h>
Louis Dionne134723e2021-06-17 15:30:11727#include <__algorithm/includes.h>
728#include <__algorithm/inplace_merge.h>
729#include <__algorithm/is_heap.h>
730#include <__algorithm/is_heap_until.h>
731#include <__algorithm/is_partitioned.h>
732#include <__algorithm/is_permutation.h>
733#include <__algorithm/is_sorted.h>
734#include <__algorithm/is_sorted_until.h>
Christopher Di Bella6adbc832021-06-05 02:47:47735#include <__algorithm/iter_swap.h>
Louis Dionne134723e2021-06-17 15:30:11736#include <__algorithm/lexicographical_compare.h>
737#include <__algorithm/lower_bound.h>
738#include <__algorithm/make_heap.h>
739#include <__algorithm/max.h>
740#include <__algorithm/max_element.h>
741#include <__algorithm/merge.h>
742#include <__algorithm/min.h>
743#include <__algorithm/min_element.h>
Nikolas Klauser807766b2022-02-21 21:48:36744#include <__algorithm/min_max_result.h>
Louis Dionne134723e2021-06-17 15:30:11745#include <__algorithm/minmax.h>
746#include <__algorithm/minmax_element.h>
747#include <__algorithm/mismatch.h>
748#include <__algorithm/move.h>
749#include <__algorithm/move_backward.h>
750#include <__algorithm/next_permutation.h>
751#include <__algorithm/none_of.h>
752#include <__algorithm/nth_element.h>
753#include <__algorithm/partial_sort.h>
754#include <__algorithm/partial_sort_copy.h>
755#include <__algorithm/partition.h>
756#include <__algorithm/partition_copy.h>
757#include <__algorithm/partition_point.h>
758#include <__algorithm/pop_heap.h>
759#include <__algorithm/prev_permutation.h>
760#include <__algorithm/push_heap.h>
Nikolas Klauser3b470d12022-02-11 12:11:57761#include <__algorithm/ranges_min_element.h>
Nikolas Klauser9d905312022-02-10 12:33:03762#include <__algorithm/ranges_swap_ranges.h>
Louis Dionne134723e2021-06-17 15:30:11763#include <__algorithm/remove.h>
764#include <__algorithm/remove_copy.h>
765#include <__algorithm/remove_copy_if.h>
766#include <__algorithm/remove_if.h>
767#include <__algorithm/replace.h>
768#include <__algorithm/replace_copy.h>
769#include <__algorithm/replace_copy_if.h>
770#include <__algorithm/replace_if.h>
771#include <__algorithm/reverse.h>
772#include <__algorithm/reverse_copy.h>
773#include <__algorithm/rotate.h>
774#include <__algorithm/rotate_copy.h>
775#include <__algorithm/sample.h>
776#include <__algorithm/search.h>
777#include <__algorithm/search_n.h>
778#include <__algorithm/set_difference.h>
779#include <__algorithm/set_intersection.h>
780#include <__algorithm/set_symmetric_difference.h>
781#include <__algorithm/set_union.h>
782#include <__algorithm/shift_left.h>
783#include <__algorithm/shift_right.h>
784#include <__algorithm/shuffle.h>
785#include <__algorithm/sift_down.h>
786#include <__algorithm/sort.h>
787#include <__algorithm/sort_heap.h>
788#include <__algorithm/stable_partition.h>
789#include <__algorithm/stable_sort.h>
Christopher Di Bella6adbc832021-06-05 02:47:47790#include <__algorithm/swap_ranges.h>
Louis Dionne134723e2021-06-17 15:30:11791#include <__algorithm/transform.h>
Louis Dionne134723e2021-06-17 15:30:11792#include <__algorithm/unique.h>
Arthur O'Dwyer4d81a462022-01-07 14:45:05793#include <__algorithm/unique_copy.h>
Louis Dionne134723e2021-06-17 15:30:11794#include <__algorithm/unwrap_iter.h>
795#include <__algorithm/upper_bound.h>
Eric Fiselierc1bd9192014-08-10 23:53:08796
Howard Hinnant073458b2011-10-17 20:05:10797#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Arthur O'Dwyerfa6b9e42022-02-02 01:16:40798# pragma GCC system_header
Howard Hinnant073458b2011-10-17 20:05:10799#endif
Howard Hinnant3e519522010-05-11 19:42:16800
Louis Dionne0a06eb92019-08-05 18:29:14801#if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17
Louis Dionne95689242019-08-06 21:11:24802# include <__pstl_algorithm>
Louis Dionne0a06eb92019-08-05 18:29:14803#endif
804
Louis Dionne4cd6ca12021-04-20 16:03:32805#endif // _LIBCPP_ALGORITHM