blob: 72fdb29e50d64c6e1c70484b8e448ae681f3702d [file] [log] [blame]
Howard Hinnant3e519522010-05-11 19:42:161// -*- C++ -*-
Louis Dionneeb8650a2021-11-17 21:25:012//===----------------------------------------------------------------------===//
Howard Hinnant3e519522010-05-11 19:42:163//
Chandler Carruth57b08b02019-01-19 10:56:404// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Howard Hinnant3e519522010-05-11 19:42:167//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP_ALGORITHM
11#define _LIBCPP_ALGORITHM
12
13/*
14 algorithm synopsis
15
16#include <initializer_list>
17
18namespace std
19{
20
Nikolas Klauserd3729bb2022-01-14 01:55:5121namespace ranges {
Nikolas Klauser1e77b392022-02-11 16:01:5822 template <class I, class F>
Nikolas Klauser807766b2022-02-21 21:48:3623 struct in_fun_result; // since C++20
Nikolas Klauser1e77b392022-02-11 16:01:5824
Nikolas Klauserd3729bb2022-01-14 01:55:5125 template <class I1, class I2>
Nikolas Klauser807766b2022-02-21 21:48:3626 struct in_in_result; // since C++20
Nikolas Klauserf3514af2022-01-25 10:21:4727
28 template <class I1, class I2, class O>
Nikolas Klauser807766b2022-02-21 21:48:3629 struct in_in_out_result; // since C++20
Nikolas Klauser610979b2022-02-03 01:17:0330
31 template <class I, class O1, class O2>
32 struct in_out_out_result; // since C++20
Nikolas Klauser1e77b392022-02-11 16:01:5833
Nikolas Klauser807766b2022-02-21 21:48:3634 template <class I1, class I2>
35 struct min_max_result; // since C++20
36
Nikolas Klauser68f41312022-02-21 22:07:0237 template <class I>
38 struct in_found_result; // since C++20
39
Nikolas Klauser3b470d12022-02-11 12:11:5740 template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
41 indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less> // since C++20
42 constexpr I min_element(I first, S last, Comp comp = {}, Proj proj = {});
43
44 template<forward_range R, class Proj = identity,
45 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less> // since C++20
46 constexpr borrowed_iterator_t<R> min_element(R&& r, Comp comp = {}, Proj proj = {});
Nikolas Klauserc2cd15a2022-03-08 22:12:3547
48 template <input_iterator I1, sentinel_for<_I1> S1, input_iterator I2, sentinel_for<_I2> S2,
49 class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
50 requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
51 constexpr mismatch_result<_I1, _I2>
52 mismatch()(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}) // since C++20
53
54 template <input_range R1, input_range R2,
55 class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
56 requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
57 constexpr mismatch_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>>
58 mismatch(R1&& r1, R2&& r2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}) // since C++20
Nikolas Klauserd3729bb2022-01-14 01:55:5159}
60
Howard Hinnant3e519522010-05-11 19:42:1661template <class InputIterator, class Predicate>
Marshall Clow706ffef2018-01-15 17:20:3662 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1663 all_of(InputIterator first, InputIterator last, Predicate pred);
64
65template <class InputIterator, class Predicate>
Marshall Clow706ffef2018-01-15 17:20:3666 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1667 any_of(InputIterator first, InputIterator last, Predicate pred);
68
69template <class InputIterator, class Predicate>
Marshall Clow706ffef2018-01-15 17:20:3670 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1671 none_of(InputIterator first, InputIterator last, Predicate pred);
72
73template <class InputIterator, class Function>
Marshall Clow1b9a4ff2018-01-22 20:44:3374 constexpr Function // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1675 for_each(InputIterator first, InputIterator last, Function f);
76
Marshall Clowd5c65ff2017-05-25 02:29:5477template<class InputIterator, class Size, class Function>
Marshall Clow1b9a4ff2018-01-22 20:44:3378 constexpr InputIterator // constexpr in C++20
79 for_each_n(InputIterator first, Size n, Function f); // C++17
Marshall Clowd5c65ff2017-05-25 02:29:5480
Howard Hinnant3e519522010-05-11 19:42:1681template <class InputIterator, class T>
Marshall Clow86944282018-01-15 19:26:0582 constexpr InputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1683 find(InputIterator first, InputIterator last, const T& value);
84
85template <class InputIterator, class Predicate>
Marshall Clow86944282018-01-15 19:26:0586 constexpr InputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1687 find_if(InputIterator first, InputIterator last, Predicate pred);
88
89template<class InputIterator, class Predicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:1890 constexpr InputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1691 find_if_not(InputIterator first, InputIterator last, Predicate pred);
92
93template <class ForwardIterator1, class ForwardIterator2>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:1894 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1695 find_end(ForwardIterator1 first1, ForwardIterator1 last1,
96 ForwardIterator2 first2, ForwardIterator2 last2);
97
98template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:1899 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16100 find_end(ForwardIterator1 first1, ForwardIterator1 last1,
101 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
102
103template <class ForwardIterator1, class ForwardIterator2>
Marshall Clow86944282018-01-15 19:26:05104 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16105 find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
106 ForwardIterator2 first2, ForwardIterator2 last2);
107
108template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow86944282018-01-15 19:26:05109 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16110 find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
111 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
112
113template <class ForwardIterator>
Marshall Clow86944282018-01-15 19:26:05114 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16115 adjacent_find(ForwardIterator first, ForwardIterator last);
116
117template <class ForwardIterator, class BinaryPredicate>
Marshall Clow86944282018-01-15 19:26:05118 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16119 adjacent_find(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
120
121template <class InputIterator, class T>
Marshall Clow056f15e2018-01-15 19:40:34122 constexpr typename iterator_traits<InputIterator>::difference_type // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16123 count(InputIterator first, InputIterator last, const T& value);
124
125template <class InputIterator, class Predicate>
Marshall Clow056f15e2018-01-15 19:40:34126 constexpr typename iterator_traits<InputIterator>::difference_type // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16127 count_if(InputIterator first, InputIterator last, Predicate pred);
128
129template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:10130 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16131 mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
132
Marshall Clow0b0bbd22013-05-09 21:14:23133template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:10134 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Aditya Kumar331fb802016-08-25 11:52:38135 mismatch(InputIterator1 first1, InputIterator1 last1,
Marshall Clow0b0bbd22013-05-09 21:14:23136 InputIterator2 first2, InputIterator2 last2); // **C++14**
137
Howard Hinnant3e519522010-05-11 19:42:16138template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:10139 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16140 mismatch(InputIterator1 first1, InputIterator1 last1,
141 InputIterator2 first2, BinaryPredicate pred);
142
Marshall Clow0b0bbd22013-05-09 21:14:23143template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:10144 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23145 mismatch(InputIterator1 first1, InputIterator1 last1,
146 InputIterator2 first2, InputIterator2 last2,
147 BinaryPredicate pred); // **C++14**
148
Howard Hinnant3e519522010-05-11 19:42:16149template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:10150 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16151 equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
152
Marshall Clow0b0bbd22013-05-09 21:14:23153template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:10154 constexpr bool // constexpr in C++20
Aditya Kumar331fb802016-08-25 11:52:38155 equal(InputIterator1 first1, InputIterator1 last1,
Marshall Clow0b0bbd22013-05-09 21:14:23156 InputIterator2 first2, InputIterator2 last2); // **C++14**
157
Howard Hinnant3e519522010-05-11 19:42:16158template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:10159 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16160 equal(InputIterator1 first1, InputIterator1 last1,
161 InputIterator2 first2, BinaryPredicate pred);
162
Marshall Clow0b0bbd22013-05-09 21:14:23163template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:10164 constexpr bool // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23165 equal(InputIterator1 first1, InputIterator1 last1,
166 InputIterator2 first2, InputIterator2 last2,
167 BinaryPredicate pred); // **C++14**
168
Howard Hinnant3e519522010-05-11 19:42:16169template<class ForwardIterator1, class ForwardIterator2>
Marshall Clow49c76432018-01-15 16:16:32170 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16171 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
172 ForwardIterator2 first2);
173
Marshall Clow0b0bbd22013-05-09 21:14:23174template<class ForwardIterator1, class ForwardIterator2>
Marshall Clow49c76432018-01-15 16:16:32175 constexpr bool // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23176 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
177 ForwardIterator2 first2, ForwardIterator2 last2); // **C++14**
178
Howard Hinnant3e519522010-05-11 19:42:16179template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow49c76432018-01-15 16:16:32180 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16181 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
182 ForwardIterator2 first2, BinaryPredicate pred);
183
Marshall Clow0b0bbd22013-05-09 21:14:23184template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow49c76432018-01-15 16:16:32185 constexpr bool // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23186 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
187 ForwardIterator2 first2, ForwardIterator2 last2,
188 BinaryPredicate pred); // **C++14**
189
Howard Hinnant3e519522010-05-11 19:42:16190template <class ForwardIterator1, class ForwardIterator2>
Marshall Clow12f0a772018-01-16 15:48:27191 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16192 search(ForwardIterator1 first1, ForwardIterator1 last1,
193 ForwardIterator2 first2, ForwardIterator2 last2);
194
195template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow12f0a772018-01-16 15:48:27196 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16197 search(ForwardIterator1 first1, ForwardIterator1 last1,
198 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
199
200template <class ForwardIterator, class Size, class T>
Marshall Clow12f0a772018-01-16 15:48:27201 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16202 search_n(ForwardIterator first, ForwardIterator last, Size count, const T& value);
203
204template <class ForwardIterator, class Size, class T, class BinaryPredicate>
Marshall Clow12f0a772018-01-16 15:48:27205 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16206 search_n(ForwardIterator first, ForwardIterator last,
207 Size count, const T& value, BinaryPredicate pred);
208
209template <class InputIterator, class OutputIterator>
Louis Dionne13c90a52019-11-06 12:02:41210 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16211 copy(InputIterator first, InputIterator last, OutputIterator result);
212
213template<class InputIterator, class OutputIterator, class Predicate>
Louis Dionne13c90a52019-11-06 12:02:41214 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16215 copy_if(InputIterator first, InputIterator last,
216 OutputIterator result, Predicate pred);
217
218template<class InputIterator, class Size, class OutputIterator>
Louis Dionne13c90a52019-11-06 12:02:41219 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16220 copy_n(InputIterator first, Size n, OutputIterator result);
221
222template <class BidirectionalIterator1, class BidirectionalIterator2>
Louis Dionne13c90a52019-11-06 12:02:41223 constexpr BidirectionalIterator2 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16224 copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last,
225 BidirectionalIterator2 result);
226
227template <class ForwardIterator1, class ForwardIterator2>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18228 constexpr ForwardIterator2 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16229 swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2);
230
Nikolas Klauser9d905312022-02-10 12:33:03231template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2>
232 requires indirectly_swappable<I1, I2>
233 constexpr ranges::swap_ranges_result<I1, I2>
234 ranges::swap_ranges(I1 first1, S1 last1, I2 first2, S2 last2);
235
236template<input_range R1, input_range R2>
237 requires indirectly_swappable<iterator_t<R1>, iterator_t<R2>>
238 constexpr ranges::swap_ranges_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>>
239 ranges::swap_ranges(R1&& r1, R2&& r2);
240
Howard Hinnant3e519522010-05-11 19:42:16241template <class ForwardIterator1, class ForwardIterator2>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18242 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16243 iter_swap(ForwardIterator1 a, ForwardIterator2 b);
244
245template <class InputIterator, class OutputIterator, class UnaryOperation>
Marshall Clow99894b62018-01-19 17:45:39246 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16247 transform(InputIterator first, InputIterator last, OutputIterator result, UnaryOperation op);
248
249template <class InputIterator1, class InputIterator2, class OutputIterator, class BinaryOperation>
Marshall Clow99894b62018-01-19 17:45:39250 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16251 transform(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2,
252 OutputIterator result, BinaryOperation binary_op);
253
254template <class ForwardIterator, class T>
Marshall Clow12c74232018-01-19 18:07:29255 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16256 replace(ForwardIterator first, ForwardIterator last, const T& old_value, const T& new_value);
257
258template <class ForwardIterator, class Predicate, class T>
Marshall Clow12c74232018-01-19 18:07:29259 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16260 replace_if(ForwardIterator first, ForwardIterator last, Predicate pred, const T& new_value);
261
262template <class InputIterator, class OutputIterator, class T>
Marshall Clow12c74232018-01-19 18:07:29263 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16264 replace_copy(InputIterator first, InputIterator last, OutputIterator result,
265 const T& old_value, const T& new_value);
266
267template <class InputIterator, class OutputIterator, class Predicate, class T>
Marshall Clow12c74232018-01-19 18:07:29268 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16269 replace_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred, const T& new_value);
270
271template <class ForwardIterator, class T>
Marshall Clow4bfb9312018-01-20 20:14:32272 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16273 fill(ForwardIterator first, ForwardIterator last, const T& value);
274
275template <class OutputIterator, class Size, class T>
Marshall Clow4bfb9312018-01-20 20:14:32276 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16277 fill_n(OutputIterator first, Size n, const T& value);
278
279template <class ForwardIterator, class Generator>
Marshall Clow4bfb9312018-01-20 20:14:32280 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16281 generate(ForwardIterator first, ForwardIterator last, Generator gen);
282
283template <class OutputIterator, class Size, class Generator>
Marshall Clow4bfb9312018-01-20 20:14:32284 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16285 generate_n(OutputIterator first, Size n, Generator gen);
286
287template <class ForwardIterator, class T>
Marshall Clowe8ea8292018-01-22 21:43:04288 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16289 remove(ForwardIterator first, ForwardIterator last, const T& value);
290
291template <class ForwardIterator, class Predicate>
Marshall Clowe8ea8292018-01-22 21:43:04292 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16293 remove_if(ForwardIterator first, ForwardIterator last, Predicate pred);
294
295template <class InputIterator, class OutputIterator, class T>
Marshall Clowe8ea8292018-01-22 21:43:04296 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16297 remove_copy(InputIterator first, InputIterator last, OutputIterator result, const T& value);
298
299template <class InputIterator, class OutputIterator, class Predicate>
Marshall Clowe8ea8292018-01-22 21:43:04300 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16301 remove_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred);
302
303template <class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18304 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16305 unique(ForwardIterator first, ForwardIterator last);
306
307template <class ForwardIterator, class BinaryPredicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18308 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16309 unique(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
310
311template <class InputIterator, class OutputIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18312 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16313 unique_copy(InputIterator first, InputIterator last, OutputIterator result);
314
315template <class InputIterator, class OutputIterator, class BinaryPredicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18316 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16317 unique_copy(InputIterator first, InputIterator last, OutputIterator result, BinaryPredicate pred);
318
319template <class BidirectionalIterator>
Arthur O'Dwyerf851db32020-12-17 05:01:08320 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16321 reverse(BidirectionalIterator first, BidirectionalIterator last);
322
323template <class BidirectionalIterator, class OutputIterator>
Marshall Clowe8ea8292018-01-22 21:43:04324 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16325 reverse_copy(BidirectionalIterator first, BidirectionalIterator last, OutputIterator result);
326
327template <class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18328 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16329 rotate(ForwardIterator first, ForwardIterator middle, ForwardIterator last);
330
331template <class ForwardIterator, class OutputIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18332 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16333 rotate_copy(ForwardIterator first, ForwardIterator middle, ForwardIterator last, OutputIterator result);
334
335template <class RandomAccessIterator>
336 void
Marshall Clow0f37a412017-03-23 13:43:37337 random_shuffle(RandomAccessIterator first, RandomAccessIterator last); // deprecated in C++14, removed in C++17
Howard Hinnant3e519522010-05-11 19:42:16338
339template <class RandomAccessIterator, class RandomNumberGenerator>
340 void
Marshall Clow06965c12014-03-03 06:14:19341 random_shuffle(RandomAccessIterator first, RandomAccessIterator last,
Marshall Clow0f37a412017-03-23 13:43:37342 RandomNumberGenerator& rand); // deprecated in C++14, removed in C++17
Howard Hinnant3e519522010-05-11 19:42:16343
Eric Fiseliere7154702016-08-28 22:14:37344template<class PopulationIterator, class SampleIterator,
345 class Distance, class UniformRandomBitGenerator>
346 SampleIterator sample(PopulationIterator first, PopulationIterator last,
347 SampleIterator out, Distance n,
348 UniformRandomBitGenerator&& g); // C++17
349
Howard Hinnantf9d540b2010-05-26 17:49:34350template<class RandomAccessIterator, class UniformRandomNumberGenerator>
351 void shuffle(RandomAccessIterator first, RandomAccessIterator last,
Howard Hinnantfb340102010-11-18 01:47:02352 UniformRandomNumberGenerator&& g);
Howard Hinnantf9d540b2010-05-26 17:49:34353
Arthur O'Dwyer3fbd3ea2020-12-26 06:39:03354template<class ForwardIterator>
355 constexpr ForwardIterator
356 shift_left(ForwardIterator first, ForwardIterator last,
357 typename iterator_traits<ForwardIterator>::difference_type n); // C++20
358
359template<class ForwardIterator>
360 constexpr ForwardIterator
361 shift_right(ForwardIterator first, ForwardIterator last,
362 typename iterator_traits<ForwardIterator>::difference_type n); // C++20
363
Howard Hinnant3e519522010-05-11 19:42:16364template <class InputIterator, class Predicate>
Marshall Clow49c76432018-01-15 16:16:32365 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16366 is_partitioned(InputIterator first, InputIterator last, Predicate pred);
367
368template <class ForwardIterator, class Predicate>
Arthur O'Dwyerf851db32020-12-17 05:01:08369 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16370 partition(ForwardIterator first, ForwardIterator last, Predicate pred);
371
372template <class InputIterator, class OutputIterator1,
373 class OutputIterator2, class Predicate>
Marshall Clow1b9a4ff2018-01-22 20:44:33374 constexpr pair<OutputIterator1, OutputIterator2> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16375 partition_copy(InputIterator first, InputIterator last,
376 OutputIterator1 out_true, OutputIterator2 out_false,
377 Predicate pred);
378
379template <class ForwardIterator, class Predicate>
380 ForwardIterator
381 stable_partition(ForwardIterator first, ForwardIterator last, Predicate pred);
382
383template<class ForwardIterator, class Predicate>
Marshall Clowd57c03d2018-01-16 02:34:41384 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16385 partition_point(ForwardIterator first, ForwardIterator last, Predicate pred);
386
387template <class ForwardIterator>
Marshall Clow49c76432018-01-15 16:16:32388 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16389 is_sorted(ForwardIterator first, ForwardIterator last);
390
391template <class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18392 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16393 is_sorted(ForwardIterator first, ForwardIterator last, Compare comp);
394
395template<class ForwardIterator>
Marshall Clow056f15e2018-01-15 19:40:34396 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16397 is_sorted_until(ForwardIterator first, ForwardIterator last);
398
399template <class ForwardIterator, class Compare>
Marshall Clow056f15e2018-01-15 19:40:34400 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16401 is_sorted_until(ForwardIterator first, ForwardIterator last, Compare comp);
402
403template <class RandomAccessIterator>
Arthur O'Dwyer493f1402020-12-20 20:21:42404 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16405 sort(RandomAccessIterator first, RandomAccessIterator last);
406
407template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer493f1402020-12-20 20:21:42408 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16409 sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
410
411template <class RandomAccessIterator>
412 void
413 stable_sort(RandomAccessIterator first, RandomAccessIterator last);
414
415template <class RandomAccessIterator, class Compare>
416 void
417 stable_sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
418
419template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18420 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16421 partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last);
422
423template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18424 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16425 partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last, Compare comp);
426
427template <class InputIterator, class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18428 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16429 partial_sort_copy(InputIterator first, InputIterator last,
430 RandomAccessIterator result_first, RandomAccessIterator result_last);
431
432template <class InputIterator, class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18433 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16434 partial_sort_copy(InputIterator first, InputIterator last,
435 RandomAccessIterator result_first, RandomAccessIterator result_last, Compare comp);
436
437template <class RandomAccessIterator>
Arthur O'Dwyer5d956562021-02-04 23:12:52438 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16439 nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last);
440
441template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5d956562021-02-04 23:12:52442 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16443 nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last, Compare comp);
444
445template <class ForwardIterator, class T>
Marshall Clowd57c03d2018-01-16 02:34:41446 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16447 lower_bound(ForwardIterator first, ForwardIterator last, const T& value);
448
449template <class ForwardIterator, class T, class Compare>
Marshall Clowd57c03d2018-01-16 02:34:41450 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16451 lower_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
452
453template <class ForwardIterator, class T>
Marshall Clowd57c03d2018-01-16 02:34:41454 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16455 upper_bound(ForwardIterator first, ForwardIterator last, const T& value);
456
457template <class ForwardIterator, class T, class Compare>
Marshall Clowd57c03d2018-01-16 02:34:41458 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16459 upper_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
460
461template <class ForwardIterator, class T>
Marshall Clowd57c03d2018-01-16 02:34:41462 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16463 equal_range(ForwardIterator first, ForwardIterator last, const T& value);
464
465template <class ForwardIterator, class T, class Compare>
Marshall Clowd57c03d2018-01-16 02:34:41466 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16467 equal_range(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
468
469template <class ForwardIterator, class T>
Marshall Clowd57c03d2018-01-16 02:34:41470 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16471 binary_search(ForwardIterator first, ForwardIterator last, const T& value);
472
473template <class ForwardIterator, class T, class Compare>
Marshall Clow8da1a482018-01-22 23:10:40474 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16475 binary_search(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
476
477template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer14098cf2020-12-04 18:47:12478 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16479 merge(InputIterator1 first1, InputIterator1 last1,
480 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
481
482template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer14098cf2020-12-04 18:47:12483 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16484 merge(InputIterator1 first1, InputIterator1 last1,
485 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
486
487template <class BidirectionalIterator>
488 void
489 inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last);
490
491template <class BidirectionalIterator, class Compare>
492 void
493 inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last, Compare comp);
494
495template <class InputIterator1, class InputIterator2>
Marshall Clow8da1a482018-01-22 23:10:40496 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16497 includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
498
499template <class InputIterator1, class InputIterator2, class Compare>
Marshall Clow8da1a482018-01-22 23:10:40500 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16501 includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, Compare comp);
502
503template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer14098cf2020-12-04 18:47:12504 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16505 set_union(InputIterator1 first1, InputIterator1 last1,
506 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
507
508template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer14098cf2020-12-04 18:47:12509 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16510 set_union(InputIterator1 first1, InputIterator1 last1,
511 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
512
513template <class InputIterator1, class InputIterator2, class OutputIterator>
Marshall Clow8da1a482018-01-22 23:10:40514 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16515 set_intersection(InputIterator1 first1, InputIterator1 last1,
516 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
517
518template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Marshall Clow8da1a482018-01-22 23:10:40519 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16520 set_intersection(InputIterator1 first1, InputIterator1 last1,
521 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
522
523template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer14098cf2020-12-04 18:47:12524 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16525 set_difference(InputIterator1 first1, InputIterator1 last1,
526 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
527
528template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer14098cf2020-12-04 18:47:12529 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16530 set_difference(InputIterator1 first1, InputIterator1 last1,
531 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
532
533template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer14098cf2020-12-04 18:47:12534 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16535 set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
536 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
537
538template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer14098cf2020-12-04 18:47:12539 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16540 set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
541 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
542
543template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18544 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16545 push_heap(RandomAccessIterator first, RandomAccessIterator last);
546
547template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18548 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16549 push_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
550
551template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18552 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16553 pop_heap(RandomAccessIterator first, RandomAccessIterator last);
554
555template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18556 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16557 pop_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
558
559template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18560 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16561 make_heap(RandomAccessIterator first, RandomAccessIterator last);
562
563template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18564 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16565 make_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
566
567template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18568 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16569 sort_heap(RandomAccessIterator first, RandomAccessIterator last);
570
571template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18572 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16573 sort_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
574
Howard Hinnantb3371f62010-08-22 00:02:43575template <class RandomAccessIterator>
Marshall Clow49c76432018-01-15 16:16:32576 constexpr bool // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43577 is_heap(RandomAccessIterator first, RandomAccessiterator last);
Howard Hinnant3e519522010-05-11 19:42:16578
Howard Hinnantb3371f62010-08-22 00:02:43579template <class RandomAccessIterator, class Compare>
Marshall Clow49c76432018-01-15 16:16:32580 constexpr bool // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43581 is_heap(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16582
Howard Hinnantb3371f62010-08-22 00:02:43583template <class RandomAccessIterator>
Marshall Clow49c76432018-01-15 16:16:32584 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43585 is_heap_until(RandomAccessIterator first, RandomAccessiterator last);
Howard Hinnant3e519522010-05-11 19:42:16586
Howard Hinnantb3371f62010-08-22 00:02:43587template <class RandomAccessIterator, class Compare>
Marshall Clow49c76432018-01-15 16:16:32588 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43589 is_heap_until(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16590
Howard Hinnant4eb27b72010-08-21 20:10:01591template <class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18592 constexpr ForwardIterator // constexpr in C++14
593 min_element(ForwardIterator first, ForwardIterator last);
Howard Hinnant4eb27b72010-08-21 20:10:01594
595template <class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18596 constexpr ForwardIterator // constexpr in C++14
597 min_element(ForwardIterator first, ForwardIterator last, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01598
Howard Hinnant3e519522010-05-11 19:42:16599template <class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18600 constexpr const T& // constexpr in C++14
601 min(const T& a, const T& b);
Howard Hinnant3e519522010-05-11 19:42:16602
603template <class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18604 constexpr const T& // constexpr in C++14
605 min(const T& a, const T& b, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16606
Howard Hinnant4eb27b72010-08-21 20:10:01607template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18608 constexpr T // constexpr in C++14
609 min(initializer_list<T> t);
Howard Hinnant4eb27b72010-08-21 20:10:01610
611template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18612 constexpr T // constexpr in C++14
613 min(initializer_list<T> t, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01614
Marshall Clow146c14a2016-03-07 22:43:49615template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18616 constexpr const T& clamp(const T& v, const T& lo, const T& hi); // C++17
Marshall Clow146c14a2016-03-07 22:43:49617
618template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18619 constexpr const T& clamp(const T& v, const T& lo, const T& hi, Compare comp); // C++17
Marshall Clow146c14a2016-03-07 22:43:49620
Howard Hinnant4eb27b72010-08-21 20:10:01621template <class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18622 constexpr ForwardIterator // constexpr in C++14
623 max_element(ForwardIterator first, ForwardIterator last);
Howard Hinnant4eb27b72010-08-21 20:10:01624
625template <class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18626 constexpr ForwardIterator // constexpr in C++14
627 max_element(ForwardIterator first, ForwardIterator last, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01628
Howard Hinnant3e519522010-05-11 19:42:16629template <class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18630 constexpr const T& // constexpr in C++14
631 max(const T& a, const T& b);
Howard Hinnant3e519522010-05-11 19:42:16632
633template <class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18634 constexpr const T& // constexpr in C++14
635 max(const T& a, const T& b, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16636
Howard Hinnant4eb27b72010-08-21 20:10:01637template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18638 constexpr T // constexpr in C++14
639 max(initializer_list<T> t);
Howard Hinnant3e519522010-05-11 19:42:16640
Howard Hinnant4eb27b72010-08-21 20:10:01641template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18642 constexpr T // constexpr in C++14
643 max(initializer_list<T> t, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16644
Howard Hinnant4eb27b72010-08-21 20:10:01645template<class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18646 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++14
647 minmax_element(ForwardIterator first, ForwardIterator last);
Howard Hinnant3e519522010-05-11 19:42:16648
Howard Hinnant4eb27b72010-08-21 20:10:01649template<class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18650 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++14
651 minmax_element(ForwardIterator first, ForwardIterator last, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01652
653template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18654 constexpr pair<const T&, const T&> // constexpr in C++14
655 minmax(const T& a, const T& b);
Howard Hinnant4eb27b72010-08-21 20:10:01656
657template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18658 constexpr pair<const T&, const T&> // constexpr in C++14
659 minmax(const T& a, const T& b, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01660
661template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18662 constexpr pair<T, T> // constexpr in C++14
663 minmax(initializer_list<T> t);
Howard Hinnant4eb27b72010-08-21 20:10:01664
665template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18666 constexpr pair<T, T> // constexpr in C++14
667 minmax(initializer_list<T> t, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16668
669template <class InputIterator1, class InputIterator2>
Marshall Clow1b9a4ff2018-01-22 20:44:33670 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16671 lexicographical_compare(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
672
673template <class InputIterator1, class InputIterator2, class Compare>
Marshall Clow1b9a4ff2018-01-22 20:44:33674 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16675 lexicographical_compare(InputIterator1 first1, InputIterator1 last1,
676 InputIterator2 first2, InputIterator2 last2, Compare comp);
677
678template <class BidirectionalIterator>
Arthur O'Dwyerf851db32020-12-17 05:01:08679 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16680 next_permutation(BidirectionalIterator first, BidirectionalIterator last);
681
682template <class BidirectionalIterator, class Compare>
Arthur O'Dwyerf851db32020-12-17 05:01:08683 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16684 next_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
685
686template <class BidirectionalIterator>
Arthur O'Dwyerf851db32020-12-17 05:01:08687 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16688 prev_permutation(BidirectionalIterator first, BidirectionalIterator last);
689
690template <class BidirectionalIterator, class Compare>
Arthur O'Dwyerf851db32020-12-17 05:01:08691 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16692 prev_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16693} // std
694
695*/
696
Arthur O'Dwyerea2206d2022-02-04 18:09:30697#include <__bits>
Howard Hinnant3e519522010-05-11 19:42:16698#include <__config>
Louis Dionne134723e2021-06-17 15:30:11699#include <__debug>
Howard Hinnanta1d07d52012-07-26 17:09:09700#include <cstddef>
Arthur O'Dwyerbfbd73f2021-05-19 15:57:04701#include <cstring>
702#include <functional>
703#include <initializer_list>
Arthur O'Dwyerbfbd73f2021-05-19 15:57:04704#include <iterator>
705#include <memory>
706#include <type_traits>
Marshall Clowf56972e2018-09-12 19:41:40707#include <version>
Howard Hinnant5d1a7012013-08-14 18:00:20708
Nikolas Klauser52915d72022-03-05 18:17:07709#include <utility> // TODO: Remove this
710
Louis Dionne134723e2021-06-17 15:30:11711#include <__algorithm/adjacent_find.h>
712#include <__algorithm/all_of.h>
713#include <__algorithm/any_of.h>
714#include <__algorithm/binary_search.h>
715#include <__algorithm/clamp.h>
716#include <__algorithm/comp.h>
717#include <__algorithm/comp_ref_type.h>
718#include <__algorithm/copy.h>
719#include <__algorithm/copy_backward.h>
720#include <__algorithm/copy_if.h>
721#include <__algorithm/copy_n.h>
722#include <__algorithm/count.h>
723#include <__algorithm/count_if.h>
724#include <__algorithm/equal.h>
725#include <__algorithm/equal_range.h>
Louis Dionne134723e2021-06-17 15:30:11726#include <__algorithm/fill.h>
Arthur O'Dwyer4d81a462022-01-07 14:45:05727#include <__algorithm/fill_n.h>
Louis Dionne134723e2021-06-17 15:30:11728#include <__algorithm/find.h>
729#include <__algorithm/find_end.h>
730#include <__algorithm/find_first_of.h>
731#include <__algorithm/find_if.h>
732#include <__algorithm/find_if_not.h>
733#include <__algorithm/for_each.h>
734#include <__algorithm/for_each_n.h>
Louis Dionne134723e2021-06-17 15:30:11735#include <__algorithm/generate.h>
Arthur O'Dwyer4d81a462022-01-07 14:45:05736#include <__algorithm/generate_n.h>
Louis Dionne134723e2021-06-17 15:30:11737#include <__algorithm/half_positive.h>
Nikolas Klauser68f41312022-02-21 22:07:02738#include <__algorithm/in_found_result.h>
Nikolas Klauser1e77b392022-02-11 16:01:58739#include <__algorithm/in_fun_result.h>
Nikolas Klauserf3514af2022-01-25 10:21:47740#include <__algorithm/in_in_out_result.h>
Nikolas Klauserd3729bb2022-01-14 01:55:51741#include <__algorithm/in_in_result.h>
Nikolas Klauser610979b2022-02-03 01:17:03742#include <__algorithm/in_out_out_result.h>
Konstantin Varlamov8d23b742022-01-11 06:49:37743#include <__algorithm/in_out_result.h>
Louis Dionne134723e2021-06-17 15:30:11744#include <__algorithm/includes.h>
745#include <__algorithm/inplace_merge.h>
746#include <__algorithm/is_heap.h>
747#include <__algorithm/is_heap_until.h>
748#include <__algorithm/is_partitioned.h>
749#include <__algorithm/is_permutation.h>
750#include <__algorithm/is_sorted.h>
751#include <__algorithm/is_sorted_until.h>
Christopher Di Bella6adbc832021-06-05 02:47:47752#include <__algorithm/iter_swap.h>
Louis Dionne134723e2021-06-17 15:30:11753#include <__algorithm/lexicographical_compare.h>
754#include <__algorithm/lower_bound.h>
755#include <__algorithm/make_heap.h>
756#include <__algorithm/max.h>
757#include <__algorithm/max_element.h>
758#include <__algorithm/merge.h>
759#include <__algorithm/min.h>
760#include <__algorithm/min_element.h>
Nikolas Klauser807766b2022-02-21 21:48:36761#include <__algorithm/min_max_result.h>
Louis Dionne134723e2021-06-17 15:30:11762#include <__algorithm/minmax.h>
763#include <__algorithm/minmax_element.h>
764#include <__algorithm/mismatch.h>
765#include <__algorithm/move.h>
766#include <__algorithm/move_backward.h>
767#include <__algorithm/next_permutation.h>
768#include <__algorithm/none_of.h>
769#include <__algorithm/nth_element.h>
770#include <__algorithm/partial_sort.h>
771#include <__algorithm/partial_sort_copy.h>
772#include <__algorithm/partition.h>
773#include <__algorithm/partition_copy.h>
774#include <__algorithm/partition_point.h>
775#include <__algorithm/pop_heap.h>
776#include <__algorithm/prev_permutation.h>
777#include <__algorithm/push_heap.h>
Nikolas Klauser205557c2022-03-07 16:01:52778#include <__algorithm/ranges_max_element.h>
Nikolas Klauser3b470d12022-02-11 12:11:57779#include <__algorithm/ranges_min_element.h>
Nikolas Klauserc2cd15a2022-03-08 22:12:35780#include <__algorithm/ranges_mismatch.h>
Nikolas Klauser9d905312022-02-10 12:33:03781#include <__algorithm/ranges_swap_ranges.h>
Louis Dionne134723e2021-06-17 15:30:11782#include <__algorithm/remove.h>
783#include <__algorithm/remove_copy.h>
784#include <__algorithm/remove_copy_if.h>
785#include <__algorithm/remove_if.h>
786#include <__algorithm/replace.h>
787#include <__algorithm/replace_copy.h>
788#include <__algorithm/replace_copy_if.h>
789#include <__algorithm/replace_if.h>
790#include <__algorithm/reverse.h>
791#include <__algorithm/reverse_copy.h>
792#include <__algorithm/rotate.h>
793#include <__algorithm/rotate_copy.h>
794#include <__algorithm/sample.h>
795#include <__algorithm/search.h>
796#include <__algorithm/search_n.h>
797#include <__algorithm/set_difference.h>
798#include <__algorithm/set_intersection.h>
799#include <__algorithm/set_symmetric_difference.h>
800#include <__algorithm/set_union.h>
801#include <__algorithm/shift_left.h>
802#include <__algorithm/shift_right.h>
803#include <__algorithm/shuffle.h>
804#include <__algorithm/sift_down.h>
805#include <__algorithm/sort.h>
806#include <__algorithm/sort_heap.h>
807#include <__algorithm/stable_partition.h>
808#include <__algorithm/stable_sort.h>
Christopher Di Bella6adbc832021-06-05 02:47:47809#include <__algorithm/swap_ranges.h>
Louis Dionne134723e2021-06-17 15:30:11810#include <__algorithm/transform.h>
Louis Dionne134723e2021-06-17 15:30:11811#include <__algorithm/unique.h>
Arthur O'Dwyer4d81a462022-01-07 14:45:05812#include <__algorithm/unique_copy.h>
Louis Dionne134723e2021-06-17 15:30:11813#include <__algorithm/unwrap_iter.h>
814#include <__algorithm/upper_bound.h>
Eric Fiselierc1bd9192014-08-10 23:53:08815
Howard Hinnant073458b2011-10-17 20:05:10816#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Arthur O'Dwyerfa6b9e42022-02-02 01:16:40817# pragma GCC system_header
Howard Hinnant073458b2011-10-17 20:05:10818#endif
Howard Hinnant3e519522010-05-11 19:42:16819
Louis Dionne0a06eb92019-08-05 18:29:14820#if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17
Louis Dionne95689242019-08-06 21:11:24821# include <__pstl_algorithm>
Louis Dionne0a06eb92019-08-05 18:29:14822#endif
823
Louis Dionne4cd6ca12021-04-20 16:03:32824#endif // _LIBCPP_ALGORITHM