blob: e5f1030be201161d818338b14cbd34ea77b90d69 [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 {
22 template <class I1, class I2>
Nikolas Klauserf3514af2022-01-25 10:21:4723 struct in_in_result; // since C++20
24
25 template <class I1, class I2, class O>
26 struct in_in_out_result; // since C++20
Nikolas Klauserd3729bb2022-01-14 01:55:5127}
28
Howard Hinnant3e519522010-05-11 19:42:1629template <class InputIterator, class Predicate>
Marshall Clow706ffef2018-01-15 17:20:3630 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1631 all_of(InputIterator first, InputIterator last, Predicate pred);
32
33template <class InputIterator, class Predicate>
Marshall Clow706ffef2018-01-15 17:20:3634 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1635 any_of(InputIterator first, InputIterator last, Predicate pred);
36
37template <class InputIterator, class Predicate>
Marshall Clow706ffef2018-01-15 17:20:3638 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1639 none_of(InputIterator first, InputIterator last, Predicate pred);
40
41template <class InputIterator, class Function>
Marshall Clow1b9a4ff2018-01-22 20:44:3342 constexpr Function // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1643 for_each(InputIterator first, InputIterator last, Function f);
44
Marshall Clowd5c65ff2017-05-25 02:29:5445template<class InputIterator, class Size, class Function>
Marshall Clow1b9a4ff2018-01-22 20:44:3346 constexpr InputIterator // constexpr in C++20
47 for_each_n(InputIterator first, Size n, Function f); // C++17
Marshall Clowd5c65ff2017-05-25 02:29:5448
Howard Hinnant3e519522010-05-11 19:42:1649template <class InputIterator, class T>
Marshall Clow86944282018-01-15 19:26:0550 constexpr InputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1651 find(InputIterator first, InputIterator last, const T& value);
52
53template <class InputIterator, class Predicate>
Marshall Clow86944282018-01-15 19:26:0554 constexpr InputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1655 find_if(InputIterator first, InputIterator last, Predicate pred);
56
57template<class InputIterator, class Predicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:1858 constexpr InputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1659 find_if_not(InputIterator first, InputIterator last, Predicate pred);
60
61template <class ForwardIterator1, class ForwardIterator2>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:1862 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1663 find_end(ForwardIterator1 first1, ForwardIterator1 last1,
64 ForwardIterator2 first2, ForwardIterator2 last2);
65
66template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:1867 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1668 find_end(ForwardIterator1 first1, ForwardIterator1 last1,
69 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
70
71template <class ForwardIterator1, class ForwardIterator2>
Marshall Clow86944282018-01-15 19:26:0572 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1673 find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
74 ForwardIterator2 first2, ForwardIterator2 last2);
75
76template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow86944282018-01-15 19:26:0577 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1678 find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
79 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
80
81template <class ForwardIterator>
Marshall Clow86944282018-01-15 19:26:0582 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1683 adjacent_find(ForwardIterator first, ForwardIterator last);
84
85template <class ForwardIterator, class BinaryPredicate>
Marshall Clow86944282018-01-15 19:26:0586 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1687 adjacent_find(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
88
89template <class InputIterator, class T>
Marshall Clow056f15e2018-01-15 19:40:3490 constexpr typename iterator_traits<InputIterator>::difference_type // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1691 count(InputIterator first, InputIterator last, const T& value);
92
93template <class InputIterator, class Predicate>
Marshall Clow056f15e2018-01-15 19:40:3494 constexpr typename iterator_traits<InputIterator>::difference_type // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1695 count_if(InputIterator first, InputIterator last, Predicate pred);
96
97template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:1098 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1699 mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
100
Marshall Clow0b0bbd22013-05-09 21:14:23101template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:10102 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Aditya Kumar331fb802016-08-25 11:52:38103 mismatch(InputIterator1 first1, InputIterator1 last1,
Marshall Clow0b0bbd22013-05-09 21:14:23104 InputIterator2 first2, InputIterator2 last2); // **C++14**
105
Howard Hinnant3e519522010-05-11 19:42:16106template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:10107 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16108 mismatch(InputIterator1 first1, InputIterator1 last1,
109 InputIterator2 first2, BinaryPredicate pred);
110
Marshall Clow0b0bbd22013-05-09 21:14:23111template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:10112 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23113 mismatch(InputIterator1 first1, InputIterator1 last1,
114 InputIterator2 first2, InputIterator2 last2,
115 BinaryPredicate pred); // **C++14**
116
Howard Hinnant3e519522010-05-11 19:42:16117template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:10118 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16119 equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
120
Marshall Clow0b0bbd22013-05-09 21:14:23121template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:10122 constexpr bool // constexpr in C++20
Aditya Kumar331fb802016-08-25 11:52:38123 equal(InputIterator1 first1, InputIterator1 last1,
Marshall Clow0b0bbd22013-05-09 21:14:23124 InputIterator2 first2, InputIterator2 last2); // **C++14**
125
Howard Hinnant3e519522010-05-11 19:42:16126template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:10127 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16128 equal(InputIterator1 first1, InputIterator1 last1,
129 InputIterator2 first2, BinaryPredicate pred);
130
Marshall Clow0b0bbd22013-05-09 21:14:23131template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:10132 constexpr bool // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23133 equal(InputIterator1 first1, InputIterator1 last1,
134 InputIterator2 first2, InputIterator2 last2,
135 BinaryPredicate pred); // **C++14**
136
Howard Hinnant3e519522010-05-11 19:42:16137template<class ForwardIterator1, class ForwardIterator2>
Marshall Clow49c76432018-01-15 16:16:32138 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16139 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
140 ForwardIterator2 first2);
141
Marshall Clow0b0bbd22013-05-09 21:14:23142template<class ForwardIterator1, class ForwardIterator2>
Marshall Clow49c76432018-01-15 16:16:32143 constexpr bool // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23144 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
145 ForwardIterator2 first2, ForwardIterator2 last2); // **C++14**
146
Howard Hinnant3e519522010-05-11 19:42:16147template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow49c76432018-01-15 16:16:32148 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16149 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
150 ForwardIterator2 first2, BinaryPredicate pred);
151
Marshall Clow0b0bbd22013-05-09 21:14:23152template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow49c76432018-01-15 16:16:32153 constexpr bool // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23154 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
155 ForwardIterator2 first2, ForwardIterator2 last2,
156 BinaryPredicate pred); // **C++14**
157
Howard Hinnant3e519522010-05-11 19:42:16158template <class ForwardIterator1, class ForwardIterator2>
Marshall Clow12f0a772018-01-16 15:48:27159 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16160 search(ForwardIterator1 first1, ForwardIterator1 last1,
161 ForwardIterator2 first2, ForwardIterator2 last2);
162
163template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow12f0a772018-01-16 15:48:27164 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16165 search(ForwardIterator1 first1, ForwardIterator1 last1,
166 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
167
168template <class ForwardIterator, class Size, class T>
Marshall Clow12f0a772018-01-16 15:48:27169 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16170 search_n(ForwardIterator first, ForwardIterator last, Size count, const T& value);
171
172template <class ForwardIterator, class Size, class T, class BinaryPredicate>
Marshall Clow12f0a772018-01-16 15:48:27173 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16174 search_n(ForwardIterator first, ForwardIterator last,
175 Size count, const T& value, BinaryPredicate pred);
176
177template <class InputIterator, class OutputIterator>
Louis Dionne13c90a52019-11-06 12:02:41178 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16179 copy(InputIterator first, InputIterator last, OutputIterator result);
180
181template<class InputIterator, class OutputIterator, class Predicate>
Louis Dionne13c90a52019-11-06 12:02:41182 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16183 copy_if(InputIterator first, InputIterator last,
184 OutputIterator result, Predicate pred);
185
186template<class InputIterator, class Size, class OutputIterator>
Louis Dionne13c90a52019-11-06 12:02:41187 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16188 copy_n(InputIterator first, Size n, OutputIterator result);
189
190template <class BidirectionalIterator1, class BidirectionalIterator2>
Louis Dionne13c90a52019-11-06 12:02:41191 constexpr BidirectionalIterator2 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16192 copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last,
193 BidirectionalIterator2 result);
194
195template <class ForwardIterator1, class ForwardIterator2>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18196 constexpr ForwardIterator2 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16197 swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2);
198
199template <class ForwardIterator1, class ForwardIterator2>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18200 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16201 iter_swap(ForwardIterator1 a, ForwardIterator2 b);
202
203template <class InputIterator, class OutputIterator, class UnaryOperation>
Marshall Clow99894b62018-01-19 17:45:39204 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16205 transform(InputIterator first, InputIterator last, OutputIterator result, UnaryOperation op);
206
207template <class InputIterator1, class InputIterator2, class OutputIterator, class BinaryOperation>
Marshall Clow99894b62018-01-19 17:45:39208 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16209 transform(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2,
210 OutputIterator result, BinaryOperation binary_op);
211
212template <class ForwardIterator, class T>
Marshall Clow12c74232018-01-19 18:07:29213 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16214 replace(ForwardIterator first, ForwardIterator last, const T& old_value, const T& new_value);
215
216template <class ForwardIterator, class Predicate, class T>
Marshall Clow12c74232018-01-19 18:07:29217 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16218 replace_if(ForwardIterator first, ForwardIterator last, Predicate pred, const T& new_value);
219
220template <class InputIterator, class OutputIterator, class T>
Marshall Clow12c74232018-01-19 18:07:29221 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16222 replace_copy(InputIterator first, InputIterator last, OutputIterator result,
223 const T& old_value, const T& new_value);
224
225template <class InputIterator, class OutputIterator, class Predicate, class T>
Marshall Clow12c74232018-01-19 18:07:29226 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16227 replace_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred, const T& new_value);
228
229template <class ForwardIterator, class T>
Marshall Clow4bfb9312018-01-20 20:14:32230 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16231 fill(ForwardIterator first, ForwardIterator last, const T& value);
232
233template <class OutputIterator, class Size, class T>
Marshall Clow4bfb9312018-01-20 20:14:32234 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16235 fill_n(OutputIterator first, Size n, const T& value);
236
237template <class ForwardIterator, class Generator>
Marshall Clow4bfb9312018-01-20 20:14:32238 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16239 generate(ForwardIterator first, ForwardIterator last, Generator gen);
240
241template <class OutputIterator, class Size, class Generator>
Marshall Clow4bfb9312018-01-20 20:14:32242 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16243 generate_n(OutputIterator first, Size n, Generator gen);
244
245template <class ForwardIterator, class T>
Marshall Clowe8ea8292018-01-22 21:43:04246 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16247 remove(ForwardIterator first, ForwardIterator last, const T& value);
248
249template <class ForwardIterator, class Predicate>
Marshall Clowe8ea8292018-01-22 21:43:04250 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16251 remove_if(ForwardIterator first, ForwardIterator last, Predicate pred);
252
253template <class InputIterator, class OutputIterator, class T>
Marshall Clowe8ea8292018-01-22 21:43:04254 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16255 remove_copy(InputIterator first, InputIterator last, OutputIterator result, const T& value);
256
257template <class InputIterator, class OutputIterator, class Predicate>
Marshall Clowe8ea8292018-01-22 21:43:04258 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16259 remove_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred);
260
261template <class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18262 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16263 unique(ForwardIterator first, ForwardIterator last);
264
265template <class ForwardIterator, class BinaryPredicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18266 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16267 unique(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
268
269template <class InputIterator, class OutputIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18270 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16271 unique_copy(InputIterator first, InputIterator last, OutputIterator result);
272
273template <class InputIterator, class OutputIterator, class BinaryPredicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18274 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16275 unique_copy(InputIterator first, InputIterator last, OutputIterator result, BinaryPredicate pred);
276
277template <class BidirectionalIterator>
Arthur O'Dwyerf851db32020-12-17 05:01:08278 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16279 reverse(BidirectionalIterator first, BidirectionalIterator last);
280
281template <class BidirectionalIterator, class OutputIterator>
Marshall Clowe8ea8292018-01-22 21:43:04282 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16283 reverse_copy(BidirectionalIterator first, BidirectionalIterator last, OutputIterator result);
284
285template <class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18286 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16287 rotate(ForwardIterator first, ForwardIterator middle, ForwardIterator last);
288
289template <class ForwardIterator, class OutputIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18290 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16291 rotate_copy(ForwardIterator first, ForwardIterator middle, ForwardIterator last, OutputIterator result);
292
293template <class RandomAccessIterator>
294 void
Marshall Clow0f37a412017-03-23 13:43:37295 random_shuffle(RandomAccessIterator first, RandomAccessIterator last); // deprecated in C++14, removed in C++17
Howard Hinnant3e519522010-05-11 19:42:16296
297template <class RandomAccessIterator, class RandomNumberGenerator>
298 void
Marshall Clow06965c12014-03-03 06:14:19299 random_shuffle(RandomAccessIterator first, RandomAccessIterator last,
Marshall Clow0f37a412017-03-23 13:43:37300 RandomNumberGenerator& rand); // deprecated in C++14, removed in C++17
Howard Hinnant3e519522010-05-11 19:42:16301
Eric Fiseliere7154702016-08-28 22:14:37302template<class PopulationIterator, class SampleIterator,
303 class Distance, class UniformRandomBitGenerator>
304 SampleIterator sample(PopulationIterator first, PopulationIterator last,
305 SampleIterator out, Distance n,
306 UniformRandomBitGenerator&& g); // C++17
307
Howard Hinnantf9d540b2010-05-26 17:49:34308template<class RandomAccessIterator, class UniformRandomNumberGenerator>
309 void shuffle(RandomAccessIterator first, RandomAccessIterator last,
Howard Hinnantfb340102010-11-18 01:47:02310 UniformRandomNumberGenerator&& g);
Howard Hinnantf9d540b2010-05-26 17:49:34311
Arthur O'Dwyer3fbd3ea2020-12-26 06:39:03312template<class ForwardIterator>
313 constexpr ForwardIterator
314 shift_left(ForwardIterator first, ForwardIterator last,
315 typename iterator_traits<ForwardIterator>::difference_type n); // C++20
316
317template<class ForwardIterator>
318 constexpr ForwardIterator
319 shift_right(ForwardIterator first, ForwardIterator last,
320 typename iterator_traits<ForwardIterator>::difference_type n); // C++20
321
Howard Hinnant3e519522010-05-11 19:42:16322template <class InputIterator, class Predicate>
Marshall Clow49c76432018-01-15 16:16:32323 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16324 is_partitioned(InputIterator first, InputIterator last, Predicate pred);
325
326template <class ForwardIterator, class Predicate>
Arthur O'Dwyerf851db32020-12-17 05:01:08327 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16328 partition(ForwardIterator first, ForwardIterator last, Predicate pred);
329
330template <class InputIterator, class OutputIterator1,
331 class OutputIterator2, class Predicate>
Marshall Clow1b9a4ff2018-01-22 20:44:33332 constexpr pair<OutputIterator1, OutputIterator2> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16333 partition_copy(InputIterator first, InputIterator last,
334 OutputIterator1 out_true, OutputIterator2 out_false,
335 Predicate pred);
336
337template <class ForwardIterator, class Predicate>
338 ForwardIterator
339 stable_partition(ForwardIterator first, ForwardIterator last, Predicate pred);
340
341template<class ForwardIterator, class Predicate>
Marshall Clowd57c03d2018-01-16 02:34:41342 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16343 partition_point(ForwardIterator first, ForwardIterator last, Predicate pred);
344
345template <class ForwardIterator>
Marshall Clow49c76432018-01-15 16:16:32346 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16347 is_sorted(ForwardIterator first, ForwardIterator last);
348
349template <class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18350 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16351 is_sorted(ForwardIterator first, ForwardIterator last, Compare comp);
352
353template<class ForwardIterator>
Marshall Clow056f15e2018-01-15 19:40:34354 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16355 is_sorted_until(ForwardIterator first, ForwardIterator last);
356
357template <class ForwardIterator, class Compare>
Marshall Clow056f15e2018-01-15 19:40:34358 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16359 is_sorted_until(ForwardIterator first, ForwardIterator last, Compare comp);
360
361template <class RandomAccessIterator>
Arthur O'Dwyer493f1402020-12-20 20:21:42362 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16363 sort(RandomAccessIterator first, RandomAccessIterator last);
364
365template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer493f1402020-12-20 20:21:42366 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16367 sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
368
369template <class RandomAccessIterator>
370 void
371 stable_sort(RandomAccessIterator first, RandomAccessIterator last);
372
373template <class RandomAccessIterator, class Compare>
374 void
375 stable_sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
376
377template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18378 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16379 partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last);
380
381template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18382 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16383 partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last, Compare comp);
384
385template <class InputIterator, class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18386 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16387 partial_sort_copy(InputIterator first, InputIterator last,
388 RandomAccessIterator result_first, RandomAccessIterator result_last);
389
390template <class InputIterator, class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18391 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16392 partial_sort_copy(InputIterator first, InputIterator last,
393 RandomAccessIterator result_first, RandomAccessIterator result_last, Compare comp);
394
395template <class RandomAccessIterator>
Arthur O'Dwyer5d956562021-02-04 23:12:52396 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16397 nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last);
398
399template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5d956562021-02-04 23:12:52400 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16401 nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last, Compare comp);
402
403template <class ForwardIterator, class T>
Marshall Clowd57c03d2018-01-16 02:34:41404 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16405 lower_bound(ForwardIterator first, ForwardIterator last, const T& value);
406
407template <class ForwardIterator, class T, class Compare>
Marshall Clowd57c03d2018-01-16 02:34:41408 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16409 lower_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
410
411template <class ForwardIterator, class T>
Marshall Clowd57c03d2018-01-16 02:34:41412 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16413 upper_bound(ForwardIterator first, ForwardIterator last, const T& value);
414
415template <class ForwardIterator, class T, class Compare>
Marshall Clowd57c03d2018-01-16 02:34:41416 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16417 upper_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
418
419template <class ForwardIterator, class T>
Marshall Clowd57c03d2018-01-16 02:34:41420 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16421 equal_range(ForwardIterator first, ForwardIterator last, const T& value);
422
423template <class ForwardIterator, class T, class Compare>
Marshall Clowd57c03d2018-01-16 02:34:41424 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16425 equal_range(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
426
427template <class ForwardIterator, class T>
Marshall Clowd57c03d2018-01-16 02:34:41428 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16429 binary_search(ForwardIterator first, ForwardIterator last, const T& value);
430
431template <class ForwardIterator, class T, class Compare>
Marshall Clow8da1a482018-01-22 23:10:40432 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16433 binary_search(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
434
435template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer14098cf2020-12-04 18:47:12436 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16437 merge(InputIterator1 first1, InputIterator1 last1,
438 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
439
440template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer14098cf2020-12-04 18:47:12441 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16442 merge(InputIterator1 first1, InputIterator1 last1,
443 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
444
445template <class BidirectionalIterator>
446 void
447 inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last);
448
449template <class BidirectionalIterator, class Compare>
450 void
451 inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last, Compare comp);
452
453template <class InputIterator1, class InputIterator2>
Marshall Clow8da1a482018-01-22 23:10:40454 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16455 includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
456
457template <class InputIterator1, class InputIterator2, class Compare>
Marshall Clow8da1a482018-01-22 23:10:40458 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16459 includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, Compare comp);
460
461template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer14098cf2020-12-04 18:47:12462 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16463 set_union(InputIterator1 first1, InputIterator1 last1,
464 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
465
466template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer14098cf2020-12-04 18:47:12467 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16468 set_union(InputIterator1 first1, InputIterator1 last1,
469 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
470
471template <class InputIterator1, class InputIterator2, class OutputIterator>
Marshall Clow8da1a482018-01-22 23:10:40472 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16473 set_intersection(InputIterator1 first1, InputIterator1 last1,
474 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
475
476template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Marshall Clow8da1a482018-01-22 23:10:40477 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16478 set_intersection(InputIterator1 first1, InputIterator1 last1,
479 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
480
481template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer14098cf2020-12-04 18:47:12482 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16483 set_difference(InputIterator1 first1, InputIterator1 last1,
484 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
485
486template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer14098cf2020-12-04 18:47:12487 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16488 set_difference(InputIterator1 first1, InputIterator1 last1,
489 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
490
491template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer14098cf2020-12-04 18:47:12492 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16493 set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
494 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
495
496template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer14098cf2020-12-04 18:47:12497 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16498 set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
499 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
500
501template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18502 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16503 push_heap(RandomAccessIterator first, RandomAccessIterator last);
504
505template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18506 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16507 push_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
508
509template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18510 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16511 pop_heap(RandomAccessIterator first, RandomAccessIterator last);
512
513template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18514 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16515 pop_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
516
517template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18518 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16519 make_heap(RandomAccessIterator first, RandomAccessIterator last);
520
521template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18522 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16523 make_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
524
525template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18526 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16527 sort_heap(RandomAccessIterator first, RandomAccessIterator last);
528
529template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18530 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16531 sort_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
532
Howard Hinnantb3371f62010-08-22 00:02:43533template <class RandomAccessIterator>
Marshall Clow49c76432018-01-15 16:16:32534 constexpr bool // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43535 is_heap(RandomAccessIterator first, RandomAccessiterator last);
Howard Hinnant3e519522010-05-11 19:42:16536
Howard Hinnantb3371f62010-08-22 00:02:43537template <class RandomAccessIterator, class Compare>
Marshall Clow49c76432018-01-15 16:16:32538 constexpr bool // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43539 is_heap(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16540
Howard Hinnantb3371f62010-08-22 00:02:43541template <class RandomAccessIterator>
Marshall Clow49c76432018-01-15 16:16:32542 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43543 is_heap_until(RandomAccessIterator first, RandomAccessiterator last);
Howard Hinnant3e519522010-05-11 19:42:16544
Howard Hinnantb3371f62010-08-22 00:02:43545template <class RandomAccessIterator, class Compare>
Marshall Clow49c76432018-01-15 16:16:32546 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43547 is_heap_until(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16548
Howard Hinnant4eb27b72010-08-21 20:10:01549template <class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18550 constexpr ForwardIterator // constexpr in C++14
551 min_element(ForwardIterator first, ForwardIterator last);
Howard Hinnant4eb27b72010-08-21 20:10:01552
553template <class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18554 constexpr ForwardIterator // constexpr in C++14
555 min_element(ForwardIterator first, ForwardIterator last, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01556
Howard Hinnant3e519522010-05-11 19:42:16557template <class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18558 constexpr const T& // constexpr in C++14
559 min(const T& a, const T& b);
Howard Hinnant3e519522010-05-11 19:42:16560
561template <class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18562 constexpr const T& // constexpr in C++14
563 min(const T& a, const T& b, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16564
Howard Hinnant4eb27b72010-08-21 20:10:01565template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18566 constexpr T // constexpr in C++14
567 min(initializer_list<T> t);
Howard Hinnant4eb27b72010-08-21 20:10:01568
569template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18570 constexpr T // constexpr in C++14
571 min(initializer_list<T> t, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01572
Marshall Clow146c14a2016-03-07 22:43:49573template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18574 constexpr const T& clamp(const T& v, const T& lo, const T& hi); // C++17
Marshall Clow146c14a2016-03-07 22:43:49575
576template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18577 constexpr const T& clamp(const T& v, const T& lo, const T& hi, Compare comp); // C++17
Marshall Clow146c14a2016-03-07 22:43:49578
Howard Hinnant4eb27b72010-08-21 20:10:01579template <class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18580 constexpr ForwardIterator // constexpr in C++14
581 max_element(ForwardIterator first, ForwardIterator last);
Howard Hinnant4eb27b72010-08-21 20:10:01582
583template <class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18584 constexpr ForwardIterator // constexpr in C++14
585 max_element(ForwardIterator first, ForwardIterator last, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01586
Howard Hinnant3e519522010-05-11 19:42:16587template <class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18588 constexpr const T& // constexpr in C++14
589 max(const T& a, const T& b);
Howard Hinnant3e519522010-05-11 19:42:16590
591template <class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18592 constexpr const T& // constexpr in C++14
593 max(const T& a, const T& b, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16594
Howard Hinnant4eb27b72010-08-21 20:10:01595template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18596 constexpr T // constexpr in C++14
597 max(initializer_list<T> t);
Howard Hinnant3e519522010-05-11 19:42:16598
Howard Hinnant4eb27b72010-08-21 20:10:01599template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18600 constexpr T // constexpr in C++14
601 max(initializer_list<T> t, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16602
Howard Hinnant4eb27b72010-08-21 20:10:01603template<class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18604 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++14
605 minmax_element(ForwardIterator first, ForwardIterator last);
Howard Hinnant3e519522010-05-11 19:42:16606
Howard Hinnant4eb27b72010-08-21 20:10:01607template<class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18608 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++14
609 minmax_element(ForwardIterator first, ForwardIterator last, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01610
611template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18612 constexpr pair<const T&, const T&> // constexpr in C++14
613 minmax(const T& a, const T& b);
Howard Hinnant4eb27b72010-08-21 20:10:01614
615template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18616 constexpr pair<const T&, const T&> // constexpr in C++14
617 minmax(const T& a, const T& b, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01618
619template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18620 constexpr pair<T, T> // constexpr in C++14
621 minmax(initializer_list<T> t);
Howard Hinnant4eb27b72010-08-21 20:10:01622
623template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18624 constexpr pair<T, T> // constexpr in C++14
625 minmax(initializer_list<T> t, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16626
627template <class InputIterator1, class InputIterator2>
Marshall Clow1b9a4ff2018-01-22 20:44:33628 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16629 lexicographical_compare(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
630
631template <class InputIterator1, class InputIterator2, class Compare>
Marshall Clow1b9a4ff2018-01-22 20:44:33632 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16633 lexicographical_compare(InputIterator1 first1, InputIterator1 last1,
634 InputIterator2 first2, InputIterator2 last2, Compare comp);
635
636template <class BidirectionalIterator>
Arthur O'Dwyerf851db32020-12-17 05:01:08637 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16638 next_permutation(BidirectionalIterator first, BidirectionalIterator last);
639
640template <class BidirectionalIterator, class Compare>
Arthur O'Dwyerf851db32020-12-17 05:01:08641 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16642 next_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
643
644template <class BidirectionalIterator>
Arthur O'Dwyerf851db32020-12-17 05:01:08645 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16646 prev_permutation(BidirectionalIterator first, BidirectionalIterator last);
647
648template <class BidirectionalIterator, class Compare>
Arthur O'Dwyerf851db32020-12-17 05:01:08649 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16650 prev_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
651
Konstantin Varlamov8d23b742022-01-11 06:49:37652namespace ranges {
653// [algorithms.results], algorithm result types
654template<class InputIterator, class OutputIterator>
655 struct in_out_result;
656}
657
Howard Hinnant3e519522010-05-11 19:42:16658} // std
659
660*/
661
Nikolas Klausercf54cb22022-01-03 00:24:09662#include <__bits> // __libcpp_clz
Howard Hinnant3e519522010-05-11 19:42:16663#include <__config>
Louis Dionne134723e2021-06-17 15:30:11664#include <__debug>
Howard Hinnanta1d07d52012-07-26 17:09:09665#include <cstddef>
Arthur O'Dwyerbfbd73f2021-05-19 15:57:04666#include <cstring>
667#include <functional>
668#include <initializer_list>
Arthur O'Dwyerbfbd73f2021-05-19 15:57:04669#include <iterator>
670#include <memory>
671#include <type_traits>
672#include <utility> // swap_ranges
Marshall Clowf56972e2018-09-12 19:41:40673#include <version>
Howard Hinnant5d1a7012013-08-14 18:00:20674
Louis Dionne134723e2021-06-17 15:30:11675#include <__algorithm/adjacent_find.h>
676#include <__algorithm/all_of.h>
677#include <__algorithm/any_of.h>
678#include <__algorithm/binary_search.h>
679#include <__algorithm/clamp.h>
680#include <__algorithm/comp.h>
681#include <__algorithm/comp_ref_type.h>
682#include <__algorithm/copy.h>
683#include <__algorithm/copy_backward.h>
684#include <__algorithm/copy_if.h>
685#include <__algorithm/copy_n.h>
686#include <__algorithm/count.h>
687#include <__algorithm/count_if.h>
688#include <__algorithm/equal.h>
689#include <__algorithm/equal_range.h>
Louis Dionne134723e2021-06-17 15:30:11690#include <__algorithm/fill.h>
Arthur O'Dwyer4d81a462022-01-07 14:45:05691#include <__algorithm/fill_n.h>
Louis Dionne134723e2021-06-17 15:30:11692#include <__algorithm/find.h>
693#include <__algorithm/find_end.h>
694#include <__algorithm/find_first_of.h>
695#include <__algorithm/find_if.h>
696#include <__algorithm/find_if_not.h>
697#include <__algorithm/for_each.h>
698#include <__algorithm/for_each_n.h>
Louis Dionne134723e2021-06-17 15:30:11699#include <__algorithm/generate.h>
Arthur O'Dwyer4d81a462022-01-07 14:45:05700#include <__algorithm/generate_n.h>
Louis Dionne134723e2021-06-17 15:30:11701#include <__algorithm/half_positive.h>
Nikolas Klauserf3514af2022-01-25 10:21:47702#include <__algorithm/in_in_out_result.h>
Nikolas Klauserd3729bb2022-01-14 01:55:51703#include <__algorithm/in_in_result.h>
Konstantin Varlamov8d23b742022-01-11 06:49:37704#include <__algorithm/in_out_result.h>
Louis Dionne134723e2021-06-17 15:30:11705#include <__algorithm/includes.h>
706#include <__algorithm/inplace_merge.h>
707#include <__algorithm/is_heap.h>
708#include <__algorithm/is_heap_until.h>
709#include <__algorithm/is_partitioned.h>
710#include <__algorithm/is_permutation.h>
711#include <__algorithm/is_sorted.h>
712#include <__algorithm/is_sorted_until.h>
Christopher Di Bella6adbc832021-06-05 02:47:47713#include <__algorithm/iter_swap.h>
Louis Dionne134723e2021-06-17 15:30:11714#include <__algorithm/lexicographical_compare.h>
715#include <__algorithm/lower_bound.h>
716#include <__algorithm/make_heap.h>
717#include <__algorithm/max.h>
718#include <__algorithm/max_element.h>
719#include <__algorithm/merge.h>
720#include <__algorithm/min.h>
721#include <__algorithm/min_element.h>
722#include <__algorithm/minmax.h>
723#include <__algorithm/minmax_element.h>
724#include <__algorithm/mismatch.h>
725#include <__algorithm/move.h>
726#include <__algorithm/move_backward.h>
727#include <__algorithm/next_permutation.h>
728#include <__algorithm/none_of.h>
729#include <__algorithm/nth_element.h>
730#include <__algorithm/partial_sort.h>
731#include <__algorithm/partial_sort_copy.h>
732#include <__algorithm/partition.h>
733#include <__algorithm/partition_copy.h>
734#include <__algorithm/partition_point.h>
735#include <__algorithm/pop_heap.h>
736#include <__algorithm/prev_permutation.h>
737#include <__algorithm/push_heap.h>
738#include <__algorithm/remove.h>
739#include <__algorithm/remove_copy.h>
740#include <__algorithm/remove_copy_if.h>
741#include <__algorithm/remove_if.h>
742#include <__algorithm/replace.h>
743#include <__algorithm/replace_copy.h>
744#include <__algorithm/replace_copy_if.h>
745#include <__algorithm/replace_if.h>
746#include <__algorithm/reverse.h>
747#include <__algorithm/reverse_copy.h>
748#include <__algorithm/rotate.h>
749#include <__algorithm/rotate_copy.h>
750#include <__algorithm/sample.h>
751#include <__algorithm/search.h>
752#include <__algorithm/search_n.h>
753#include <__algorithm/set_difference.h>
754#include <__algorithm/set_intersection.h>
755#include <__algorithm/set_symmetric_difference.h>
756#include <__algorithm/set_union.h>
757#include <__algorithm/shift_left.h>
758#include <__algorithm/shift_right.h>
759#include <__algorithm/shuffle.h>
760#include <__algorithm/sift_down.h>
761#include <__algorithm/sort.h>
762#include <__algorithm/sort_heap.h>
763#include <__algorithm/stable_partition.h>
764#include <__algorithm/stable_sort.h>
Christopher Di Bella6adbc832021-06-05 02:47:47765#include <__algorithm/swap_ranges.h>
Louis Dionne134723e2021-06-17 15:30:11766#include <__algorithm/transform.h>
Louis Dionne134723e2021-06-17 15:30:11767#include <__algorithm/unique.h>
Arthur O'Dwyer4d81a462022-01-07 14:45:05768#include <__algorithm/unique_copy.h>
Louis Dionne134723e2021-06-17 15:30:11769#include <__algorithm/unwrap_iter.h>
770#include <__algorithm/upper_bound.h>
Eric Fiselierc1bd9192014-08-10 23:53:08771
Howard Hinnant073458b2011-10-17 20:05:10772#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Howard Hinnant3e519522010-05-11 19:42:16773#pragma GCC system_header
Howard Hinnant073458b2011-10-17 20:05:10774#endif
Howard Hinnant3e519522010-05-11 19:42:16775
Louis Dionne0a06eb92019-08-05 18:29:14776#if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17
Louis Dionne95689242019-08-06 21:11:24777# include <__pstl_algorithm>
Louis Dionne0a06eb92019-08-05 18:29:14778#endif
779
Louis Dionne4cd6ca12021-04-20 16:03:32780#endif // _LIBCPP_ALGORITHM