blob: 51a1781450fe2b5900caf791dde2961cc0d51712 [file] [log] [blame]
Howard Hinnant3e519522010-05-11 19:42:161// -*- C++ -*-
Louis Dionneeb8650a2021-11-17 21:25:012//===----------------------------------------------------------------------===//
Howard Hinnant3e519522010-05-11 19:42:163//
Chandler Carruth57b08b02019-01-19 10:56:404// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Howard Hinnant3e519522010-05-11 19:42:167//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP_ALGORITHM
11#define _LIBCPP_ALGORITHM
12
13/*
14 algorithm synopsis
15
16#include <initializer_list>
17
18namespace std
19{
20
Nikolas Klauserd3729bb2022-01-14 01:55:5121namespace ranges {
Nikolas Klauser1e77b392022-02-11 16:01:5822 template <class I, class F>
Nikolas Klauser807766b2022-02-21 21:48:3623 struct in_fun_result; // since C++20
Nikolas Klauser1e77b392022-02-11 16:01:5824
Nikolas Klauserd3729bb2022-01-14 01:55:5125 template <class I1, class I2>
Nikolas Klauser807766b2022-02-21 21:48:3626 struct in_in_result; // since C++20
Nikolas Klauserf3514af2022-01-25 10:21:4727
28 template <class I1, class I2, class O>
Nikolas Klauser807766b2022-02-21 21:48:3629 struct in_in_out_result; // since C++20
Nikolas Klauser610979b2022-02-03 01:17:0330
31 template <class I, class O1, class O2>
32 struct in_out_out_result; // since C++20
Nikolas Klauser1e77b392022-02-11 16:01:5833
Nikolas Klauser807766b2022-02-21 21:48:3634 template <class I1, class I2>
35 struct min_max_result; // since C++20
36
Nikolas Klauser68f41312022-02-21 22:07:0237 template <class I>
38 struct in_found_result; // since C++20
39
Nikolas Klauser3b470d12022-02-11 12:11:5740 template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
41 indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less> // since C++20
42 constexpr I min_element(I first, S last, Comp comp = {}, Proj proj = {});
43
44 template<forward_range R, class Proj = identity,
45 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less> // since C++20
46 constexpr borrowed_iterator_t<R> min_element(R&& r, Comp comp = {}, Proj proj = {});
Nikolas Klauserc2cd15a2022-03-08 22:12:3547
48 template <input_iterator I1, sentinel_for<_I1> S1, input_iterator I2, sentinel_for<_I2> S2,
49 class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
50 requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
51 constexpr mismatch_result<_I1, _I2>
52 mismatch()(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}) // since C++20
53
54 template <input_range R1, input_range R2,
55 class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
56 requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
57 constexpr mismatch_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>>
58 mismatch(R1&& r1, R2&& r2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}) // since C++20
Nikolas Klauseree0f8c42022-03-12 00:45:3559
Nikolas Klauseree0f8c42022-03-12 00:45:3560 requires indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
61 constexpr I find(I first, S last, const T& value, Proj proj = {}); // since C++20
62
63 template<input_range R, class T, class Proj = identity>
64 requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*>
65 constexpr borrowed_iterator_t<R>
66 find(R&& r, const T& value, Proj proj = {}); // since C++20
67
68 template<input_iterator I, sentinel_for<I> S, class Proj = identity,
69 indirect_unary_predicate<projected<I, Proj>> Pred>
70 constexpr I find_if(I first, S last, Pred pred, Proj proj = {}); // since C++20
71
72 template<input_range R, class Proj = identity,
73 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
74 constexpr borrowed_iterator_t<R>
75 find_if(R&& r, Pred pred, Proj proj = {}); // since C++20
76
77 template<input_iterator I, sentinel_for<I> S, class Proj = identity,
78 indirect_unary_predicate<projected<I, Proj>> Pred>
79 constexpr I find_if_not(I first, S last, Pred pred, Proj proj = {}); // since C++20
80
81 template<input_range R, class Proj = identity,
82 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
83 constexpr borrowed_iterator_t<R>
84 find_if_not(R&& r, Pred pred, Proj proj = {}); // since C++20
Nikolas Klauserf83d8332022-03-18 01:57:0885
86 template<class T, class Proj = identity,
87 indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
88 constexpr const T& min(const T& a, const T& b, Comp comp = {}, Proj proj = {}); // since C++20
89
90 template<copyable T, class Proj = identity,
91 indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
92 constexpr T min(initializer_list<T> r, Comp comp = {}, Proj proj = {}); // since C++20
93
94 template<input_range R, class Proj = identity,
95 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
96 requires indirectly_copyable_storable<iterator_t<R>, range_value_t<R>*>
97 constexpr range_value_t<R>
98 min(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
Nikolas Klauserd3729bb2022-01-14 01:55:5199}
100
Marshall Clow706ffef2018-01-15 17:20:36101 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16102 all_of(InputIterator first, InputIterator last, Predicate pred);
103
104template <class InputIterator, class Predicate>
Marshall Clow706ffef2018-01-15 17:20:36105 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16106 any_of(InputIterator first, InputIterator last, Predicate pred);
107
108template <class InputIterator, class Predicate>
Marshall Clow706ffef2018-01-15 17:20:36109 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16110 none_of(InputIterator first, InputIterator last, Predicate pred);
111
112template <class InputIterator, class Function>
Marshall Clow1b9a4ff2018-01-22 20:44:33113 constexpr Function // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16114 for_each(InputIterator first, InputIterator last, Function f);
115
Marshall Clowd5c65ff2017-05-25 02:29:54116template<class InputIterator, class Size, class Function>
Marshall Clow1b9a4ff2018-01-22 20:44:33117 constexpr InputIterator // constexpr in C++20
118 for_each_n(InputIterator first, Size n, Function f); // C++17
Marshall Clowd5c65ff2017-05-25 02:29:54119
Howard Hinnant3e519522010-05-11 19:42:16120template <class InputIterator, class T>
Marshall Clow86944282018-01-15 19:26:05121 constexpr InputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16122 find(InputIterator first, InputIterator last, const T& value);
123
124template <class InputIterator, class Predicate>
Marshall Clow86944282018-01-15 19:26:05125 constexpr InputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16126 find_if(InputIterator first, InputIterator last, Predicate pred);
127
128template<class InputIterator, class Predicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18129 constexpr InputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16130 find_if_not(InputIterator first, InputIterator last, Predicate pred);
131
132template <class ForwardIterator1, class ForwardIterator2>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18133 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16134 find_end(ForwardIterator1 first1, ForwardIterator1 last1,
135 ForwardIterator2 first2, ForwardIterator2 last2);
136
137template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18138 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16139 find_end(ForwardIterator1 first1, ForwardIterator1 last1,
140 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
141
142template <class ForwardIterator1, class ForwardIterator2>
Marshall Clow86944282018-01-15 19:26:05143 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16144 find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
145 ForwardIterator2 first2, ForwardIterator2 last2);
146
147template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow86944282018-01-15 19:26:05148 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16149 find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
150 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
151
152template <class ForwardIterator>
Marshall Clow86944282018-01-15 19:26:05153 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16154 adjacent_find(ForwardIterator first, ForwardIterator last);
155
156template <class ForwardIterator, class BinaryPredicate>
Marshall Clow86944282018-01-15 19:26:05157 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16158 adjacent_find(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
159
160template <class InputIterator, class T>
Marshall Clow056f15e2018-01-15 19:40:34161 constexpr typename iterator_traits<InputIterator>::difference_type // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16162 count(InputIterator first, InputIterator last, const T& value);
163
164template <class InputIterator, class Predicate>
Marshall Clow056f15e2018-01-15 19:40:34165 constexpr typename iterator_traits<InputIterator>::difference_type // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16166 count_if(InputIterator first, InputIterator last, Predicate pred);
167
168template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:10169 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16170 mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
171
Marshall Clow0b0bbd22013-05-09 21:14:23172template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:10173 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Aditya Kumar331fb802016-08-25 11:52:38174 mismatch(InputIterator1 first1, InputIterator1 last1,
Marshall Clow0b0bbd22013-05-09 21:14:23175 InputIterator2 first2, InputIterator2 last2); // **C++14**
176
Howard Hinnant3e519522010-05-11 19:42:16177template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:10178 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16179 mismatch(InputIterator1 first1, InputIterator1 last1,
180 InputIterator2 first2, BinaryPredicate pred);
181
Marshall Clow0b0bbd22013-05-09 21:14:23182template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:10183 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23184 mismatch(InputIterator1 first1, InputIterator1 last1,
185 InputIterator2 first2, InputIterator2 last2,
186 BinaryPredicate pred); // **C++14**
187
Howard Hinnant3e519522010-05-11 19:42:16188template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:10189 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16190 equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
191
Marshall Clow0b0bbd22013-05-09 21:14:23192template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:10193 constexpr bool // constexpr in C++20
Aditya Kumar331fb802016-08-25 11:52:38194 equal(InputIterator1 first1, InputIterator1 last1,
Marshall Clow0b0bbd22013-05-09 21:14:23195 InputIterator2 first2, InputIterator2 last2); // **C++14**
196
Howard Hinnant3e519522010-05-11 19:42:16197template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:10198 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16199 equal(InputIterator1 first1, InputIterator1 last1,
200 InputIterator2 first2, BinaryPredicate pred);
201
Marshall Clow0b0bbd22013-05-09 21:14:23202template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:10203 constexpr bool // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23204 equal(InputIterator1 first1, InputIterator1 last1,
205 InputIterator2 first2, InputIterator2 last2,
206 BinaryPredicate pred); // **C++14**
207
Howard Hinnant3e519522010-05-11 19:42:16208template<class ForwardIterator1, class ForwardIterator2>
Marshall Clow49c76432018-01-15 16:16:32209 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16210 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
211 ForwardIterator2 first2);
212
Marshall Clow0b0bbd22013-05-09 21:14:23213template<class ForwardIterator1, class ForwardIterator2>
Marshall Clow49c76432018-01-15 16:16:32214 constexpr bool // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23215 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
216 ForwardIterator2 first2, ForwardIterator2 last2); // **C++14**
217
Howard Hinnant3e519522010-05-11 19:42:16218template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow49c76432018-01-15 16:16:32219 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16220 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
221 ForwardIterator2 first2, BinaryPredicate pred);
222
Marshall Clow0b0bbd22013-05-09 21:14:23223template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow49c76432018-01-15 16:16:32224 constexpr bool // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23225 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
226 ForwardIterator2 first2, ForwardIterator2 last2,
227 BinaryPredicate pred); // **C++14**
228
Howard Hinnant3e519522010-05-11 19:42:16229template <class ForwardIterator1, class ForwardIterator2>
Marshall Clow12f0a772018-01-16 15:48:27230 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16231 search(ForwardIterator1 first1, ForwardIterator1 last1,
232 ForwardIterator2 first2, ForwardIterator2 last2);
233
234template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow12f0a772018-01-16 15:48:27235 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16236 search(ForwardIterator1 first1, ForwardIterator1 last1,
237 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
238
239template <class ForwardIterator, class Size, class T>
Marshall Clow12f0a772018-01-16 15:48:27240 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16241 search_n(ForwardIterator first, ForwardIterator last, Size count, const T& value);
242
243template <class ForwardIterator, class Size, class T, class BinaryPredicate>
Marshall Clow12f0a772018-01-16 15:48:27244 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16245 search_n(ForwardIterator first, ForwardIterator last,
246 Size count, const T& value, BinaryPredicate pred);
247
248template <class InputIterator, class OutputIterator>
Louis Dionne13c90a52019-11-06 12:02:41249 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16250 copy(InputIterator first, InputIterator last, OutputIterator result);
251
252template<class InputIterator, class OutputIterator, class Predicate>
Louis Dionne13c90a52019-11-06 12:02:41253 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16254 copy_if(InputIterator first, InputIterator last,
255 OutputIterator result, Predicate pred);
256
257template<class InputIterator, class Size, class OutputIterator>
Louis Dionne13c90a52019-11-06 12:02:41258 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16259 copy_n(InputIterator first, Size n, OutputIterator result);
260
261template <class BidirectionalIterator1, class BidirectionalIterator2>
Louis Dionne13c90a52019-11-06 12:02:41262 constexpr BidirectionalIterator2 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16263 copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last,
264 BidirectionalIterator2 result);
265
266template <class ForwardIterator1, class ForwardIterator2>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18267 constexpr ForwardIterator2 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16268 swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2);
269
Nikolas Klauser9d905312022-02-10 12:33:03270template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2>
271 requires indirectly_swappable<I1, I2>
272 constexpr ranges::swap_ranges_result<I1, I2>
273 ranges::swap_ranges(I1 first1, S1 last1, I2 first2, S2 last2);
274
275template<input_range R1, input_range R2>
276 requires indirectly_swappable<iterator_t<R1>, iterator_t<R2>>
277 constexpr ranges::swap_ranges_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>>
278 ranges::swap_ranges(R1&& r1, R2&& r2);
279
Howard Hinnant3e519522010-05-11 19:42:16280template <class ForwardIterator1, class ForwardIterator2>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18281 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16282 iter_swap(ForwardIterator1 a, ForwardIterator2 b);
283
284template <class InputIterator, class OutputIterator, class UnaryOperation>
Marshall Clow99894b62018-01-19 17:45:39285 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16286 transform(InputIterator first, InputIterator last, OutputIterator result, UnaryOperation op);
287
288template <class InputIterator1, class InputIterator2, class OutputIterator, class BinaryOperation>
Marshall Clow99894b62018-01-19 17:45:39289 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16290 transform(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2,
291 OutputIterator result, BinaryOperation binary_op);
292
293template <class ForwardIterator, class T>
Marshall Clow12c74232018-01-19 18:07:29294 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16295 replace(ForwardIterator first, ForwardIterator last, const T& old_value, const T& new_value);
296
297template <class ForwardIterator, class Predicate, class T>
Marshall Clow12c74232018-01-19 18:07:29298 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16299 replace_if(ForwardIterator first, ForwardIterator last, Predicate pred, const T& new_value);
300
301template <class InputIterator, class OutputIterator, class T>
Marshall Clow12c74232018-01-19 18:07:29302 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16303 replace_copy(InputIterator first, InputIterator last, OutputIterator result,
304 const T& old_value, const T& new_value);
305
306template <class InputIterator, class OutputIterator, class Predicate, class T>
Marshall Clow12c74232018-01-19 18:07:29307 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16308 replace_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred, const T& new_value);
309
310template <class ForwardIterator, class T>
Marshall Clow4bfb9312018-01-20 20:14:32311 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16312 fill(ForwardIterator first, ForwardIterator last, const T& value);
313
314template <class OutputIterator, class Size, class T>
Marshall Clow4bfb9312018-01-20 20:14:32315 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16316 fill_n(OutputIterator first, Size n, const T& value);
317
318template <class ForwardIterator, class Generator>
Marshall Clow4bfb9312018-01-20 20:14:32319 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16320 generate(ForwardIterator first, ForwardIterator last, Generator gen);
321
322template <class OutputIterator, class Size, class Generator>
Marshall Clow4bfb9312018-01-20 20:14:32323 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16324 generate_n(OutputIterator first, Size n, Generator gen);
325
326template <class ForwardIterator, class T>
Marshall Clowe8ea8292018-01-22 21:43:04327 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16328 remove(ForwardIterator first, ForwardIterator last, const T& value);
329
330template <class ForwardIterator, class Predicate>
Marshall Clowe8ea8292018-01-22 21:43:04331 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16332 remove_if(ForwardIterator first, ForwardIterator last, Predicate pred);
333
334template <class InputIterator, class OutputIterator, class T>
Marshall Clowe8ea8292018-01-22 21:43:04335 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16336 remove_copy(InputIterator first, InputIterator last, OutputIterator result, const T& value);
337
338template <class InputIterator, class OutputIterator, class Predicate>
Marshall Clowe8ea8292018-01-22 21:43:04339 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16340 remove_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred);
341
342template <class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18343 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16344 unique(ForwardIterator first, ForwardIterator last);
345
346template <class ForwardIterator, class BinaryPredicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18347 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16348 unique(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
349
350template <class InputIterator, class OutputIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18351 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16352 unique_copy(InputIterator first, InputIterator last, OutputIterator result);
353
354template <class InputIterator, class OutputIterator, class BinaryPredicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18355 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16356 unique_copy(InputIterator first, InputIterator last, OutputIterator result, BinaryPredicate pred);
357
358template <class BidirectionalIterator>
Arthur O'Dwyerf851db32020-12-17 05:01:08359 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16360 reverse(BidirectionalIterator first, BidirectionalIterator last);
361
362template <class BidirectionalIterator, class OutputIterator>
Marshall Clowe8ea8292018-01-22 21:43:04363 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16364 reverse_copy(BidirectionalIterator first, BidirectionalIterator last, OutputIterator result);
365
366template <class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18367 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16368 rotate(ForwardIterator first, ForwardIterator middle, ForwardIterator last);
369
370template <class ForwardIterator, class OutputIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18371 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16372 rotate_copy(ForwardIterator first, ForwardIterator middle, ForwardIterator last, OutputIterator result);
373
374template <class RandomAccessIterator>
375 void
Marshall Clow0f37a412017-03-23 13:43:37376 random_shuffle(RandomAccessIterator first, RandomAccessIterator last); // deprecated in C++14, removed in C++17
Howard Hinnant3e519522010-05-11 19:42:16377
378template <class RandomAccessIterator, class RandomNumberGenerator>
379 void
Marshall Clow06965c12014-03-03 06:14:19380 random_shuffle(RandomAccessIterator first, RandomAccessIterator last,
Marshall Clow0f37a412017-03-23 13:43:37381 RandomNumberGenerator& rand); // deprecated in C++14, removed in C++17
Howard Hinnant3e519522010-05-11 19:42:16382
Eric Fiseliere7154702016-08-28 22:14:37383template<class PopulationIterator, class SampleIterator,
384 class Distance, class UniformRandomBitGenerator>
385 SampleIterator sample(PopulationIterator first, PopulationIterator last,
386 SampleIterator out, Distance n,
387 UniformRandomBitGenerator&& g); // C++17
388
Howard Hinnantf9d540b2010-05-26 17:49:34389template<class RandomAccessIterator, class UniformRandomNumberGenerator>
390 void shuffle(RandomAccessIterator first, RandomAccessIterator last,
Howard Hinnantfb340102010-11-18 01:47:02391 UniformRandomNumberGenerator&& g);
Howard Hinnantf9d540b2010-05-26 17:49:34392
Arthur O'Dwyer3fbd3ea2020-12-26 06:39:03393template<class ForwardIterator>
394 constexpr ForwardIterator
395 shift_left(ForwardIterator first, ForwardIterator last,
396 typename iterator_traits<ForwardIterator>::difference_type n); // C++20
397
398template<class ForwardIterator>
399 constexpr ForwardIterator
400 shift_right(ForwardIterator first, ForwardIterator last,
401 typename iterator_traits<ForwardIterator>::difference_type n); // C++20
402
Howard Hinnant3e519522010-05-11 19:42:16403template <class InputIterator, class Predicate>
Marshall Clow49c76432018-01-15 16:16:32404 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16405 is_partitioned(InputIterator first, InputIterator last, Predicate pred);
406
407template <class ForwardIterator, class Predicate>
Arthur O'Dwyerf851db32020-12-17 05:01:08408 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16409 partition(ForwardIterator first, ForwardIterator last, Predicate pred);
410
411template <class InputIterator, class OutputIterator1,
412 class OutputIterator2, class Predicate>
Marshall Clow1b9a4ff2018-01-22 20:44:33413 constexpr pair<OutputIterator1, OutputIterator2> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16414 partition_copy(InputIterator first, InputIterator last,
415 OutputIterator1 out_true, OutputIterator2 out_false,
416 Predicate pred);
417
418template <class ForwardIterator, class Predicate>
419 ForwardIterator
420 stable_partition(ForwardIterator first, ForwardIterator last, Predicate pred);
421
422template<class ForwardIterator, class Predicate>
Marshall Clowd57c03d2018-01-16 02:34:41423 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16424 partition_point(ForwardIterator first, ForwardIterator last, Predicate pred);
425
426template <class ForwardIterator>
Marshall Clow49c76432018-01-15 16:16:32427 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16428 is_sorted(ForwardIterator first, ForwardIterator last);
429
430template <class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18431 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16432 is_sorted(ForwardIterator first, ForwardIterator last, Compare comp);
433
434template<class ForwardIterator>
Marshall Clow056f15e2018-01-15 19:40:34435 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16436 is_sorted_until(ForwardIterator first, ForwardIterator last);
437
438template <class ForwardIterator, class Compare>
Marshall Clow056f15e2018-01-15 19:40:34439 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16440 is_sorted_until(ForwardIterator first, ForwardIterator last, Compare comp);
441
442template <class RandomAccessIterator>
Arthur O'Dwyer493f1402020-12-20 20:21:42443 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16444 sort(RandomAccessIterator first, RandomAccessIterator last);
445
446template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer493f1402020-12-20 20:21:42447 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16448 sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
449
450template <class RandomAccessIterator>
451 void
452 stable_sort(RandomAccessIterator first, RandomAccessIterator last);
453
454template <class RandomAccessIterator, class Compare>
455 void
456 stable_sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
457
458template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18459 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16460 partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last);
461
462template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18463 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16464 partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last, Compare comp);
465
466template <class InputIterator, class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18467 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16468 partial_sort_copy(InputIterator first, InputIterator last,
469 RandomAccessIterator result_first, RandomAccessIterator result_last);
470
471template <class InputIterator, class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18472 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16473 partial_sort_copy(InputIterator first, InputIterator last,
474 RandomAccessIterator result_first, RandomAccessIterator result_last, Compare comp);
475
476template <class RandomAccessIterator>
Arthur O'Dwyer5d956562021-02-04 23:12:52477 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16478 nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last);
479
480template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5d956562021-02-04 23:12:52481 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16482 nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last, Compare comp);
483
484template <class ForwardIterator, class T>
Marshall Clowd57c03d2018-01-16 02:34:41485 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16486 lower_bound(ForwardIterator first, ForwardIterator last, const T& value);
487
488template <class ForwardIterator, class T, class Compare>
Marshall Clowd57c03d2018-01-16 02:34:41489 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16490 lower_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
491
492template <class ForwardIterator, class T>
Marshall Clowd57c03d2018-01-16 02:34:41493 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16494 upper_bound(ForwardIterator first, ForwardIterator last, const T& value);
495
496template <class ForwardIterator, class T, class Compare>
Marshall Clowd57c03d2018-01-16 02:34:41497 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16498 upper_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
499
500template <class ForwardIterator, class T>
Marshall Clowd57c03d2018-01-16 02:34:41501 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16502 equal_range(ForwardIterator first, ForwardIterator last, const T& value);
503
504template <class ForwardIterator, class T, class Compare>
Marshall Clowd57c03d2018-01-16 02:34:41505 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16506 equal_range(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
507
508template <class ForwardIterator, class T>
Marshall Clowd57c03d2018-01-16 02:34:41509 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16510 binary_search(ForwardIterator first, ForwardIterator last, const T& value);
511
512template <class ForwardIterator, class T, class Compare>
Marshall Clow8da1a482018-01-22 23:10:40513 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16514 binary_search(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
515
516template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer14098cf2020-12-04 18:47:12517 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16518 merge(InputIterator1 first1, InputIterator1 last1,
519 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
520
521template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer14098cf2020-12-04 18:47:12522 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16523 merge(InputIterator1 first1, InputIterator1 last1,
524 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
525
526template <class BidirectionalIterator>
527 void
528 inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last);
529
530template <class BidirectionalIterator, class Compare>
531 void
532 inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last, Compare comp);
533
534template <class InputIterator1, class InputIterator2>
Marshall Clow8da1a482018-01-22 23:10:40535 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16536 includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
537
538template <class InputIterator1, class InputIterator2, class Compare>
Marshall Clow8da1a482018-01-22 23:10:40539 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16540 includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, Compare comp);
541
542template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer14098cf2020-12-04 18:47:12543 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16544 set_union(InputIterator1 first1, InputIterator1 last1,
545 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
546
547template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer14098cf2020-12-04 18:47:12548 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16549 set_union(InputIterator1 first1, InputIterator1 last1,
550 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
551
552template <class InputIterator1, class InputIterator2, class OutputIterator>
Marshall Clow8da1a482018-01-22 23:10:40553 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16554 set_intersection(InputIterator1 first1, InputIterator1 last1,
555 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
556
557template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Marshall Clow8da1a482018-01-22 23:10:40558 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16559 set_intersection(InputIterator1 first1, InputIterator1 last1,
560 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
561
562template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer14098cf2020-12-04 18:47:12563 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16564 set_difference(InputIterator1 first1, InputIterator1 last1,
565 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
566
567template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer14098cf2020-12-04 18:47:12568 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16569 set_difference(InputIterator1 first1, InputIterator1 last1,
570 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
571
572template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer14098cf2020-12-04 18:47:12573 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16574 set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
575 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
576
577template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer14098cf2020-12-04 18:47:12578 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16579 set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
580 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
581
582template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18583 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16584 push_heap(RandomAccessIterator first, RandomAccessIterator last);
585
586template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18587 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16588 push_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
589
590template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18591 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16592 pop_heap(RandomAccessIterator first, RandomAccessIterator last);
593
594template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18595 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16596 pop_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
597
598template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18599 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16600 make_heap(RandomAccessIterator first, RandomAccessIterator last);
601
602template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18603 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16604 make_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
605
606template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18607 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16608 sort_heap(RandomAccessIterator first, RandomAccessIterator last);
609
610template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18611 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16612 sort_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
613
Howard Hinnantb3371f62010-08-22 00:02:43614template <class RandomAccessIterator>
Marshall Clow49c76432018-01-15 16:16:32615 constexpr bool // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43616 is_heap(RandomAccessIterator first, RandomAccessiterator last);
Howard Hinnant3e519522010-05-11 19:42:16617
Howard Hinnantb3371f62010-08-22 00:02:43618template <class RandomAccessIterator, class Compare>
Marshall Clow49c76432018-01-15 16:16:32619 constexpr bool // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43620 is_heap(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16621
Howard Hinnantb3371f62010-08-22 00:02:43622template <class RandomAccessIterator>
Marshall Clow49c76432018-01-15 16:16:32623 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43624 is_heap_until(RandomAccessIterator first, RandomAccessiterator last);
Howard Hinnant3e519522010-05-11 19:42:16625
Howard Hinnantb3371f62010-08-22 00:02:43626template <class RandomAccessIterator, class Compare>
Marshall Clow49c76432018-01-15 16:16:32627 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43628 is_heap_until(RandomAccessIterator first, RandomAccessiterator last, 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 ForwardIterator // constexpr in C++14
632 min_element(ForwardIterator first, ForwardIterator last);
Howard Hinnant4eb27b72010-08-21 20:10:01633
634template <class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18635 constexpr ForwardIterator // constexpr in C++14
636 min_element(ForwardIterator first, ForwardIterator last, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01637
Howard Hinnant3e519522010-05-11 19:42:16638template <class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18639 constexpr const T& // constexpr in C++14
640 min(const T& a, const T& b);
Howard Hinnant3e519522010-05-11 19:42:16641
642template <class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18643 constexpr const T& // constexpr in C++14
644 min(const T& a, const T& b, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16645
Howard Hinnant4eb27b72010-08-21 20:10:01646template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18647 constexpr T // constexpr in C++14
648 min(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 T // constexpr in C++14
652 min(initializer_list<T> t, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01653
Marshall Clow146c14a2016-03-07 22:43:49654template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18655 constexpr const T& clamp(const T& v, const T& lo, const T& hi); // C++17
Marshall Clow146c14a2016-03-07 22:43:49656
657template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18658 constexpr const T& clamp(const T& v, const T& lo, const T& hi, Compare comp); // C++17
Marshall Clow146c14a2016-03-07 22:43:49659
Howard Hinnant4eb27b72010-08-21 20:10:01660template <class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18661 constexpr ForwardIterator // constexpr in C++14
662 max_element(ForwardIterator first, ForwardIterator last);
Howard Hinnant4eb27b72010-08-21 20:10:01663
664template <class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18665 constexpr ForwardIterator // constexpr in C++14
666 max_element(ForwardIterator first, ForwardIterator last, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01667
Howard Hinnant3e519522010-05-11 19:42:16668template <class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18669 constexpr const T& // constexpr in C++14
670 max(const T& a, const T& b);
Howard Hinnant3e519522010-05-11 19:42:16671
672template <class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18673 constexpr const T& // constexpr in C++14
674 max(const T& a, const T& b, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16675
Howard Hinnant4eb27b72010-08-21 20:10:01676template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18677 constexpr T // constexpr in C++14
678 max(initializer_list<T> t);
Howard Hinnant3e519522010-05-11 19:42:16679
Howard Hinnant4eb27b72010-08-21 20:10:01680template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18681 constexpr T // constexpr in C++14
682 max(initializer_list<T> t, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16683
Howard Hinnant4eb27b72010-08-21 20:10:01684template<class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18685 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++14
686 minmax_element(ForwardIterator first, ForwardIterator last);
Howard Hinnant3e519522010-05-11 19:42:16687
Howard Hinnant4eb27b72010-08-21 20:10:01688template<class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18689 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++14
690 minmax_element(ForwardIterator first, ForwardIterator last, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01691
692template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18693 constexpr pair<const T&, const T&> // constexpr in C++14
694 minmax(const T& a, const T& b);
Howard Hinnant4eb27b72010-08-21 20:10:01695
696template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18697 constexpr pair<const T&, const T&> // constexpr in C++14
698 minmax(const T& a, const T& b, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01699
700template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18701 constexpr pair<T, T> // constexpr in C++14
702 minmax(initializer_list<T> t);
Howard Hinnant4eb27b72010-08-21 20:10:01703
704template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18705 constexpr pair<T, T> // constexpr in C++14
706 minmax(initializer_list<T> t, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16707
708template <class InputIterator1, class InputIterator2>
Marshall Clow1b9a4ff2018-01-22 20:44:33709 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16710 lexicographical_compare(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
711
712template <class InputIterator1, class InputIterator2, class Compare>
Marshall Clow1b9a4ff2018-01-22 20:44:33713 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16714 lexicographical_compare(InputIterator1 first1, InputIterator1 last1,
715 InputIterator2 first2, InputIterator2 last2, Compare comp);
716
717template <class BidirectionalIterator>
Arthur O'Dwyerf851db32020-12-17 05:01:08718 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16719 next_permutation(BidirectionalIterator first, BidirectionalIterator last);
720
721template <class BidirectionalIterator, class Compare>
Arthur O'Dwyerf851db32020-12-17 05:01:08722 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16723 next_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
724
725template <class BidirectionalIterator>
Arthur O'Dwyerf851db32020-12-17 05:01:08726 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16727 prev_permutation(BidirectionalIterator first, BidirectionalIterator last);
728
729template <class BidirectionalIterator, class Compare>
Arthur O'Dwyerf851db32020-12-17 05:01:08730 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16731 prev_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16732} // std
733
734*/
735
Arthur O'Dwyerea2206d2022-02-04 18:09:30736#include <__bits>
Howard Hinnant3e519522010-05-11 19:42:16737#include <__config>
Louis Dionne134723e2021-06-17 15:30:11738#include <__debug>
Howard Hinnanta1d07d52012-07-26 17:09:09739#include <cstddef>
Arthur O'Dwyerbfbd73f2021-05-19 15:57:04740#include <cstring>
741#include <functional>
742#include <initializer_list>
Arthur O'Dwyerbfbd73f2021-05-19 15:57:04743#include <iterator>
744#include <memory>
745#include <type_traits>
Marshall Clowf56972e2018-09-12 19:41:40746#include <version>
Howard Hinnant5d1a7012013-08-14 18:00:20747
Louis Dionne134723e2021-06-17 15:30:11748#include <__algorithm/adjacent_find.h>
749#include <__algorithm/all_of.h>
750#include <__algorithm/any_of.h>
751#include <__algorithm/binary_search.h>
752#include <__algorithm/clamp.h>
753#include <__algorithm/comp.h>
754#include <__algorithm/comp_ref_type.h>
755#include <__algorithm/copy.h>
756#include <__algorithm/copy_backward.h>
757#include <__algorithm/copy_if.h>
758#include <__algorithm/copy_n.h>
759#include <__algorithm/count.h>
760#include <__algorithm/count_if.h>
761#include <__algorithm/equal.h>
762#include <__algorithm/equal_range.h>
Louis Dionne134723e2021-06-17 15:30:11763#include <__algorithm/fill.h>
Arthur O'Dwyer4d81a462022-01-07 14:45:05764#include <__algorithm/fill_n.h>
Louis Dionne134723e2021-06-17 15:30:11765#include <__algorithm/find.h>
766#include <__algorithm/find_end.h>
767#include <__algorithm/find_first_of.h>
768#include <__algorithm/find_if.h>
769#include <__algorithm/find_if_not.h>
770#include <__algorithm/for_each.h>
771#include <__algorithm/for_each_n.h>
Louis Dionne134723e2021-06-17 15:30:11772#include <__algorithm/generate.h>
Arthur O'Dwyer4d81a462022-01-07 14:45:05773#include <__algorithm/generate_n.h>
Louis Dionne134723e2021-06-17 15:30:11774#include <__algorithm/half_positive.h>
Nikolas Klauser68f41312022-02-21 22:07:02775#include <__algorithm/in_found_result.h>
Nikolas Klauser1e77b392022-02-11 16:01:58776#include <__algorithm/in_fun_result.h>
Nikolas Klauserf3514af2022-01-25 10:21:47777#include <__algorithm/in_in_out_result.h>
Nikolas Klauserd3729bb2022-01-14 01:55:51778#include <__algorithm/in_in_result.h>
Nikolas Klauser610979b2022-02-03 01:17:03779#include <__algorithm/in_out_out_result.h>
Konstantin Varlamov8d23b742022-01-11 06:49:37780#include <__algorithm/in_out_result.h>
Louis Dionne134723e2021-06-17 15:30:11781#include <__algorithm/includes.h>
782#include <__algorithm/inplace_merge.h>
783#include <__algorithm/is_heap.h>
784#include <__algorithm/is_heap_until.h>
785#include <__algorithm/is_partitioned.h>
786#include <__algorithm/is_permutation.h>
787#include <__algorithm/is_sorted.h>
788#include <__algorithm/is_sorted_until.h>
Christopher Di Bella6adbc832021-06-05 02:47:47789#include <__algorithm/iter_swap.h>
Louis Dionne134723e2021-06-17 15:30:11790#include <__algorithm/lexicographical_compare.h>
791#include <__algorithm/lower_bound.h>
792#include <__algorithm/make_heap.h>
793#include <__algorithm/max.h>
794#include <__algorithm/max_element.h>
795#include <__algorithm/merge.h>
796#include <__algorithm/min.h>
797#include <__algorithm/min_element.h>
Nikolas Klauser807766b2022-02-21 21:48:36798#include <__algorithm/min_max_result.h>
Louis Dionne134723e2021-06-17 15:30:11799#include <__algorithm/minmax.h>
800#include <__algorithm/minmax_element.h>
801#include <__algorithm/mismatch.h>
802#include <__algorithm/move.h>
803#include <__algorithm/move_backward.h>
804#include <__algorithm/next_permutation.h>
805#include <__algorithm/none_of.h>
806#include <__algorithm/nth_element.h>
807#include <__algorithm/partial_sort.h>
808#include <__algorithm/partial_sort_copy.h>
809#include <__algorithm/partition.h>
810#include <__algorithm/partition_copy.h>
811#include <__algorithm/partition_point.h>
812#include <__algorithm/pop_heap.h>
813#include <__algorithm/prev_permutation.h>
814#include <__algorithm/push_heap.h>
Nikolas Klauseree0f8c42022-03-12 00:45:35815#include <__algorithm/ranges_find.h>
816#include <__algorithm/ranges_find_if.h>
817#include <__algorithm/ranges_find_if_not.h>
Nikolas Klauser205557c2022-03-07 16:01:52818#include <__algorithm/ranges_max_element.h>
Nikolas Klauserf83d8332022-03-18 01:57:08819#include <__algorithm/ranges_min.h>
Nikolas Klauser3b470d12022-02-11 12:11:57820#include <__algorithm/ranges_min_element.h>
Nikolas Klauserc2cd15a2022-03-08 22:12:35821#include <__algorithm/ranges_mismatch.h>
Nikolas Klauser9d905312022-02-10 12:33:03822#include <__algorithm/ranges_swap_ranges.h>
Louis Dionne134723e2021-06-17 15:30:11823#include <__algorithm/remove.h>
824#include <__algorithm/remove_copy.h>
825#include <__algorithm/remove_copy_if.h>
826#include <__algorithm/remove_if.h>
827#include <__algorithm/replace.h>
828#include <__algorithm/replace_copy.h>
829#include <__algorithm/replace_copy_if.h>
830#include <__algorithm/replace_if.h>
831#include <__algorithm/reverse.h>
832#include <__algorithm/reverse_copy.h>
833#include <__algorithm/rotate.h>
834#include <__algorithm/rotate_copy.h>
835#include <__algorithm/sample.h>
836#include <__algorithm/search.h>
837#include <__algorithm/search_n.h>
838#include <__algorithm/set_difference.h>
839#include <__algorithm/set_intersection.h>
840#include <__algorithm/set_symmetric_difference.h>
841#include <__algorithm/set_union.h>
842#include <__algorithm/shift_left.h>
843#include <__algorithm/shift_right.h>
844#include <__algorithm/shuffle.h>
845#include <__algorithm/sift_down.h>
846#include <__algorithm/sort.h>
847#include <__algorithm/sort_heap.h>
848#include <__algorithm/stable_partition.h>
849#include <__algorithm/stable_sort.h>
Christopher Di Bella6adbc832021-06-05 02:47:47850#include <__algorithm/swap_ranges.h>
Louis Dionne134723e2021-06-17 15:30:11851#include <__algorithm/transform.h>
Louis Dionne134723e2021-06-17 15:30:11852#include <__algorithm/unique.h>
Arthur O'Dwyer4d81a462022-01-07 14:45:05853#include <__algorithm/unique_copy.h>
Louis Dionne134723e2021-06-17 15:30:11854#include <__algorithm/unwrap_iter.h>
855#include <__algorithm/upper_bound.h>
Eric Fiselierc1bd9192014-08-10 23:53:08856
Howard Hinnant073458b2011-10-17 20:05:10857#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Arthur O'Dwyerfa6b9e42022-02-02 01:16:40858# pragma GCC system_header
Howard Hinnant073458b2011-10-17 20:05:10859#endif
Howard Hinnant3e519522010-05-11 19:42:16860
Louis Dionne0a06eb92019-08-05 18:29:14861#if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17
Louis Dionne95689242019-08-06 21:11:24862# include <__pstl_algorithm>
Louis Dionne0a06eb92019-08-05 18:29:14863#endif
864
Louis Dionne4cd6ca12021-04-20 16:03:32865#endif // _LIBCPP_ALGORITHM