blob: 87e4ec9bad8ff8b55720ca1bf3473836512e8d99 [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 Klauser610979b2022-02-03 01:17:0327
28 template <class I, class O1, class O2>
29 struct in_out_out_result; // since C++20
Nikolas Klauserd3729bb2022-01-14 01:55:5130}
31
Howard Hinnant3e519522010-05-11 19:42:1632template <class InputIterator, class Predicate>
Marshall Clow706ffef2018-01-15 17:20:3633 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1634 all_of(InputIterator first, InputIterator last, Predicate pred);
35
36template <class InputIterator, class Predicate>
Marshall Clow706ffef2018-01-15 17:20:3637 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1638 any_of(InputIterator first, InputIterator last, Predicate pred);
39
40template <class InputIterator, class Predicate>
Marshall Clow706ffef2018-01-15 17:20:3641 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1642 none_of(InputIterator first, InputIterator last, Predicate pred);
43
44template <class InputIterator, class Function>
Marshall Clow1b9a4ff2018-01-22 20:44:3345 constexpr Function // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1646 for_each(InputIterator first, InputIterator last, Function f);
47
Marshall Clowd5c65ff2017-05-25 02:29:5448template<class InputIterator, class Size, class Function>
Marshall Clow1b9a4ff2018-01-22 20:44:3349 constexpr InputIterator // constexpr in C++20
50 for_each_n(InputIterator first, Size n, Function f); // C++17
Marshall Clowd5c65ff2017-05-25 02:29:5451
Howard Hinnant3e519522010-05-11 19:42:1652template <class InputIterator, class T>
Marshall Clow86944282018-01-15 19:26:0553 constexpr InputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1654 find(InputIterator first, InputIterator last, const T& value);
55
56template <class InputIterator, class Predicate>
Marshall Clow86944282018-01-15 19:26:0557 constexpr InputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1658 find_if(InputIterator first, InputIterator last, Predicate pred);
59
60template<class InputIterator, class Predicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:1861 constexpr InputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1662 find_if_not(InputIterator first, InputIterator last, Predicate pred);
63
64template <class ForwardIterator1, class ForwardIterator2>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:1865 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1666 find_end(ForwardIterator1 first1, ForwardIterator1 last1,
67 ForwardIterator2 first2, ForwardIterator2 last2);
68
69template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:1870 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1671 find_end(ForwardIterator1 first1, ForwardIterator1 last1,
72 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
73
74template <class ForwardIterator1, class ForwardIterator2>
Marshall Clow86944282018-01-15 19:26:0575 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1676 find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
77 ForwardIterator2 first2, ForwardIterator2 last2);
78
79template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow86944282018-01-15 19:26:0580 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1681 find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
82 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
83
84template <class ForwardIterator>
Marshall Clow86944282018-01-15 19:26:0585 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1686 adjacent_find(ForwardIterator first, ForwardIterator last);
87
88template <class ForwardIterator, class BinaryPredicate>
Marshall Clow86944282018-01-15 19:26:0589 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1690 adjacent_find(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
91
92template <class InputIterator, class T>
Marshall Clow056f15e2018-01-15 19:40:3493 constexpr typename iterator_traits<InputIterator>::difference_type // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1694 count(InputIterator first, InputIterator last, const T& value);
95
96template <class InputIterator, class Predicate>
Marshall Clow056f15e2018-01-15 19:40:3497 constexpr typename iterator_traits<InputIterator>::difference_type // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1698 count_if(InputIterator first, InputIterator last, Predicate pred);
99
100template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:10101 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16102 mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
103
Marshall Clow0b0bbd22013-05-09 21:14:23104template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:10105 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Aditya Kumar331fb802016-08-25 11:52:38106 mismatch(InputIterator1 first1, InputIterator1 last1,
Marshall Clow0b0bbd22013-05-09 21:14:23107 InputIterator2 first2, InputIterator2 last2); // **C++14**
108
Howard Hinnant3e519522010-05-11 19:42:16109template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:10110 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16111 mismatch(InputIterator1 first1, InputIterator1 last1,
112 InputIterator2 first2, BinaryPredicate pred);
113
Marshall Clow0b0bbd22013-05-09 21:14:23114template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:10115 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23116 mismatch(InputIterator1 first1, InputIterator1 last1,
117 InputIterator2 first2, InputIterator2 last2,
118 BinaryPredicate pred); // **C++14**
119
Howard Hinnant3e519522010-05-11 19:42:16120template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:10121 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16122 equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
123
Marshall Clow0b0bbd22013-05-09 21:14:23124template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:10125 constexpr bool // constexpr in C++20
Aditya Kumar331fb802016-08-25 11:52:38126 equal(InputIterator1 first1, InputIterator1 last1,
Marshall Clow0b0bbd22013-05-09 21:14:23127 InputIterator2 first2, InputIterator2 last2); // **C++14**
128
Howard Hinnant3e519522010-05-11 19:42:16129template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:10130 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16131 equal(InputIterator1 first1, InputIterator1 last1,
132 InputIterator2 first2, BinaryPredicate pred);
133
Marshall Clow0b0bbd22013-05-09 21:14:23134template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:10135 constexpr bool // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23136 equal(InputIterator1 first1, InputIterator1 last1,
137 InputIterator2 first2, InputIterator2 last2,
138 BinaryPredicate pred); // **C++14**
139
Howard Hinnant3e519522010-05-11 19:42:16140template<class ForwardIterator1, class ForwardIterator2>
Marshall Clow49c76432018-01-15 16:16:32141 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16142 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
143 ForwardIterator2 first2);
144
Marshall Clow0b0bbd22013-05-09 21:14:23145template<class ForwardIterator1, class ForwardIterator2>
Marshall Clow49c76432018-01-15 16:16:32146 constexpr bool // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23147 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
148 ForwardIterator2 first2, ForwardIterator2 last2); // **C++14**
149
Howard Hinnant3e519522010-05-11 19:42:16150template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow49c76432018-01-15 16:16:32151 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16152 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
153 ForwardIterator2 first2, BinaryPredicate pred);
154
Marshall Clow0b0bbd22013-05-09 21:14:23155template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow49c76432018-01-15 16:16:32156 constexpr bool // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23157 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
158 ForwardIterator2 first2, ForwardIterator2 last2,
159 BinaryPredicate pred); // **C++14**
160
Howard Hinnant3e519522010-05-11 19:42:16161template <class ForwardIterator1, class ForwardIterator2>
Marshall Clow12f0a772018-01-16 15:48:27162 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16163 search(ForwardIterator1 first1, ForwardIterator1 last1,
164 ForwardIterator2 first2, ForwardIterator2 last2);
165
166template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow12f0a772018-01-16 15:48:27167 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16168 search(ForwardIterator1 first1, ForwardIterator1 last1,
169 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
170
171template <class ForwardIterator, class Size, class T>
Marshall Clow12f0a772018-01-16 15:48:27172 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16173 search_n(ForwardIterator first, ForwardIterator last, Size count, const T& value);
174
175template <class ForwardIterator, class Size, class T, class BinaryPredicate>
Marshall Clow12f0a772018-01-16 15:48:27176 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16177 search_n(ForwardIterator first, ForwardIterator last,
178 Size count, const T& value, BinaryPredicate pred);
179
180template <class InputIterator, class OutputIterator>
Louis Dionne13c90a52019-11-06 12:02:41181 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16182 copy(InputIterator first, InputIterator last, OutputIterator result);
183
184template<class InputIterator, class OutputIterator, class Predicate>
Louis Dionne13c90a52019-11-06 12:02:41185 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16186 copy_if(InputIterator first, InputIterator last,
187 OutputIterator result, Predicate pred);
188
189template<class InputIterator, class Size, class OutputIterator>
Louis Dionne13c90a52019-11-06 12:02:41190 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16191 copy_n(InputIterator first, Size n, OutputIterator result);
192
193template <class BidirectionalIterator1, class BidirectionalIterator2>
Louis Dionne13c90a52019-11-06 12:02:41194 constexpr BidirectionalIterator2 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16195 copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last,
196 BidirectionalIterator2 result);
197
198template <class ForwardIterator1, class ForwardIterator2>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18199 constexpr ForwardIterator2 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16200 swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2);
201
202template <class ForwardIterator1, class ForwardIterator2>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18203 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16204 iter_swap(ForwardIterator1 a, ForwardIterator2 b);
205
206template <class InputIterator, class OutputIterator, class UnaryOperation>
Marshall Clow99894b62018-01-19 17:45:39207 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16208 transform(InputIterator first, InputIterator last, OutputIterator result, UnaryOperation op);
209
210template <class InputIterator1, class InputIterator2, class OutputIterator, class BinaryOperation>
Marshall Clow99894b62018-01-19 17:45:39211 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16212 transform(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2,
213 OutputIterator result, BinaryOperation binary_op);
214
215template <class ForwardIterator, class T>
Marshall Clow12c74232018-01-19 18:07:29216 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16217 replace(ForwardIterator first, ForwardIterator last, const T& old_value, const T& new_value);
218
219template <class ForwardIterator, class Predicate, class T>
Marshall Clow12c74232018-01-19 18:07:29220 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16221 replace_if(ForwardIterator first, ForwardIterator last, Predicate pred, const T& new_value);
222
223template <class InputIterator, class OutputIterator, class T>
Marshall Clow12c74232018-01-19 18:07:29224 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16225 replace_copy(InputIterator first, InputIterator last, OutputIterator result,
226 const T& old_value, const T& new_value);
227
228template <class InputIterator, class OutputIterator, class Predicate, class T>
Marshall Clow12c74232018-01-19 18:07:29229 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16230 replace_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred, const T& new_value);
231
232template <class ForwardIterator, class T>
Marshall Clow4bfb9312018-01-20 20:14:32233 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16234 fill(ForwardIterator first, ForwardIterator last, const T& value);
235
236template <class OutputIterator, class Size, class T>
Marshall Clow4bfb9312018-01-20 20:14:32237 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16238 fill_n(OutputIterator first, Size n, const T& value);
239
240template <class ForwardIterator, class Generator>
Marshall Clow4bfb9312018-01-20 20:14:32241 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16242 generate(ForwardIterator first, ForwardIterator last, Generator gen);
243
244template <class OutputIterator, class Size, class Generator>
Marshall Clow4bfb9312018-01-20 20:14:32245 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16246 generate_n(OutputIterator first, Size n, Generator gen);
247
248template <class ForwardIterator, class T>
Marshall Clowe8ea8292018-01-22 21:43:04249 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16250 remove(ForwardIterator first, ForwardIterator last, const T& value);
251
252template <class ForwardIterator, class Predicate>
Marshall Clowe8ea8292018-01-22 21:43:04253 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16254 remove_if(ForwardIterator first, ForwardIterator last, Predicate pred);
255
256template <class InputIterator, class OutputIterator, class T>
Marshall Clowe8ea8292018-01-22 21:43:04257 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16258 remove_copy(InputIterator first, InputIterator last, OutputIterator result, const T& value);
259
260template <class InputIterator, class OutputIterator, class Predicate>
Marshall Clowe8ea8292018-01-22 21:43:04261 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16262 remove_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred);
263
264template <class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18265 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16266 unique(ForwardIterator first, ForwardIterator last);
267
268template <class ForwardIterator, class BinaryPredicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18269 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16270 unique(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
271
272template <class InputIterator, class OutputIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18273 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16274 unique_copy(InputIterator first, InputIterator last, OutputIterator result);
275
276template <class InputIterator, class OutputIterator, class BinaryPredicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18277 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16278 unique_copy(InputIterator first, InputIterator last, OutputIterator result, BinaryPredicate pred);
279
280template <class BidirectionalIterator>
Arthur O'Dwyerf851db32020-12-17 05:01:08281 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16282 reverse(BidirectionalIterator first, BidirectionalIterator last);
283
284template <class BidirectionalIterator, class OutputIterator>
Marshall Clowe8ea8292018-01-22 21:43:04285 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16286 reverse_copy(BidirectionalIterator first, BidirectionalIterator last, OutputIterator result);
287
288template <class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18289 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16290 rotate(ForwardIterator first, ForwardIterator middle, ForwardIterator last);
291
292template <class ForwardIterator, class OutputIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18293 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16294 rotate_copy(ForwardIterator first, ForwardIterator middle, ForwardIterator last, OutputIterator result);
295
296template <class RandomAccessIterator>
297 void
Marshall Clow0f37a412017-03-23 13:43:37298 random_shuffle(RandomAccessIterator first, RandomAccessIterator last); // deprecated in C++14, removed in C++17
Howard Hinnant3e519522010-05-11 19:42:16299
300template <class RandomAccessIterator, class RandomNumberGenerator>
301 void
Marshall Clow06965c12014-03-03 06:14:19302 random_shuffle(RandomAccessIterator first, RandomAccessIterator last,
Marshall Clow0f37a412017-03-23 13:43:37303 RandomNumberGenerator& rand); // deprecated in C++14, removed in C++17
Howard Hinnant3e519522010-05-11 19:42:16304
Eric Fiseliere7154702016-08-28 22:14:37305template<class PopulationIterator, class SampleIterator,
306 class Distance, class UniformRandomBitGenerator>
307 SampleIterator sample(PopulationIterator first, PopulationIterator last,
308 SampleIterator out, Distance n,
309 UniformRandomBitGenerator&& g); // C++17
310
Howard Hinnantf9d540b2010-05-26 17:49:34311template<class RandomAccessIterator, class UniformRandomNumberGenerator>
312 void shuffle(RandomAccessIterator first, RandomAccessIterator last,
Howard Hinnantfb340102010-11-18 01:47:02313 UniformRandomNumberGenerator&& g);
Howard Hinnantf9d540b2010-05-26 17:49:34314
Arthur O'Dwyer3fbd3ea2020-12-26 06:39:03315template<class ForwardIterator>
316 constexpr ForwardIterator
317 shift_left(ForwardIterator first, ForwardIterator last,
318 typename iterator_traits<ForwardIterator>::difference_type n); // C++20
319
320template<class ForwardIterator>
321 constexpr ForwardIterator
322 shift_right(ForwardIterator first, ForwardIterator last,
323 typename iterator_traits<ForwardIterator>::difference_type n); // C++20
324
Howard Hinnant3e519522010-05-11 19:42:16325template <class InputIterator, class Predicate>
Marshall Clow49c76432018-01-15 16:16:32326 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16327 is_partitioned(InputIterator first, InputIterator last, Predicate pred);
328
329template <class ForwardIterator, class Predicate>
Arthur O'Dwyerf851db32020-12-17 05:01:08330 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16331 partition(ForwardIterator first, ForwardIterator last, Predicate pred);
332
333template <class InputIterator, class OutputIterator1,
334 class OutputIterator2, class Predicate>
Marshall Clow1b9a4ff2018-01-22 20:44:33335 constexpr pair<OutputIterator1, OutputIterator2> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16336 partition_copy(InputIterator first, InputIterator last,
337 OutputIterator1 out_true, OutputIterator2 out_false,
338 Predicate pred);
339
340template <class ForwardIterator, class Predicate>
341 ForwardIterator
342 stable_partition(ForwardIterator first, ForwardIterator last, Predicate pred);
343
344template<class ForwardIterator, class Predicate>
Marshall Clowd57c03d2018-01-16 02:34:41345 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16346 partition_point(ForwardIterator first, ForwardIterator last, Predicate pred);
347
348template <class ForwardIterator>
Marshall Clow49c76432018-01-15 16:16:32349 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16350 is_sorted(ForwardIterator first, ForwardIterator last);
351
352template <class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18353 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16354 is_sorted(ForwardIterator first, ForwardIterator last, Compare comp);
355
356template<class ForwardIterator>
Marshall Clow056f15e2018-01-15 19:40:34357 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16358 is_sorted_until(ForwardIterator first, ForwardIterator last);
359
360template <class ForwardIterator, class Compare>
Marshall Clow056f15e2018-01-15 19:40:34361 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16362 is_sorted_until(ForwardIterator first, ForwardIterator last, Compare comp);
363
364template <class RandomAccessIterator>
Arthur O'Dwyer493f1402020-12-20 20:21:42365 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16366 sort(RandomAccessIterator first, RandomAccessIterator last);
367
368template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer493f1402020-12-20 20:21:42369 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16370 sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
371
372template <class RandomAccessIterator>
373 void
374 stable_sort(RandomAccessIterator first, RandomAccessIterator last);
375
376template <class RandomAccessIterator, class Compare>
377 void
378 stable_sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
379
380template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18381 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16382 partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last);
383
384template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18385 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16386 partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last, Compare comp);
387
388template <class InputIterator, class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18389 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16390 partial_sort_copy(InputIterator first, InputIterator last,
391 RandomAccessIterator result_first, RandomAccessIterator result_last);
392
393template <class InputIterator, class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18394 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16395 partial_sort_copy(InputIterator first, InputIterator last,
396 RandomAccessIterator result_first, RandomAccessIterator result_last, Compare comp);
397
398template <class RandomAccessIterator>
Arthur O'Dwyer5d956562021-02-04 23:12:52399 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16400 nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last);
401
402template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5d956562021-02-04 23:12:52403 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16404 nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last, Compare comp);
405
406template <class ForwardIterator, class T>
Marshall Clowd57c03d2018-01-16 02:34:41407 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16408 lower_bound(ForwardIterator first, ForwardIterator last, const T& value);
409
410template <class ForwardIterator, class T, class Compare>
Marshall Clowd57c03d2018-01-16 02:34:41411 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16412 lower_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
413
414template <class ForwardIterator, class T>
Marshall Clowd57c03d2018-01-16 02:34:41415 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16416 upper_bound(ForwardIterator first, ForwardIterator last, const T& value);
417
418template <class ForwardIterator, class T, class Compare>
Marshall Clowd57c03d2018-01-16 02:34:41419 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16420 upper_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
421
422template <class ForwardIterator, class T>
Marshall Clowd57c03d2018-01-16 02:34:41423 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16424 equal_range(ForwardIterator first, ForwardIterator last, const T& value);
425
426template <class ForwardIterator, class T, class Compare>
Marshall Clowd57c03d2018-01-16 02:34:41427 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16428 equal_range(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
429
430template <class ForwardIterator, class T>
Marshall Clowd57c03d2018-01-16 02:34:41431 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16432 binary_search(ForwardIterator first, ForwardIterator last, const T& value);
433
434template <class ForwardIterator, class T, class Compare>
Marshall Clow8da1a482018-01-22 23:10:40435 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16436 binary_search(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
437
438template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer14098cf2020-12-04 18:47:12439 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16440 merge(InputIterator1 first1, InputIterator1 last1,
441 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
442
443template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer14098cf2020-12-04 18:47:12444 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16445 merge(InputIterator1 first1, InputIterator1 last1,
446 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
447
448template <class BidirectionalIterator>
449 void
450 inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last);
451
452template <class BidirectionalIterator, class Compare>
453 void
454 inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last, Compare comp);
455
456template <class InputIterator1, class InputIterator2>
Marshall Clow8da1a482018-01-22 23:10:40457 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16458 includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
459
460template <class InputIterator1, class InputIterator2, class Compare>
Marshall Clow8da1a482018-01-22 23:10:40461 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16462 includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, Compare comp);
463
464template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer14098cf2020-12-04 18:47:12465 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16466 set_union(InputIterator1 first1, InputIterator1 last1,
467 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
468
469template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer14098cf2020-12-04 18:47:12470 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16471 set_union(InputIterator1 first1, InputIterator1 last1,
472 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
473
474template <class InputIterator1, class InputIterator2, class OutputIterator>
Marshall Clow8da1a482018-01-22 23:10:40475 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16476 set_intersection(InputIterator1 first1, InputIterator1 last1,
477 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
478
479template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Marshall Clow8da1a482018-01-22 23:10:40480 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16481 set_intersection(InputIterator1 first1, InputIterator1 last1,
482 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
483
484template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer14098cf2020-12-04 18:47:12485 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16486 set_difference(InputIterator1 first1, InputIterator1 last1,
487 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
488
489template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer14098cf2020-12-04 18:47:12490 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16491 set_difference(InputIterator1 first1, InputIterator1 last1,
492 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
493
494template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer14098cf2020-12-04 18:47:12495 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16496 set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
497 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
498
499template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer14098cf2020-12-04 18:47:12500 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16501 set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
502 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
503
504template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18505 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16506 push_heap(RandomAccessIterator first, RandomAccessIterator last);
507
508template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18509 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16510 push_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
511
512template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18513 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16514 pop_heap(RandomAccessIterator first, RandomAccessIterator last);
515
516template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18517 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16518 pop_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
519
520template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18521 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16522 make_heap(RandomAccessIterator first, RandomAccessIterator last);
523
524template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18525 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16526 make_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
527
528template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18529 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16530 sort_heap(RandomAccessIterator first, RandomAccessIterator last);
531
532template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18533 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16534 sort_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
535
Howard Hinnantb3371f62010-08-22 00:02:43536template <class RandomAccessIterator>
Marshall Clow49c76432018-01-15 16:16:32537 constexpr bool // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43538 is_heap(RandomAccessIterator first, RandomAccessiterator last);
Howard Hinnant3e519522010-05-11 19:42:16539
Howard Hinnantb3371f62010-08-22 00:02:43540template <class RandomAccessIterator, class Compare>
Marshall Clow49c76432018-01-15 16:16:32541 constexpr bool // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43542 is_heap(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16543
Howard Hinnantb3371f62010-08-22 00:02:43544template <class RandomAccessIterator>
Marshall Clow49c76432018-01-15 16:16:32545 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43546 is_heap_until(RandomAccessIterator first, RandomAccessiterator last);
Howard Hinnant3e519522010-05-11 19:42:16547
Howard Hinnantb3371f62010-08-22 00:02:43548template <class RandomAccessIterator, class Compare>
Marshall Clow49c76432018-01-15 16:16:32549 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43550 is_heap_until(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16551
Howard Hinnant4eb27b72010-08-21 20:10:01552template <class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18553 constexpr ForwardIterator // constexpr in C++14
554 min_element(ForwardIterator first, ForwardIterator last);
Howard Hinnant4eb27b72010-08-21 20:10:01555
556template <class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18557 constexpr ForwardIterator // constexpr in C++14
558 min_element(ForwardIterator first, ForwardIterator last, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01559
Howard Hinnant3e519522010-05-11 19:42:16560template <class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18561 constexpr const T& // constexpr in C++14
562 min(const T& a, const T& b);
Howard Hinnant3e519522010-05-11 19:42:16563
564template <class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18565 constexpr const T& // constexpr in C++14
566 min(const T& a, const T& b, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16567
Howard Hinnant4eb27b72010-08-21 20:10:01568template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18569 constexpr T // constexpr in C++14
570 min(initializer_list<T> t);
Howard Hinnant4eb27b72010-08-21 20:10:01571
572template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18573 constexpr T // constexpr in C++14
574 min(initializer_list<T> t, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01575
Marshall Clow146c14a2016-03-07 22:43:49576template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18577 constexpr const T& clamp(const T& v, const T& lo, const T& hi); // C++17
Marshall Clow146c14a2016-03-07 22:43:49578
579template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18580 constexpr const T& clamp(const T& v, const T& lo, const T& hi, Compare comp); // C++17
Marshall Clow146c14a2016-03-07 22:43:49581
Howard Hinnant4eb27b72010-08-21 20:10:01582template <class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18583 constexpr ForwardIterator // constexpr in C++14
584 max_element(ForwardIterator first, ForwardIterator last);
Howard Hinnant4eb27b72010-08-21 20:10:01585
586template <class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18587 constexpr ForwardIterator // constexpr in C++14
588 max_element(ForwardIterator first, ForwardIterator last, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01589
Howard Hinnant3e519522010-05-11 19:42:16590template <class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18591 constexpr const T& // constexpr in C++14
592 max(const T& a, const T& b);
Howard Hinnant3e519522010-05-11 19:42:16593
594template <class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18595 constexpr const T& // constexpr in C++14
596 max(const T& a, const T& b, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16597
Howard Hinnant4eb27b72010-08-21 20:10:01598template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18599 constexpr T // constexpr in C++14
600 max(initializer_list<T> t);
Howard Hinnant3e519522010-05-11 19:42:16601
Howard Hinnant4eb27b72010-08-21 20:10:01602template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18603 constexpr T // constexpr in C++14
604 max(initializer_list<T> t, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16605
Howard Hinnant4eb27b72010-08-21 20:10:01606template<class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18607 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++14
608 minmax_element(ForwardIterator first, ForwardIterator last);
Howard Hinnant3e519522010-05-11 19:42:16609
Howard Hinnant4eb27b72010-08-21 20:10:01610template<class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18611 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++14
612 minmax_element(ForwardIterator first, ForwardIterator last, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01613
614template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18615 constexpr pair<const T&, const T&> // constexpr in C++14
616 minmax(const T& a, const T& b);
Howard Hinnant4eb27b72010-08-21 20:10:01617
618template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18619 constexpr pair<const T&, const T&> // constexpr in C++14
620 minmax(const T& a, const T& b, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01621
622template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18623 constexpr pair<T, T> // constexpr in C++14
624 minmax(initializer_list<T> t);
Howard Hinnant4eb27b72010-08-21 20:10:01625
626template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18627 constexpr pair<T, T> // constexpr in C++14
628 minmax(initializer_list<T> t, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16629
630template <class InputIterator1, class InputIterator2>
Marshall Clow1b9a4ff2018-01-22 20:44:33631 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16632 lexicographical_compare(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
633
634template <class InputIterator1, class InputIterator2, class Compare>
Marshall Clow1b9a4ff2018-01-22 20:44:33635 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16636 lexicographical_compare(InputIterator1 first1, InputIterator1 last1,
637 InputIterator2 first2, InputIterator2 last2, Compare comp);
638
639template <class BidirectionalIterator>
Arthur O'Dwyerf851db32020-12-17 05:01:08640 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16641 next_permutation(BidirectionalIterator first, BidirectionalIterator last);
642
643template <class BidirectionalIterator, class Compare>
Arthur O'Dwyerf851db32020-12-17 05:01:08644 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16645 next_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
646
647template <class BidirectionalIterator>
Arthur O'Dwyerf851db32020-12-17 05:01:08648 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16649 prev_permutation(BidirectionalIterator first, BidirectionalIterator last);
650
651template <class BidirectionalIterator, class Compare>
Arthur O'Dwyerf851db32020-12-17 05:01:08652 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16653 prev_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
654
Konstantin Varlamov8d23b742022-01-11 06:49:37655namespace ranges {
656// [algorithms.results], algorithm result types
657template<class InputIterator, class OutputIterator>
658 struct in_out_result;
659}
660
Howard Hinnant3e519522010-05-11 19:42:16661} // std
662
663*/
664
Nikolas Klausercf54cb22022-01-03 00:24:09665#include <__bits> // __libcpp_clz
Howard Hinnant3e519522010-05-11 19:42:16666#include <__config>
Louis Dionne134723e2021-06-17 15:30:11667#include <__debug>
Howard Hinnanta1d07d52012-07-26 17:09:09668#include <cstddef>
Arthur O'Dwyerbfbd73f2021-05-19 15:57:04669#include <cstring>
670#include <functional>
671#include <initializer_list>
Arthur O'Dwyerbfbd73f2021-05-19 15:57:04672#include <iterator>
673#include <memory>
674#include <type_traits>
675#include <utility> // swap_ranges
Marshall Clowf56972e2018-09-12 19:41:40676#include <version>
Howard Hinnant5d1a7012013-08-14 18:00:20677
Louis Dionne134723e2021-06-17 15:30:11678#include <__algorithm/adjacent_find.h>
679#include <__algorithm/all_of.h>
680#include <__algorithm/any_of.h>
681#include <__algorithm/binary_search.h>
682#include <__algorithm/clamp.h>
683#include <__algorithm/comp.h>
684#include <__algorithm/comp_ref_type.h>
685#include <__algorithm/copy.h>
686#include <__algorithm/copy_backward.h>
687#include <__algorithm/copy_if.h>
688#include <__algorithm/copy_n.h>
689#include <__algorithm/count.h>
690#include <__algorithm/count_if.h>
691#include <__algorithm/equal.h>
692#include <__algorithm/equal_range.h>
Louis Dionne134723e2021-06-17 15:30:11693#include <__algorithm/fill.h>
Arthur O'Dwyer4d81a462022-01-07 14:45:05694#include <__algorithm/fill_n.h>
Louis Dionne134723e2021-06-17 15:30:11695#include <__algorithm/find.h>
696#include <__algorithm/find_end.h>
697#include <__algorithm/find_first_of.h>
698#include <__algorithm/find_if.h>
699#include <__algorithm/find_if_not.h>
700#include <__algorithm/for_each.h>
701#include <__algorithm/for_each_n.h>
Louis Dionne134723e2021-06-17 15:30:11702#include <__algorithm/generate.h>
Arthur O'Dwyer4d81a462022-01-07 14:45:05703#include <__algorithm/generate_n.h>
Louis Dionne134723e2021-06-17 15:30:11704#include <__algorithm/half_positive.h>
Nikolas Klauserf3514af2022-01-25 10:21:47705#include <__algorithm/in_in_out_result.h>
Nikolas Klauserd3729bb2022-01-14 01:55:51706#include <__algorithm/in_in_result.h>
Nikolas Klauser610979b2022-02-03 01:17:03707#include <__algorithm/in_out_out_result.h>
Konstantin Varlamov8d23b742022-01-11 06:49:37708#include <__algorithm/in_out_result.h>
Louis Dionne134723e2021-06-17 15:30:11709#include <__algorithm/includes.h>
710#include <__algorithm/inplace_merge.h>
711#include <__algorithm/is_heap.h>
712#include <__algorithm/is_heap_until.h>
713#include <__algorithm/is_partitioned.h>
714#include <__algorithm/is_permutation.h>
715#include <__algorithm/is_sorted.h>
716#include <__algorithm/is_sorted_until.h>
Christopher Di Bella6adbc832021-06-05 02:47:47717#include <__algorithm/iter_swap.h>
Louis Dionne134723e2021-06-17 15:30:11718#include <__algorithm/lexicographical_compare.h>
719#include <__algorithm/lower_bound.h>
720#include <__algorithm/make_heap.h>
721#include <__algorithm/max.h>
722#include <__algorithm/max_element.h>
723#include <__algorithm/merge.h>
724#include <__algorithm/min.h>
725#include <__algorithm/min_element.h>
726#include <__algorithm/minmax.h>
727#include <__algorithm/minmax_element.h>
728#include <__algorithm/mismatch.h>
729#include <__algorithm/move.h>
730#include <__algorithm/move_backward.h>
731#include <__algorithm/next_permutation.h>
732#include <__algorithm/none_of.h>
733#include <__algorithm/nth_element.h>
734#include <__algorithm/partial_sort.h>
735#include <__algorithm/partial_sort_copy.h>
736#include <__algorithm/partition.h>
737#include <__algorithm/partition_copy.h>
738#include <__algorithm/partition_point.h>
739#include <__algorithm/pop_heap.h>
740#include <__algorithm/prev_permutation.h>
741#include <__algorithm/push_heap.h>
742#include <__algorithm/remove.h>
743#include <__algorithm/remove_copy.h>
744#include <__algorithm/remove_copy_if.h>
745#include <__algorithm/remove_if.h>
746#include <__algorithm/replace.h>
747#include <__algorithm/replace_copy.h>
748#include <__algorithm/replace_copy_if.h>
749#include <__algorithm/replace_if.h>
750#include <__algorithm/reverse.h>
751#include <__algorithm/reverse_copy.h>
752#include <__algorithm/rotate.h>
753#include <__algorithm/rotate_copy.h>
754#include <__algorithm/sample.h>
755#include <__algorithm/search.h>
756#include <__algorithm/search_n.h>
757#include <__algorithm/set_difference.h>
758#include <__algorithm/set_intersection.h>
759#include <__algorithm/set_symmetric_difference.h>
760#include <__algorithm/set_union.h>
761#include <__algorithm/shift_left.h>
762#include <__algorithm/shift_right.h>
763#include <__algorithm/shuffle.h>
764#include <__algorithm/sift_down.h>
765#include <__algorithm/sort.h>
766#include <__algorithm/sort_heap.h>
767#include <__algorithm/stable_partition.h>
768#include <__algorithm/stable_sort.h>
Christopher Di Bella6adbc832021-06-05 02:47:47769#include <__algorithm/swap_ranges.h>
Louis Dionne134723e2021-06-17 15:30:11770#include <__algorithm/transform.h>
Louis Dionne134723e2021-06-17 15:30:11771#include <__algorithm/unique.h>
Arthur O'Dwyer4d81a462022-01-07 14:45:05772#include <__algorithm/unique_copy.h>
Louis Dionne134723e2021-06-17 15:30:11773#include <__algorithm/unwrap_iter.h>
774#include <__algorithm/upper_bound.h>
Eric Fiselierc1bd9192014-08-10 23:53:08775
Howard Hinnant073458b2011-10-17 20:05:10776#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Howard Hinnant3e519522010-05-11 19:42:16777#pragma GCC system_header
Howard Hinnant073458b2011-10-17 20:05:10778#endif
Howard Hinnant3e519522010-05-11 19:42:16779
Louis Dionne0a06eb92019-08-05 18:29:14780#if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17
Louis Dionne95689242019-08-06 21:11:24781# include <__pstl_algorithm>
Louis Dionne0a06eb92019-08-05 18:29:14782#endif
783
Louis Dionne4cd6ca12021-04-20 16:03:32784#endif // _LIBCPP_ALGORITHM