blob: b28c8cd4989015dc2d48496ccd040bcd33bef047 [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
21template <class InputIterator, class Predicate>
Marshall Clow706ffef2018-01-15 17:20:3622 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1623 all_of(InputIterator first, InputIterator last, Predicate pred);
24
25template <class InputIterator, class Predicate>
Marshall Clow706ffef2018-01-15 17:20:3626 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1627 any_of(InputIterator first, InputIterator last, Predicate pred);
28
29template <class InputIterator, class Predicate>
Marshall Clow706ffef2018-01-15 17:20:3630 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1631 none_of(InputIterator first, InputIterator last, Predicate pred);
32
33template <class InputIterator, class Function>
Marshall Clow1b9a4ff2018-01-22 20:44:3334 constexpr Function // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1635 for_each(InputIterator first, InputIterator last, Function f);
36
Marshall Clowd5c65ff2017-05-25 02:29:5437template<class InputIterator, class Size, class Function>
Marshall Clow1b9a4ff2018-01-22 20:44:3338 constexpr InputIterator // constexpr in C++20
39 for_each_n(InputIterator first, Size n, Function f); // C++17
Marshall Clowd5c65ff2017-05-25 02:29:5440
Howard Hinnant3e519522010-05-11 19:42:1641template <class InputIterator, class T>
Marshall Clow86944282018-01-15 19:26:0542 constexpr InputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1643 find(InputIterator first, InputIterator last, const T& value);
44
45template <class InputIterator, class Predicate>
Marshall Clow86944282018-01-15 19:26:0546 constexpr InputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1647 find_if(InputIterator first, InputIterator last, Predicate pred);
48
49template<class InputIterator, class Predicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:1850 constexpr InputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1651 find_if_not(InputIterator first, InputIterator last, Predicate pred);
52
53template <class ForwardIterator1, class ForwardIterator2>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:1854 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1655 find_end(ForwardIterator1 first1, ForwardIterator1 last1,
56 ForwardIterator2 first2, ForwardIterator2 last2);
57
58template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:1859 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1660 find_end(ForwardIterator1 first1, ForwardIterator1 last1,
61 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
62
63template <class ForwardIterator1, class ForwardIterator2>
Marshall Clow86944282018-01-15 19:26:0564 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1665 find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
66 ForwardIterator2 first2, ForwardIterator2 last2);
67
68template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow86944282018-01-15 19:26:0569 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1670 find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
71 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
72
73template <class ForwardIterator>
Marshall Clow86944282018-01-15 19:26:0574 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1675 adjacent_find(ForwardIterator first, ForwardIterator last);
76
77template <class ForwardIterator, class BinaryPredicate>
Marshall Clow86944282018-01-15 19:26:0578 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1679 adjacent_find(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
80
81template <class InputIterator, class T>
Marshall Clow056f15e2018-01-15 19:40:3482 constexpr typename iterator_traits<InputIterator>::difference_type // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1683 count(InputIterator first, InputIterator last, const T& value);
84
85template <class InputIterator, class Predicate>
Marshall Clow056f15e2018-01-15 19:40:3486 constexpr typename iterator_traits<InputIterator>::difference_type // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1687 count_if(InputIterator first, InputIterator last, Predicate pred);
88
89template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:1090 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1691 mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
92
Marshall Clow0b0bbd22013-05-09 21:14:2393template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:1094 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Aditya Kumar331fb802016-08-25 11:52:3895 mismatch(InputIterator1 first1, InputIterator1 last1,
Marshall Clow0b0bbd22013-05-09 21:14:2396 InputIterator2 first2, InputIterator2 last2); // **C++14**
97
Howard Hinnant3e519522010-05-11 19:42:1698template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:1099 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16100 mismatch(InputIterator1 first1, InputIterator1 last1,
101 InputIterator2 first2, BinaryPredicate pred);
102
Marshall Clow0b0bbd22013-05-09 21:14:23103template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:10104 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23105 mismatch(InputIterator1 first1, InputIterator1 last1,
106 InputIterator2 first2, InputIterator2 last2,
107 BinaryPredicate pred); // **C++14**
108
Howard Hinnant3e519522010-05-11 19:42:16109template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:10110 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16111 equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
112
Marshall Clow0b0bbd22013-05-09 21:14:23113template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:10114 constexpr bool // constexpr in C++20
Aditya Kumar331fb802016-08-25 11:52:38115 equal(InputIterator1 first1, InputIterator1 last1,
Marshall Clow0b0bbd22013-05-09 21:14:23116 InputIterator2 first2, InputIterator2 last2); // **C++14**
117
Howard Hinnant3e519522010-05-11 19:42:16118template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:10119 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16120 equal(InputIterator1 first1, InputIterator1 last1,
121 InputIterator2 first2, BinaryPredicate pred);
122
Marshall Clow0b0bbd22013-05-09 21:14:23123template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:10124 constexpr bool // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23125 equal(InputIterator1 first1, InputIterator1 last1,
126 InputIterator2 first2, InputIterator2 last2,
127 BinaryPredicate pred); // **C++14**
128
Howard Hinnant3e519522010-05-11 19:42:16129template<class ForwardIterator1, class ForwardIterator2>
Marshall Clow49c76432018-01-15 16:16:32130 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16131 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
132 ForwardIterator2 first2);
133
Marshall Clow0b0bbd22013-05-09 21:14:23134template<class ForwardIterator1, class ForwardIterator2>
Marshall Clow49c76432018-01-15 16:16:32135 constexpr bool // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23136 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
137 ForwardIterator2 first2, ForwardIterator2 last2); // **C++14**
138
Howard Hinnant3e519522010-05-11 19:42:16139template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow49c76432018-01-15 16:16:32140 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16141 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
142 ForwardIterator2 first2, BinaryPredicate pred);
143
Marshall Clow0b0bbd22013-05-09 21:14:23144template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow49c76432018-01-15 16:16:32145 constexpr bool // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23146 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
147 ForwardIterator2 first2, ForwardIterator2 last2,
148 BinaryPredicate pred); // **C++14**
149
Howard Hinnant3e519522010-05-11 19:42:16150template <class ForwardIterator1, class ForwardIterator2>
Marshall Clow12f0a772018-01-16 15:48:27151 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16152 search(ForwardIterator1 first1, ForwardIterator1 last1,
153 ForwardIterator2 first2, ForwardIterator2 last2);
154
155template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow12f0a772018-01-16 15:48:27156 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16157 search(ForwardIterator1 first1, ForwardIterator1 last1,
158 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
159
160template <class ForwardIterator, class Size, class T>
Marshall Clow12f0a772018-01-16 15:48:27161 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16162 search_n(ForwardIterator first, ForwardIterator last, Size count, const T& value);
163
164template <class ForwardIterator, class Size, class T, class BinaryPredicate>
Marshall Clow12f0a772018-01-16 15:48:27165 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16166 search_n(ForwardIterator first, ForwardIterator last,
167 Size count, const T& value, BinaryPredicate pred);
168
169template <class InputIterator, class OutputIterator>
Louis Dionne13c90a52019-11-06 12:02:41170 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16171 copy(InputIterator first, InputIterator last, OutputIterator result);
172
173template<class InputIterator, class OutputIterator, class Predicate>
Louis Dionne13c90a52019-11-06 12:02:41174 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16175 copy_if(InputIterator first, InputIterator last,
176 OutputIterator result, Predicate pred);
177
178template<class InputIterator, class Size, class OutputIterator>
Louis Dionne13c90a52019-11-06 12:02:41179 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16180 copy_n(InputIterator first, Size n, OutputIterator result);
181
182template <class BidirectionalIterator1, class BidirectionalIterator2>
Louis Dionne13c90a52019-11-06 12:02:41183 constexpr BidirectionalIterator2 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16184 copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last,
185 BidirectionalIterator2 result);
186
187template <class ForwardIterator1, class ForwardIterator2>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18188 constexpr ForwardIterator2 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16189 swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2);
190
191template <class ForwardIterator1, class ForwardIterator2>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18192 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16193 iter_swap(ForwardIterator1 a, ForwardIterator2 b);
194
195template <class InputIterator, class OutputIterator, class UnaryOperation>
Marshall Clow99894b62018-01-19 17:45:39196 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16197 transform(InputIterator first, InputIterator last, OutputIterator result, UnaryOperation op);
198
199template <class InputIterator1, class InputIterator2, class OutputIterator, class BinaryOperation>
Marshall Clow99894b62018-01-19 17:45:39200 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16201 transform(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2,
202 OutputIterator result, BinaryOperation binary_op);
203
204template <class ForwardIterator, class T>
Marshall Clow12c74232018-01-19 18:07:29205 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16206 replace(ForwardIterator first, ForwardIterator last, const T& old_value, const T& new_value);
207
208template <class ForwardIterator, class Predicate, class T>
Marshall Clow12c74232018-01-19 18:07:29209 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16210 replace_if(ForwardIterator first, ForwardIterator last, Predicate pred, const T& new_value);
211
212template <class InputIterator, class OutputIterator, class T>
Marshall Clow12c74232018-01-19 18:07:29213 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16214 replace_copy(InputIterator first, InputIterator last, OutputIterator result,
215 const T& old_value, const T& new_value);
216
217template <class InputIterator, class OutputIterator, class Predicate, class T>
Marshall Clow12c74232018-01-19 18:07:29218 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16219 replace_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred, const T& new_value);
220
221template <class ForwardIterator, class T>
Marshall Clow4bfb9312018-01-20 20:14:32222 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16223 fill(ForwardIterator first, ForwardIterator last, const T& value);
224
225template <class OutputIterator, class Size, class T>
Marshall Clow4bfb9312018-01-20 20:14:32226 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16227 fill_n(OutputIterator first, Size n, const T& value);
228
229template <class ForwardIterator, class Generator>
Marshall Clow4bfb9312018-01-20 20:14:32230 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16231 generate(ForwardIterator first, ForwardIterator last, Generator gen);
232
233template <class OutputIterator, class Size, class Generator>
Marshall Clow4bfb9312018-01-20 20:14:32234 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16235 generate_n(OutputIterator first, Size n, Generator gen);
236
237template <class ForwardIterator, class T>
Marshall Clowe8ea8292018-01-22 21:43:04238 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16239 remove(ForwardIterator first, ForwardIterator last, const T& value);
240
241template <class ForwardIterator, class Predicate>
Marshall Clowe8ea8292018-01-22 21:43:04242 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16243 remove_if(ForwardIterator first, ForwardIterator last, Predicate pred);
244
245template <class InputIterator, class OutputIterator, class T>
Marshall Clowe8ea8292018-01-22 21:43:04246 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16247 remove_copy(InputIterator first, InputIterator last, OutputIterator result, const T& value);
248
249template <class InputIterator, class OutputIterator, class Predicate>
Marshall Clowe8ea8292018-01-22 21:43:04250 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16251 remove_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred);
252
253template <class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18254 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16255 unique(ForwardIterator first, ForwardIterator last);
256
257template <class ForwardIterator, class BinaryPredicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18258 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16259 unique(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
260
261template <class InputIterator, class OutputIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18262 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16263 unique_copy(InputIterator first, InputIterator last, OutputIterator result);
264
265template <class InputIterator, class OutputIterator, class BinaryPredicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18266 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16267 unique_copy(InputIterator first, InputIterator last, OutputIterator result, BinaryPredicate pred);
268
269template <class BidirectionalIterator>
Arthur O'Dwyerf851db32020-12-17 05:01:08270 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16271 reverse(BidirectionalIterator first, BidirectionalIterator last);
272
273template <class BidirectionalIterator, class OutputIterator>
Marshall Clowe8ea8292018-01-22 21:43:04274 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16275 reverse_copy(BidirectionalIterator first, BidirectionalIterator last, OutputIterator result);
276
277template <class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18278 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16279 rotate(ForwardIterator first, ForwardIterator middle, ForwardIterator last);
280
281template <class ForwardIterator, class OutputIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18282 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16283 rotate_copy(ForwardIterator first, ForwardIterator middle, ForwardIterator last, OutputIterator result);
284
285template <class RandomAccessIterator>
286 void
Marshall Clow0f37a412017-03-23 13:43:37287 random_shuffle(RandomAccessIterator first, RandomAccessIterator last); // deprecated in C++14, removed in C++17
Howard Hinnant3e519522010-05-11 19:42:16288
289template <class RandomAccessIterator, class RandomNumberGenerator>
290 void
Marshall Clow06965c12014-03-03 06:14:19291 random_shuffle(RandomAccessIterator first, RandomAccessIterator last,
Marshall Clow0f37a412017-03-23 13:43:37292 RandomNumberGenerator& rand); // deprecated in C++14, removed in C++17
Howard Hinnant3e519522010-05-11 19:42:16293
Eric Fiseliere7154702016-08-28 22:14:37294template<class PopulationIterator, class SampleIterator,
295 class Distance, class UniformRandomBitGenerator>
296 SampleIterator sample(PopulationIterator first, PopulationIterator last,
297 SampleIterator out, Distance n,
298 UniformRandomBitGenerator&& g); // C++17
299
Howard Hinnantf9d540b2010-05-26 17:49:34300template<class RandomAccessIterator, class UniformRandomNumberGenerator>
301 void shuffle(RandomAccessIterator first, RandomAccessIterator last,
Howard Hinnantfb340102010-11-18 01:47:02302 UniformRandomNumberGenerator&& g);
Howard Hinnantf9d540b2010-05-26 17:49:34303
Arthur O'Dwyer3fbd3ea2020-12-26 06:39:03304template<class ForwardIterator>
305 constexpr ForwardIterator
306 shift_left(ForwardIterator first, ForwardIterator last,
307 typename iterator_traits<ForwardIterator>::difference_type n); // C++20
308
309template<class ForwardIterator>
310 constexpr ForwardIterator
311 shift_right(ForwardIterator first, ForwardIterator last,
312 typename iterator_traits<ForwardIterator>::difference_type n); // C++20
313
Howard Hinnant3e519522010-05-11 19:42:16314template <class InputIterator, class Predicate>
Marshall Clow49c76432018-01-15 16:16:32315 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16316 is_partitioned(InputIterator first, InputIterator last, Predicate pred);
317
318template <class ForwardIterator, class Predicate>
Arthur O'Dwyerf851db32020-12-17 05:01:08319 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16320 partition(ForwardIterator first, ForwardIterator last, Predicate pred);
321
322template <class InputIterator, class OutputIterator1,
323 class OutputIterator2, class Predicate>
Marshall Clow1b9a4ff2018-01-22 20:44:33324 constexpr pair<OutputIterator1, OutputIterator2> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16325 partition_copy(InputIterator first, InputIterator last,
326 OutputIterator1 out_true, OutputIterator2 out_false,
327 Predicate pred);
328
329template <class ForwardIterator, class Predicate>
330 ForwardIterator
331 stable_partition(ForwardIterator first, ForwardIterator last, Predicate pred);
332
333template<class ForwardIterator, class Predicate>
Marshall Clowd57c03d2018-01-16 02:34:41334 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16335 partition_point(ForwardIterator first, ForwardIterator last, Predicate pred);
336
337template <class ForwardIterator>
Marshall Clow49c76432018-01-15 16:16:32338 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16339 is_sorted(ForwardIterator first, ForwardIterator last);
340
341template <class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18342 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16343 is_sorted(ForwardIterator first, ForwardIterator last, Compare comp);
344
345template<class ForwardIterator>
Marshall Clow056f15e2018-01-15 19:40:34346 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16347 is_sorted_until(ForwardIterator first, ForwardIterator last);
348
349template <class ForwardIterator, class Compare>
Marshall Clow056f15e2018-01-15 19:40:34350 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16351 is_sorted_until(ForwardIterator first, ForwardIterator last, Compare comp);
352
353template <class RandomAccessIterator>
Arthur O'Dwyer493f1402020-12-20 20:21:42354 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16355 sort(RandomAccessIterator first, RandomAccessIterator last);
356
357template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer493f1402020-12-20 20:21:42358 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16359 sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
360
361template <class RandomAccessIterator>
362 void
363 stable_sort(RandomAccessIterator first, RandomAccessIterator last);
364
365template <class RandomAccessIterator, class Compare>
366 void
367 stable_sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
368
369template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18370 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16371 partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last);
372
373template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18374 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16375 partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last, Compare comp);
376
377template <class InputIterator, class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18378 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16379 partial_sort_copy(InputIterator first, InputIterator last,
380 RandomAccessIterator result_first, RandomAccessIterator result_last);
381
382template <class InputIterator, class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18383 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16384 partial_sort_copy(InputIterator first, InputIterator last,
385 RandomAccessIterator result_first, RandomAccessIterator result_last, Compare comp);
386
387template <class RandomAccessIterator>
Arthur O'Dwyer5d956562021-02-04 23:12:52388 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16389 nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last);
390
391template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5d956562021-02-04 23:12:52392 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16393 nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last, Compare comp);
394
395template <class ForwardIterator, class T>
Marshall Clowd57c03d2018-01-16 02:34:41396 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16397 lower_bound(ForwardIterator first, ForwardIterator last, const T& value);
398
399template <class ForwardIterator, class T, class Compare>
Marshall Clowd57c03d2018-01-16 02:34:41400 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16401 lower_bound(ForwardIterator first, ForwardIterator last, const T& value, 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 upper_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 upper_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
410
411template <class ForwardIterator, class T>
Marshall Clowd57c03d2018-01-16 02:34:41412 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16413 equal_range(ForwardIterator first, ForwardIterator last, const T& value);
414
415template <class ForwardIterator, class T, class Compare>
Marshall Clowd57c03d2018-01-16 02:34:41416 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16417 equal_range(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
418
419template <class ForwardIterator, class T>
Marshall Clowd57c03d2018-01-16 02:34:41420 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16421 binary_search(ForwardIterator first, ForwardIterator last, const T& value);
422
423template <class ForwardIterator, class T, class Compare>
Marshall Clow8da1a482018-01-22 23:10:40424 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16425 binary_search(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
426
427template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer14098cf2020-12-04 18:47:12428 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16429 merge(InputIterator1 first1, InputIterator1 last1,
430 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
431
432template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer14098cf2020-12-04 18:47:12433 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16434 merge(InputIterator1 first1, InputIterator1 last1,
435 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
436
437template <class BidirectionalIterator>
438 void
439 inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last);
440
441template <class BidirectionalIterator, class Compare>
442 void
443 inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last, Compare comp);
444
445template <class InputIterator1, class InputIterator2>
Marshall Clow8da1a482018-01-22 23:10:40446 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16447 includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
448
449template <class InputIterator1, class InputIterator2, class Compare>
Marshall Clow8da1a482018-01-22 23:10:40450 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16451 includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, Compare comp);
452
453template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer14098cf2020-12-04 18:47:12454 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16455 set_union(InputIterator1 first1, InputIterator1 last1,
456 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
457
458template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer14098cf2020-12-04 18:47:12459 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16460 set_union(InputIterator1 first1, InputIterator1 last1,
461 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
462
463template <class InputIterator1, class InputIterator2, class OutputIterator>
Marshall Clow8da1a482018-01-22 23:10:40464 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16465 set_intersection(InputIterator1 first1, InputIterator1 last1,
466 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
467
468template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Marshall Clow8da1a482018-01-22 23:10:40469 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16470 set_intersection(InputIterator1 first1, InputIterator1 last1,
471 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
472
473template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer14098cf2020-12-04 18:47:12474 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16475 set_difference(InputIterator1 first1, InputIterator1 last1,
476 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
477
478template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer14098cf2020-12-04 18:47:12479 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16480 set_difference(InputIterator1 first1, InputIterator1 last1,
481 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
482
483template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer14098cf2020-12-04 18:47:12484 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16485 set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
486 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
487
488template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer14098cf2020-12-04 18:47:12489 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16490 set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
491 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
492
493template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18494 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16495 push_heap(RandomAccessIterator first, RandomAccessIterator last);
496
497template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18498 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16499 push_heap(RandomAccessIterator first, RandomAccessIterator last, 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 pop_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 pop_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 make_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 make_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 sort_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 sort_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
524
Howard Hinnantb3371f62010-08-22 00:02:43525template <class RandomAccessIterator>
Marshall Clow49c76432018-01-15 16:16:32526 constexpr bool // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43527 is_heap(RandomAccessIterator first, RandomAccessiterator last);
Howard Hinnant3e519522010-05-11 19:42:16528
Howard Hinnantb3371f62010-08-22 00:02:43529template <class RandomAccessIterator, class Compare>
Marshall Clow49c76432018-01-15 16:16:32530 constexpr bool // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43531 is_heap(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16532
Howard Hinnantb3371f62010-08-22 00:02:43533template <class RandomAccessIterator>
Marshall Clow49c76432018-01-15 16:16:32534 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43535 is_heap_until(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 RandomAccessIterator // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43539 is_heap_until(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16540
Howard Hinnant4eb27b72010-08-21 20:10:01541template <class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18542 constexpr ForwardIterator // constexpr in C++14
543 min_element(ForwardIterator first, ForwardIterator last);
Howard Hinnant4eb27b72010-08-21 20:10:01544
545template <class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18546 constexpr ForwardIterator // constexpr in C++14
547 min_element(ForwardIterator first, ForwardIterator last, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01548
Howard Hinnant3e519522010-05-11 19:42:16549template <class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18550 constexpr const T& // constexpr in C++14
551 min(const T& a, const T& b);
Howard Hinnant3e519522010-05-11 19:42:16552
553template <class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18554 constexpr const T& // constexpr in C++14
555 min(const T& a, const T& b, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16556
Howard Hinnant4eb27b72010-08-21 20:10:01557template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18558 constexpr T // constexpr in C++14
559 min(initializer_list<T> t);
Howard Hinnant4eb27b72010-08-21 20:10:01560
561template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18562 constexpr T // constexpr in C++14
563 min(initializer_list<T> t, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01564
Marshall Clow146c14a2016-03-07 22:43:49565template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18566 constexpr const T& clamp(const T& v, const T& lo, const T& hi); // C++17
Marshall Clow146c14a2016-03-07 22:43:49567
568template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18569 constexpr const T& clamp(const T& v, const T& lo, const T& hi, Compare comp); // C++17
Marshall Clow146c14a2016-03-07 22:43:49570
Howard Hinnant4eb27b72010-08-21 20:10:01571template <class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18572 constexpr ForwardIterator // constexpr in C++14
573 max_element(ForwardIterator first, ForwardIterator last);
Howard Hinnant4eb27b72010-08-21 20:10:01574
575template <class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18576 constexpr ForwardIterator // constexpr in C++14
577 max_element(ForwardIterator first, ForwardIterator last, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01578
Howard Hinnant3e519522010-05-11 19:42:16579template <class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18580 constexpr const T& // constexpr in C++14
581 max(const T& a, const T& b);
Howard Hinnant3e519522010-05-11 19:42:16582
583template <class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18584 constexpr const T& // constexpr in C++14
585 max(const T& a, const T& b, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16586
Howard Hinnant4eb27b72010-08-21 20:10:01587template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18588 constexpr T // constexpr in C++14
589 max(initializer_list<T> t);
Howard Hinnant3e519522010-05-11 19:42:16590
Howard Hinnant4eb27b72010-08-21 20:10:01591template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18592 constexpr T // constexpr in C++14
593 max(initializer_list<T> t, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16594
Howard Hinnant4eb27b72010-08-21 20:10:01595template<class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18596 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++14
597 minmax_element(ForwardIterator first, ForwardIterator last);
Howard Hinnant3e519522010-05-11 19:42:16598
Howard Hinnant4eb27b72010-08-21 20:10:01599template<class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18600 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++14
601 minmax_element(ForwardIterator first, ForwardIterator last, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01602
603template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18604 constexpr pair<const T&, const T&> // constexpr in C++14
605 minmax(const T& a, const T& b);
Howard Hinnant4eb27b72010-08-21 20:10:01606
607template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18608 constexpr pair<const T&, const T&> // constexpr in C++14
609 minmax(const T& a, const T& b, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01610
611template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18612 constexpr pair<T, T> // constexpr in C++14
613 minmax(initializer_list<T> t);
Howard Hinnant4eb27b72010-08-21 20:10:01614
615template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18616 constexpr pair<T, T> // constexpr in C++14
617 minmax(initializer_list<T> t, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16618
619template <class InputIterator1, class InputIterator2>
Marshall Clow1b9a4ff2018-01-22 20:44:33620 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16621 lexicographical_compare(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
622
623template <class InputIterator1, class InputIterator2, class Compare>
Marshall Clow1b9a4ff2018-01-22 20:44:33624 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16625 lexicographical_compare(InputIterator1 first1, InputIterator1 last1,
626 InputIterator2 first2, InputIterator2 last2, Compare comp);
627
628template <class BidirectionalIterator>
Arthur O'Dwyerf851db32020-12-17 05:01:08629 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16630 next_permutation(BidirectionalIterator first, BidirectionalIterator last);
631
632template <class BidirectionalIterator, class Compare>
Arthur O'Dwyerf851db32020-12-17 05:01:08633 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16634 next_permutation(BidirectionalIterator first, BidirectionalIterator last, 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 prev_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 prev_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
643
644} // std
645
646*/
647
648#include <__config>
Louis Dionne134723e2021-06-17 15:30:11649#include <__debug>
Arthur O'Dwyerbfbd73f2021-05-19 15:57:04650#include <__bits> // __libcpp_clz
Howard Hinnanta1d07d52012-07-26 17:09:09651#include <cstddef>
Arthur O'Dwyerbfbd73f2021-05-19 15:57:04652#include <cstring>
653#include <functional>
654#include <initializer_list>
Louis Dionne134723e2021-06-17 15:30:11655#include <utility> // needed to provide swap_ranges.
656#include <memory>
Arthur O'Dwyerbfbd73f2021-05-19 15:57:04657#include <iterator>
658#include <memory>
659#include <type_traits>
660#include <utility> // swap_ranges
Marshall Clowf56972e2018-09-12 19:41:40661#include <version>
Howard Hinnant5d1a7012013-08-14 18:00:20662
Louis Dionne134723e2021-06-17 15:30:11663#include <__algorithm/adjacent_find.h>
664#include <__algorithm/all_of.h>
665#include <__algorithm/any_of.h>
666#include <__algorithm/binary_search.h>
667#include <__algorithm/clamp.h>
668#include <__algorithm/comp.h>
669#include <__algorithm/comp_ref_type.h>
670#include <__algorithm/copy.h>
671#include <__algorithm/copy_backward.h>
672#include <__algorithm/copy_if.h>
673#include <__algorithm/copy_n.h>
674#include <__algorithm/count.h>
675#include <__algorithm/count_if.h>
676#include <__algorithm/equal.h>
677#include <__algorithm/equal_range.h>
678#include <__algorithm/fill_n.h>
679#include <__algorithm/fill.h>
680#include <__algorithm/find.h>
681#include <__algorithm/find_end.h>
682#include <__algorithm/find_first_of.h>
683#include <__algorithm/find_if.h>
684#include <__algorithm/find_if_not.h>
685#include <__algorithm/for_each.h>
686#include <__algorithm/for_each_n.h>
687#include <__algorithm/generate_n.h>
688#include <__algorithm/generate.h>
689#include <__algorithm/half_positive.h>
690#include <__algorithm/includes.h>
691#include <__algorithm/inplace_merge.h>
692#include <__algorithm/is_heap.h>
693#include <__algorithm/is_heap_until.h>
694#include <__algorithm/is_partitioned.h>
695#include <__algorithm/is_permutation.h>
696#include <__algorithm/is_sorted.h>
697#include <__algorithm/is_sorted_until.h>
Christopher Di Bella6adbc832021-06-05 02:47:47698#include <__algorithm/iter_swap.h>
Louis Dionne134723e2021-06-17 15:30:11699#include <__algorithm/lexicographical_compare.h>
700#include <__algorithm/lower_bound.h>
701#include <__algorithm/make_heap.h>
702#include <__algorithm/max.h>
703#include <__algorithm/max_element.h>
704#include <__algorithm/merge.h>
705#include <__algorithm/min.h>
706#include <__algorithm/min_element.h>
707#include <__algorithm/minmax.h>
708#include <__algorithm/minmax_element.h>
709#include <__algorithm/mismatch.h>
710#include <__algorithm/move.h>
711#include <__algorithm/move_backward.h>
712#include <__algorithm/next_permutation.h>
713#include <__algorithm/none_of.h>
714#include <__algorithm/nth_element.h>
715#include <__algorithm/partial_sort.h>
716#include <__algorithm/partial_sort_copy.h>
717#include <__algorithm/partition.h>
718#include <__algorithm/partition_copy.h>
719#include <__algorithm/partition_point.h>
720#include <__algorithm/pop_heap.h>
721#include <__algorithm/prev_permutation.h>
722#include <__algorithm/push_heap.h>
723#include <__algorithm/remove.h>
724#include <__algorithm/remove_copy.h>
725#include <__algorithm/remove_copy_if.h>
726#include <__algorithm/remove_if.h>
727#include <__algorithm/replace.h>
728#include <__algorithm/replace_copy.h>
729#include <__algorithm/replace_copy_if.h>
730#include <__algorithm/replace_if.h>
731#include <__algorithm/reverse.h>
732#include <__algorithm/reverse_copy.h>
733#include <__algorithm/rotate.h>
734#include <__algorithm/rotate_copy.h>
735#include <__algorithm/sample.h>
736#include <__algorithm/search.h>
737#include <__algorithm/search_n.h>
738#include <__algorithm/set_difference.h>
739#include <__algorithm/set_intersection.h>
740#include <__algorithm/set_symmetric_difference.h>
741#include <__algorithm/set_union.h>
742#include <__algorithm/shift_left.h>
743#include <__algorithm/shift_right.h>
744#include <__algorithm/shuffle.h>
745#include <__algorithm/sift_down.h>
746#include <__algorithm/sort.h>
747#include <__algorithm/sort_heap.h>
748#include <__algorithm/stable_partition.h>
749#include <__algorithm/stable_sort.h>
Christopher Di Bella6adbc832021-06-05 02:47:47750#include <__algorithm/swap_ranges.h>
Louis Dionne134723e2021-06-17 15:30:11751#include <__algorithm/transform.h>
752#include <__algorithm/unique_copy.h>
753#include <__algorithm/unique.h>
754#include <__algorithm/unwrap_iter.h>
755#include <__algorithm/upper_bound.h>
Eric Fiselierc1bd9192014-08-10 23:53:08756
Howard Hinnant073458b2011-10-17 20:05:10757#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Howard Hinnant3e519522010-05-11 19:42:16758#pragma GCC system_header
Howard Hinnant073458b2011-10-17 20:05:10759#endif
Howard Hinnant3e519522010-05-11 19:42:16760
Louis Dionne0a06eb92019-08-05 18:29:14761#if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17
Louis Dionne95689242019-08-06 21:11:24762# include <__pstl_algorithm>
Louis Dionne0a06eb92019-08-05 18:29:14763#endif
764
Louis Dionne4cd6ca12021-04-20 16:03:32765#endif // _LIBCPP_ALGORITHM