blob: b35ad674cbe779709530a52104313e08bb179b16 [file] [log] [blame]
Howard Hinnant3e519522010-05-11 19:42:161// -*- C++ -*-
Louis Dionneeb8650a2021-11-17 21:25:012//===----------------------------------------------------------------------===//
Howard Hinnant3e519522010-05-11 19:42:163//
Chandler Carruth57b08b02019-01-19 10:56:404// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Howard Hinnant3e519522010-05-11 19:42:167//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP_ALGORITHM
11#define _LIBCPP_ALGORITHM
12
13/*
14 algorithm synopsis
15
16#include <initializer_list>
17
18namespace std
19{
20
Nikolas Klauserd3729bb2022-01-14 01:55:5121namespace ranges {
Nikolas Klauser1e77b392022-02-11 16:01:5822 template <class I, class F>
23 struct in_fun_result; // since C++20
24
Nikolas Klauserd3729bb2022-01-14 01:55:5125 template <class I1, class I2>
Nikolas Klauserf3514af2022-01-25 10:21:4726 struct in_in_result; // since C++20
27
28 template <class I1, class I2, class O>
29 struct in_in_out_result; // since C++20
Nikolas Klauser610979b2022-02-03 01:17:0330
31 template <class I, class O1, class O2>
32 struct in_out_out_result; // since C++20
Nikolas Klauser1e77b392022-02-11 16:01:5833
Nikolas Klauser3b470d12022-02-11 12:11:5734 template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
35 indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less> // since C++20
36 constexpr I min_element(I first, S last, Comp comp = {}, Proj proj = {});
37
38 template<forward_range R, class Proj = identity,
39 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less> // since C++20
40 constexpr borrowed_iterator_t<R> min_element(R&& r, Comp comp = {}, Proj proj = {});
Nikolas Klauserd3729bb2022-01-14 01:55:5141}
42
Howard Hinnant3e519522010-05-11 19:42:1643template <class InputIterator, class Predicate>
Marshall Clow706ffef2018-01-15 17:20:3644 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1645 all_of(InputIterator first, InputIterator last, Predicate pred);
46
47template <class InputIterator, class Predicate>
Marshall Clow706ffef2018-01-15 17:20:3648 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1649 any_of(InputIterator first, InputIterator last, Predicate pred);
50
51template <class InputIterator, class Predicate>
Marshall Clow706ffef2018-01-15 17:20:3652 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1653 none_of(InputIterator first, InputIterator last, Predicate pred);
54
55template <class InputIterator, class Function>
Marshall Clow1b9a4ff2018-01-22 20:44:3356 constexpr Function // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1657 for_each(InputIterator first, InputIterator last, Function f);
58
Marshall Clowd5c65ff2017-05-25 02:29:5459template<class InputIterator, class Size, class Function>
Marshall Clow1b9a4ff2018-01-22 20:44:3360 constexpr InputIterator // constexpr in C++20
61 for_each_n(InputIterator first, Size n, Function f); // C++17
Marshall Clowd5c65ff2017-05-25 02:29:5462
Howard Hinnant3e519522010-05-11 19:42:1663template <class InputIterator, class T>
Marshall Clow86944282018-01-15 19:26:0564 constexpr InputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1665 find(InputIterator first, InputIterator last, const T& value);
66
67template <class InputIterator, class Predicate>
Marshall Clow86944282018-01-15 19:26:0568 constexpr InputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1669 find_if(InputIterator first, InputIterator last, Predicate pred);
70
71template<class InputIterator, class Predicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:1872 constexpr InputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1673 find_if_not(InputIterator first, InputIterator last, Predicate pred);
74
75template <class ForwardIterator1, class ForwardIterator2>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:1876 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1677 find_end(ForwardIterator1 first1, ForwardIterator1 last1,
78 ForwardIterator2 first2, ForwardIterator2 last2);
79
80template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:1881 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1682 find_end(ForwardIterator1 first1, ForwardIterator1 last1,
83 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
84
85template <class ForwardIterator1, class ForwardIterator2>
Marshall Clow86944282018-01-15 19:26:0586 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1687 find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
88 ForwardIterator2 first2, ForwardIterator2 last2);
89
90template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow86944282018-01-15 19:26:0591 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1692 find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
93 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
94
95template <class ForwardIterator>
Marshall Clow86944282018-01-15 19:26:0596 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:1697 adjacent_find(ForwardIterator first, ForwardIterator last);
98
99template <class ForwardIterator, class BinaryPredicate>
Marshall Clow86944282018-01-15 19:26:05100 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16101 adjacent_find(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
102
103template <class InputIterator, class T>
Marshall Clow056f15e2018-01-15 19:40:34104 constexpr typename iterator_traits<InputIterator>::difference_type // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16105 count(InputIterator first, InputIterator last, const T& value);
106
107template <class InputIterator, class Predicate>
Marshall Clow056f15e2018-01-15 19:40:34108 constexpr typename iterator_traits<InputIterator>::difference_type // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16109 count_if(InputIterator first, InputIterator last, Predicate pred);
110
111template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:10112 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16113 mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
114
Marshall Clow0b0bbd22013-05-09 21:14:23115template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:10116 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Aditya Kumar331fb802016-08-25 11:52:38117 mismatch(InputIterator1 first1, InputIterator1 last1,
Marshall Clow0b0bbd22013-05-09 21:14:23118 InputIterator2 first2, InputIterator2 last2); // **C++14**
119
Howard Hinnant3e519522010-05-11 19:42:16120template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:10121 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16122 mismatch(InputIterator1 first1, InputIterator1 last1,
123 InputIterator2 first2, BinaryPredicate pred);
124
Marshall Clow0b0bbd22013-05-09 21:14:23125template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:10126 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23127 mismatch(InputIterator1 first1, InputIterator1 last1,
128 InputIterator2 first2, InputIterator2 last2,
129 BinaryPredicate pred); // **C++14**
130
Howard Hinnant3e519522010-05-11 19:42:16131template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:10132 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16133 equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
134
Marshall Clow0b0bbd22013-05-09 21:14:23135template <class InputIterator1, class InputIterator2>
Marshall Clow6538e28d2018-01-16 02:04:10136 constexpr bool // constexpr in C++20
Aditya Kumar331fb802016-08-25 11:52:38137 equal(InputIterator1 first1, InputIterator1 last1,
Marshall Clow0b0bbd22013-05-09 21:14:23138 InputIterator2 first2, InputIterator2 last2); // **C++14**
139
Howard Hinnant3e519522010-05-11 19:42:16140template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:10141 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16142 equal(InputIterator1 first1, InputIterator1 last1,
143 InputIterator2 first2, BinaryPredicate pred);
144
Marshall Clow0b0bbd22013-05-09 21:14:23145template <class InputIterator1, class InputIterator2, class BinaryPredicate>
Marshall Clow6538e28d2018-01-16 02:04:10146 constexpr bool // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23147 equal(InputIterator1 first1, InputIterator1 last1,
148 InputIterator2 first2, InputIterator2 last2,
149 BinaryPredicate pred); // **C++14**
150
Howard Hinnant3e519522010-05-11 19:42:16151template<class ForwardIterator1, class ForwardIterator2>
Marshall Clow49c76432018-01-15 16:16:32152 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16153 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
154 ForwardIterator2 first2);
155
Marshall Clow0b0bbd22013-05-09 21:14:23156template<class ForwardIterator1, class ForwardIterator2>
Marshall Clow49c76432018-01-15 16:16:32157 constexpr bool // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23158 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
159 ForwardIterator2 first2, ForwardIterator2 last2); // **C++14**
160
Howard Hinnant3e519522010-05-11 19:42:16161template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow49c76432018-01-15 16:16:32162 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16163 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
164 ForwardIterator2 first2, BinaryPredicate pred);
165
Marshall Clow0b0bbd22013-05-09 21:14:23166template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow49c76432018-01-15 16:16:32167 constexpr bool // constexpr in C++20
Marshall Clow0b0bbd22013-05-09 21:14:23168 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
169 ForwardIterator2 first2, ForwardIterator2 last2,
170 BinaryPredicate pred); // **C++14**
171
Howard Hinnant3e519522010-05-11 19:42:16172template <class ForwardIterator1, class ForwardIterator2>
Marshall Clow12f0a772018-01-16 15:48:27173 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16174 search(ForwardIterator1 first1, ForwardIterator1 last1,
175 ForwardIterator2 first2, ForwardIterator2 last2);
176
177template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
Marshall Clow12f0a772018-01-16 15:48:27178 constexpr ForwardIterator1 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16179 search(ForwardIterator1 first1, ForwardIterator1 last1,
180 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
181
182template <class ForwardIterator, class Size, class T>
Marshall Clow12f0a772018-01-16 15:48:27183 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16184 search_n(ForwardIterator first, ForwardIterator last, Size count, const T& value);
185
186template <class ForwardIterator, class Size, class T, class BinaryPredicate>
Marshall Clow12f0a772018-01-16 15:48:27187 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16188 search_n(ForwardIterator first, ForwardIterator last,
189 Size count, const T& value, BinaryPredicate pred);
190
191template <class InputIterator, class OutputIterator>
Louis Dionne13c90a52019-11-06 12:02:41192 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16193 copy(InputIterator first, InputIterator last, OutputIterator result);
194
195template<class InputIterator, class OutputIterator, class Predicate>
Louis Dionne13c90a52019-11-06 12:02:41196 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16197 copy_if(InputIterator first, InputIterator last,
198 OutputIterator result, Predicate pred);
199
200template<class InputIterator, class Size, class OutputIterator>
Louis Dionne13c90a52019-11-06 12:02:41201 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16202 copy_n(InputIterator first, Size n, OutputIterator result);
203
204template <class BidirectionalIterator1, class BidirectionalIterator2>
Louis Dionne13c90a52019-11-06 12:02:41205 constexpr BidirectionalIterator2 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16206 copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last,
207 BidirectionalIterator2 result);
208
209template <class ForwardIterator1, class ForwardIterator2>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18210 constexpr ForwardIterator2 // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16211 swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2);
212
Nikolas Klauser9d905312022-02-10 12:33:03213template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2>
214 requires indirectly_swappable<I1, I2>
215 constexpr ranges::swap_ranges_result<I1, I2>
216 ranges::swap_ranges(I1 first1, S1 last1, I2 first2, S2 last2);
217
218template<input_range R1, input_range R2>
219 requires indirectly_swappable<iterator_t<R1>, iterator_t<R2>>
220 constexpr ranges::swap_ranges_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>>
221 ranges::swap_ranges(R1&& r1, R2&& r2);
222
Howard Hinnant3e519522010-05-11 19:42:16223template <class ForwardIterator1, class ForwardIterator2>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18224 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16225 iter_swap(ForwardIterator1 a, ForwardIterator2 b);
226
227template <class InputIterator, class OutputIterator, class UnaryOperation>
Marshall Clow99894b62018-01-19 17:45:39228 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16229 transform(InputIterator first, InputIterator last, OutputIterator result, UnaryOperation op);
230
231template <class InputIterator1, class InputIterator2, class OutputIterator, class BinaryOperation>
Marshall Clow99894b62018-01-19 17:45:39232 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16233 transform(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2,
234 OutputIterator result, BinaryOperation binary_op);
235
236template <class ForwardIterator, class T>
Marshall Clow12c74232018-01-19 18:07:29237 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16238 replace(ForwardIterator first, ForwardIterator last, const T& old_value, const T& new_value);
239
240template <class ForwardIterator, class Predicate, class T>
Marshall Clow12c74232018-01-19 18:07:29241 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16242 replace_if(ForwardIterator first, ForwardIterator last, Predicate pred, const T& new_value);
243
244template <class InputIterator, class OutputIterator, class T>
Marshall Clow12c74232018-01-19 18:07:29245 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16246 replace_copy(InputIterator first, InputIterator last, OutputIterator result,
247 const T& old_value, const T& new_value);
248
249template <class InputIterator, class OutputIterator, class Predicate, class T>
Marshall Clow12c74232018-01-19 18:07:29250 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16251 replace_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred, const T& new_value);
252
253template <class ForwardIterator, class T>
Marshall Clow4bfb9312018-01-20 20:14:32254 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16255 fill(ForwardIterator first, ForwardIterator last, const T& value);
256
257template <class OutputIterator, class Size, class T>
Marshall Clow4bfb9312018-01-20 20:14:32258 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16259 fill_n(OutputIterator first, Size n, const T& value);
260
261template <class ForwardIterator, class Generator>
Marshall Clow4bfb9312018-01-20 20:14:32262 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16263 generate(ForwardIterator first, ForwardIterator last, Generator gen);
264
265template <class OutputIterator, class Size, class Generator>
Marshall Clow4bfb9312018-01-20 20:14:32266 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16267 generate_n(OutputIterator first, Size n, Generator gen);
268
269template <class ForwardIterator, class T>
Marshall Clowe8ea8292018-01-22 21:43:04270 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16271 remove(ForwardIterator first, ForwardIterator last, const T& value);
272
273template <class ForwardIterator, class Predicate>
Marshall Clowe8ea8292018-01-22 21:43:04274 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16275 remove_if(ForwardIterator first, ForwardIterator last, Predicate pred);
276
277template <class InputIterator, class OutputIterator, class T>
Marshall Clowe8ea8292018-01-22 21:43:04278 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16279 remove_copy(InputIterator first, InputIterator last, OutputIterator result, const T& value);
280
281template <class InputIterator, class OutputIterator, class Predicate>
Marshall Clowe8ea8292018-01-22 21:43:04282 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16283 remove_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred);
284
285template <class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18286 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16287 unique(ForwardIterator first, ForwardIterator last);
288
289template <class ForwardIterator, class BinaryPredicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18290 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16291 unique(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
292
293template <class InputIterator, class OutputIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18294 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16295 unique_copy(InputIterator first, InputIterator last, OutputIterator result);
296
297template <class InputIterator, class OutputIterator, class BinaryPredicate>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18298 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16299 unique_copy(InputIterator first, InputIterator last, OutputIterator result, BinaryPredicate pred);
300
301template <class BidirectionalIterator>
Arthur O'Dwyerf851db32020-12-17 05:01:08302 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16303 reverse(BidirectionalIterator first, BidirectionalIterator last);
304
305template <class BidirectionalIterator, class OutputIterator>
Marshall Clowe8ea8292018-01-22 21:43:04306 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16307 reverse_copy(BidirectionalIterator first, BidirectionalIterator last, OutputIterator result);
308
309template <class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18310 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16311 rotate(ForwardIterator first, ForwardIterator middle, ForwardIterator last);
312
313template <class ForwardIterator, class OutputIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18314 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16315 rotate_copy(ForwardIterator first, ForwardIterator middle, ForwardIterator last, OutputIterator result);
316
317template <class RandomAccessIterator>
318 void
Marshall Clow0f37a412017-03-23 13:43:37319 random_shuffle(RandomAccessIterator first, RandomAccessIterator last); // deprecated in C++14, removed in C++17
Howard Hinnant3e519522010-05-11 19:42:16320
321template <class RandomAccessIterator, class RandomNumberGenerator>
322 void
Marshall Clow06965c12014-03-03 06:14:19323 random_shuffle(RandomAccessIterator first, RandomAccessIterator last,
Marshall Clow0f37a412017-03-23 13:43:37324 RandomNumberGenerator& rand); // deprecated in C++14, removed in C++17
Howard Hinnant3e519522010-05-11 19:42:16325
Eric Fiseliere7154702016-08-28 22:14:37326template<class PopulationIterator, class SampleIterator,
327 class Distance, class UniformRandomBitGenerator>
328 SampleIterator sample(PopulationIterator first, PopulationIterator last,
329 SampleIterator out, Distance n,
330 UniformRandomBitGenerator&& g); // C++17
331
Howard Hinnantf9d540b2010-05-26 17:49:34332template<class RandomAccessIterator, class UniformRandomNumberGenerator>
333 void shuffle(RandomAccessIterator first, RandomAccessIterator last,
Howard Hinnantfb340102010-11-18 01:47:02334 UniformRandomNumberGenerator&& g);
Howard Hinnantf9d540b2010-05-26 17:49:34335
Arthur O'Dwyer3fbd3ea2020-12-26 06:39:03336template<class ForwardIterator>
337 constexpr ForwardIterator
338 shift_left(ForwardIterator first, ForwardIterator last,
339 typename iterator_traits<ForwardIterator>::difference_type n); // C++20
340
341template<class ForwardIterator>
342 constexpr ForwardIterator
343 shift_right(ForwardIterator first, ForwardIterator last,
344 typename iterator_traits<ForwardIterator>::difference_type n); // C++20
345
Howard Hinnant3e519522010-05-11 19:42:16346template <class InputIterator, class Predicate>
Marshall Clow49c76432018-01-15 16:16:32347 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16348 is_partitioned(InputIterator first, InputIterator last, Predicate pred);
349
350template <class ForwardIterator, class Predicate>
Arthur O'Dwyerf851db32020-12-17 05:01:08351 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16352 partition(ForwardIterator first, ForwardIterator last, Predicate pred);
353
354template <class InputIterator, class OutputIterator1,
355 class OutputIterator2, class Predicate>
Marshall Clow1b9a4ff2018-01-22 20:44:33356 constexpr pair<OutputIterator1, OutputIterator2> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16357 partition_copy(InputIterator first, InputIterator last,
358 OutputIterator1 out_true, OutputIterator2 out_false,
359 Predicate pred);
360
361template <class ForwardIterator, class Predicate>
362 ForwardIterator
363 stable_partition(ForwardIterator first, ForwardIterator last, Predicate pred);
364
365template<class ForwardIterator, class Predicate>
Marshall Clowd57c03d2018-01-16 02:34:41366 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16367 partition_point(ForwardIterator first, ForwardIterator last, Predicate pred);
368
369template <class ForwardIterator>
Marshall Clow49c76432018-01-15 16:16:32370 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16371 is_sorted(ForwardIterator first, ForwardIterator last);
372
373template <class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18374 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16375 is_sorted(ForwardIterator first, ForwardIterator last, Compare comp);
376
377template<class ForwardIterator>
Marshall Clow056f15e2018-01-15 19:40:34378 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16379 is_sorted_until(ForwardIterator first, ForwardIterator last);
380
381template <class ForwardIterator, class Compare>
Marshall Clow056f15e2018-01-15 19:40:34382 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16383 is_sorted_until(ForwardIterator first, ForwardIterator last, Compare comp);
384
385template <class RandomAccessIterator>
Arthur O'Dwyer493f1402020-12-20 20:21:42386 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16387 sort(RandomAccessIterator first, RandomAccessIterator last);
388
389template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer493f1402020-12-20 20:21:42390 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16391 sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
392
393template <class RandomAccessIterator>
394 void
395 stable_sort(RandomAccessIterator first, RandomAccessIterator last);
396
397template <class RandomAccessIterator, class Compare>
398 void
399 stable_sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
400
401template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18402 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16403 partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last);
404
405template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18406 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16407 partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last, Compare comp);
408
409template <class InputIterator, class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18410 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16411 partial_sort_copy(InputIterator first, InputIterator last,
412 RandomAccessIterator result_first, RandomAccessIterator result_last);
413
414template <class InputIterator, class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18415 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16416 partial_sort_copy(InputIterator first, InputIterator last,
417 RandomAccessIterator result_first, RandomAccessIterator result_last, Compare comp);
418
419template <class RandomAccessIterator>
Arthur O'Dwyer5d956562021-02-04 23:12:52420 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16421 nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last);
422
423template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5d956562021-02-04 23:12:52424 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16425 nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last, Compare comp);
426
427template <class ForwardIterator, class T>
Marshall Clowd57c03d2018-01-16 02:34:41428 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16429 lower_bound(ForwardIterator first, ForwardIterator last, const T& value);
430
431template <class ForwardIterator, class T, class Compare>
Marshall Clowd57c03d2018-01-16 02:34:41432 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16433 lower_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
434
435template <class ForwardIterator, class T>
Marshall Clowd57c03d2018-01-16 02:34:41436 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16437 upper_bound(ForwardIterator first, ForwardIterator last, const T& value);
438
439template <class ForwardIterator, class T, class Compare>
Marshall Clowd57c03d2018-01-16 02:34:41440 constexpr ForwardIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16441 upper_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
442
443template <class ForwardIterator, class T>
Marshall Clowd57c03d2018-01-16 02:34:41444 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16445 equal_range(ForwardIterator first, ForwardIterator last, const T& value);
446
447template <class ForwardIterator, class T, class Compare>
Marshall Clowd57c03d2018-01-16 02:34:41448 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16449 equal_range(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
450
451template <class ForwardIterator, class T>
Marshall Clowd57c03d2018-01-16 02:34:41452 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16453 binary_search(ForwardIterator first, ForwardIterator last, const T& value);
454
455template <class ForwardIterator, class T, class Compare>
Marshall Clow8da1a482018-01-22 23:10:40456 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16457 binary_search(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
458
459template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer14098cf2020-12-04 18:47:12460 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16461 merge(InputIterator1 first1, InputIterator1 last1,
462 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
463
464template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer14098cf2020-12-04 18:47:12465 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16466 merge(InputIterator1 first1, InputIterator1 last1,
467 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
468
469template <class BidirectionalIterator>
470 void
471 inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last);
472
473template <class BidirectionalIterator, class Compare>
474 void
475 inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last, Compare comp);
476
477template <class InputIterator1, class InputIterator2>
Marshall Clow8da1a482018-01-22 23:10:40478 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16479 includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
480
481template <class InputIterator1, class InputIterator2, class Compare>
Marshall Clow8da1a482018-01-22 23:10:40482 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16483 includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, Compare comp);
484
485template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer14098cf2020-12-04 18:47:12486 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16487 set_union(InputIterator1 first1, InputIterator1 last1,
488 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
489
490template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer14098cf2020-12-04 18:47:12491 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16492 set_union(InputIterator1 first1, InputIterator1 last1,
493 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
494
495template <class InputIterator1, class InputIterator2, class OutputIterator>
Marshall Clow8da1a482018-01-22 23:10:40496 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16497 set_intersection(InputIterator1 first1, InputIterator1 last1,
498 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
499
500template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Marshall Clow8da1a482018-01-22 23:10:40501 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16502 set_intersection(InputIterator1 first1, InputIterator1 last1,
503 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
504
505template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer14098cf2020-12-04 18:47:12506 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16507 set_difference(InputIterator1 first1, InputIterator1 last1,
508 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
509
510template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer14098cf2020-12-04 18:47:12511 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16512 set_difference(InputIterator1 first1, InputIterator1 last1,
513 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
514
515template <class InputIterator1, class InputIterator2, class OutputIterator>
Arthur O'Dwyer14098cf2020-12-04 18:47:12516 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16517 set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
518 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
519
520template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
Arthur O'Dwyer14098cf2020-12-04 18:47:12521 constexpr OutputIterator // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16522 set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
523 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
524
525template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18526 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16527 push_heap(RandomAccessIterator first, RandomAccessIterator last);
528
529template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18530 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16531 push_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
532
533template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18534 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16535 pop_heap(RandomAccessIterator first, RandomAccessIterator last);
536
537template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18538 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16539 pop_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
540
541template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18542 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16543 make_heap(RandomAccessIterator first, RandomAccessIterator last);
544
545template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18546 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16547 make_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
548
549template <class RandomAccessIterator>
Arthur O'Dwyer5386aa22020-12-17 05:26:18550 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16551 sort_heap(RandomAccessIterator first, RandomAccessIterator last);
552
553template <class RandomAccessIterator, class Compare>
Arthur O'Dwyer5386aa22020-12-17 05:26:18554 constexpr void // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16555 sort_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
556
Howard Hinnantb3371f62010-08-22 00:02:43557template <class RandomAccessIterator>
Marshall Clow49c76432018-01-15 16:16:32558 constexpr bool // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43559 is_heap(RandomAccessIterator first, RandomAccessiterator last);
Howard Hinnant3e519522010-05-11 19:42:16560
Howard Hinnantb3371f62010-08-22 00:02:43561template <class RandomAccessIterator, class Compare>
Marshall Clow49c76432018-01-15 16:16:32562 constexpr bool // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43563 is_heap(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16564
Howard Hinnantb3371f62010-08-22 00:02:43565template <class RandomAccessIterator>
Marshall Clow49c76432018-01-15 16:16:32566 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43567 is_heap_until(RandomAccessIterator first, RandomAccessiterator last);
Howard Hinnant3e519522010-05-11 19:42:16568
Howard Hinnantb3371f62010-08-22 00:02:43569template <class RandomAccessIterator, class Compare>
Marshall Clow49c76432018-01-15 16:16:32570 constexpr RandomAccessIterator // constexpr in C++20
Howard Hinnantb3371f62010-08-22 00:02:43571 is_heap_until(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16572
Howard Hinnant4eb27b72010-08-21 20:10:01573template <class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18574 constexpr ForwardIterator // constexpr in C++14
575 min_element(ForwardIterator first, ForwardIterator last);
Howard Hinnant4eb27b72010-08-21 20:10:01576
577template <class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18578 constexpr ForwardIterator // constexpr in C++14
579 min_element(ForwardIterator first, ForwardIterator last, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01580
Howard Hinnant3e519522010-05-11 19:42:16581template <class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18582 constexpr const T& // constexpr in C++14
583 min(const T& a, const T& b);
Howard Hinnant3e519522010-05-11 19:42:16584
585template <class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18586 constexpr const T& // constexpr in C++14
587 min(const T& a, const T& b, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16588
Howard Hinnant4eb27b72010-08-21 20:10:01589template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18590 constexpr T // constexpr in C++14
591 min(initializer_list<T> t);
Howard Hinnant4eb27b72010-08-21 20:10:01592
593template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18594 constexpr T // constexpr in C++14
595 min(initializer_list<T> t, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01596
Marshall Clow146c14a2016-03-07 22:43:49597template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18598 constexpr const T& clamp(const T& v, const T& lo, const T& hi); // C++17
Marshall Clow146c14a2016-03-07 22:43:49599
600template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18601 constexpr const T& clamp(const T& v, const T& lo, const T& hi, Compare comp); // C++17
Marshall Clow146c14a2016-03-07 22:43:49602
Howard Hinnant4eb27b72010-08-21 20:10:01603template <class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18604 constexpr ForwardIterator // constexpr in C++14
605 max_element(ForwardIterator first, ForwardIterator last);
Howard Hinnant4eb27b72010-08-21 20:10:01606
607template <class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18608 constexpr ForwardIterator // constexpr in C++14
609 max_element(ForwardIterator first, ForwardIterator last, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01610
Howard Hinnant3e519522010-05-11 19:42:16611template <class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18612 constexpr const T& // constexpr in C++14
613 max(const T& a, const T& b);
Howard Hinnant3e519522010-05-11 19:42:16614
615template <class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18616 constexpr const T& // constexpr in C++14
617 max(const T& a, const T& b, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16618
Howard Hinnant4eb27b72010-08-21 20:10:01619template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18620 constexpr T // constexpr in C++14
621 max(initializer_list<T> t);
Howard Hinnant3e519522010-05-11 19:42:16622
Howard Hinnant4eb27b72010-08-21 20:10:01623template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18624 constexpr T // constexpr in C++14
625 max(initializer_list<T> t, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16626
Howard Hinnant4eb27b72010-08-21 20:10:01627template<class ForwardIterator>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18628 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++14
629 minmax_element(ForwardIterator first, ForwardIterator last);
Howard Hinnant3e519522010-05-11 19:42:16630
Howard Hinnant4eb27b72010-08-21 20:10:01631template<class ForwardIterator, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18632 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++14
633 minmax_element(ForwardIterator first, ForwardIterator last, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01634
635template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18636 constexpr pair<const T&, const T&> // constexpr in C++14
637 minmax(const T& a, const T& b);
Howard Hinnant4eb27b72010-08-21 20:10:01638
639template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18640 constexpr pair<const T&, const T&> // constexpr in C++14
641 minmax(const T& a, const T& b, Compare comp);
Howard Hinnant4eb27b72010-08-21 20:10:01642
643template<class T>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18644 constexpr pair<T, T> // constexpr in C++14
645 minmax(initializer_list<T> t);
Howard Hinnant4eb27b72010-08-21 20:10:01646
647template<class T, class Compare>
Arthur O'Dwyerb8bc4e12020-12-03 01:02:18648 constexpr pair<T, T> // constexpr in C++14
649 minmax(initializer_list<T> t, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16650
651template <class InputIterator1, class InputIterator2>
Marshall Clow1b9a4ff2018-01-22 20:44:33652 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16653 lexicographical_compare(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
654
655template <class InputIterator1, class InputIterator2, class Compare>
Marshall Clow1b9a4ff2018-01-22 20:44:33656 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16657 lexicographical_compare(InputIterator1 first1, InputIterator1 last1,
658 InputIterator2 first2, InputIterator2 last2, Compare comp);
659
660template <class BidirectionalIterator>
Arthur O'Dwyerf851db32020-12-17 05:01:08661 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16662 next_permutation(BidirectionalIterator first, BidirectionalIterator last);
663
664template <class BidirectionalIterator, class Compare>
Arthur O'Dwyerf851db32020-12-17 05:01:08665 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16666 next_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
667
668template <class BidirectionalIterator>
Arthur O'Dwyerf851db32020-12-17 05:01:08669 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16670 prev_permutation(BidirectionalIterator first, BidirectionalIterator last);
671
672template <class BidirectionalIterator, class Compare>
Arthur O'Dwyerf851db32020-12-17 05:01:08673 constexpr bool // constexpr in C++20
Howard Hinnant3e519522010-05-11 19:42:16674 prev_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
Howard Hinnant3e519522010-05-11 19:42:16675} // std
676
677*/
678
Arthur O'Dwyerea2206d2022-02-04 18:09:30679#include <__bits>
Howard Hinnant3e519522010-05-11 19:42:16680#include <__config>
Louis Dionne134723e2021-06-17 15:30:11681#include <__debug>
Howard Hinnanta1d07d52012-07-26 17:09:09682#include <cstddef>
Arthur O'Dwyerbfbd73f2021-05-19 15:57:04683#include <cstring>
684#include <functional>
685#include <initializer_list>
Arthur O'Dwyerbfbd73f2021-05-19 15:57:04686#include <iterator>
687#include <memory>
688#include <type_traits>
Arthur O'Dwyerea2206d2022-02-04 18:09:30689#include <utility>
Marshall Clowf56972e2018-09-12 19:41:40690#include <version>
Howard Hinnant5d1a7012013-08-14 18:00:20691
Louis Dionne134723e2021-06-17 15:30:11692#include <__algorithm/adjacent_find.h>
693#include <__algorithm/all_of.h>
694#include <__algorithm/any_of.h>
695#include <__algorithm/binary_search.h>
696#include <__algorithm/clamp.h>
697#include <__algorithm/comp.h>
698#include <__algorithm/comp_ref_type.h>
699#include <__algorithm/copy.h>
700#include <__algorithm/copy_backward.h>
701#include <__algorithm/copy_if.h>
702#include <__algorithm/copy_n.h>
703#include <__algorithm/count.h>
704#include <__algorithm/count_if.h>
705#include <__algorithm/equal.h>
706#include <__algorithm/equal_range.h>
Louis Dionne134723e2021-06-17 15:30:11707#include <__algorithm/fill.h>
Arthur O'Dwyer4d81a462022-01-07 14:45:05708#include <__algorithm/fill_n.h>
Louis Dionne134723e2021-06-17 15:30:11709#include <__algorithm/find.h>
710#include <__algorithm/find_end.h>
711#include <__algorithm/find_first_of.h>
712#include <__algorithm/find_if.h>
713#include <__algorithm/find_if_not.h>
714#include <__algorithm/for_each.h>
715#include <__algorithm/for_each_n.h>
Louis Dionne134723e2021-06-17 15:30:11716#include <__algorithm/generate.h>
Arthur O'Dwyer4d81a462022-01-07 14:45:05717#include <__algorithm/generate_n.h>
Louis Dionne134723e2021-06-17 15:30:11718#include <__algorithm/half_positive.h>
Nikolas Klauser1e77b392022-02-11 16:01:58719#include <__algorithm/in_fun_result.h>
Nikolas Klauserf3514af2022-01-25 10:21:47720#include <__algorithm/in_in_out_result.h>
Nikolas Klauserd3729bb2022-01-14 01:55:51721#include <__algorithm/in_in_result.h>
Nikolas Klauser610979b2022-02-03 01:17:03722#include <__algorithm/in_out_out_result.h>
Konstantin Varlamov8d23b742022-01-11 06:49:37723#include <__algorithm/in_out_result.h>
Louis Dionne134723e2021-06-17 15:30:11724#include <__algorithm/includes.h>
725#include <__algorithm/inplace_merge.h>
726#include <__algorithm/is_heap.h>
727#include <__algorithm/is_heap_until.h>
728#include <__algorithm/is_partitioned.h>
729#include <__algorithm/is_permutation.h>
730#include <__algorithm/is_sorted.h>
731#include <__algorithm/is_sorted_until.h>
Christopher Di Bella6adbc832021-06-05 02:47:47732#include <__algorithm/iter_swap.h>
Louis Dionne134723e2021-06-17 15:30:11733#include <__algorithm/lexicographical_compare.h>
734#include <__algorithm/lower_bound.h>
735#include <__algorithm/make_heap.h>
736#include <__algorithm/max.h>
737#include <__algorithm/max_element.h>
738#include <__algorithm/merge.h>
739#include <__algorithm/min.h>
740#include <__algorithm/min_element.h>
741#include <__algorithm/minmax.h>
742#include <__algorithm/minmax_element.h>
743#include <__algorithm/mismatch.h>
744#include <__algorithm/move.h>
745#include <__algorithm/move_backward.h>
746#include <__algorithm/next_permutation.h>
747#include <__algorithm/none_of.h>
748#include <__algorithm/nth_element.h>
749#include <__algorithm/partial_sort.h>
750#include <__algorithm/partial_sort_copy.h>
751#include <__algorithm/partition.h>
752#include <__algorithm/partition_copy.h>
753#include <__algorithm/partition_point.h>
754#include <__algorithm/pop_heap.h>
755#include <__algorithm/prev_permutation.h>
756#include <__algorithm/push_heap.h>
Nikolas Klauser3b470d12022-02-11 12:11:57757#include <__algorithm/ranges_min_element.h>
Nikolas Klauser9d905312022-02-10 12:33:03758#include <__algorithm/ranges_swap_ranges.h>
Louis Dionne134723e2021-06-17 15:30:11759#include <__algorithm/remove.h>
760#include <__algorithm/remove_copy.h>
761#include <__algorithm/remove_copy_if.h>
762#include <__algorithm/remove_if.h>
763#include <__algorithm/replace.h>
764#include <__algorithm/replace_copy.h>
765#include <__algorithm/replace_copy_if.h>
766#include <__algorithm/replace_if.h>
767#include <__algorithm/reverse.h>
768#include <__algorithm/reverse_copy.h>
769#include <__algorithm/rotate.h>
770#include <__algorithm/rotate_copy.h>
771#include <__algorithm/sample.h>
772#include <__algorithm/search.h>
773#include <__algorithm/search_n.h>
774#include <__algorithm/set_difference.h>
775#include <__algorithm/set_intersection.h>
776#include <__algorithm/set_symmetric_difference.h>
777#include <__algorithm/set_union.h>
778#include <__algorithm/shift_left.h>
779#include <__algorithm/shift_right.h>
780#include <__algorithm/shuffle.h>
781#include <__algorithm/sift_down.h>
782#include <__algorithm/sort.h>
783#include <__algorithm/sort_heap.h>
784#include <__algorithm/stable_partition.h>
785#include <__algorithm/stable_sort.h>
Christopher Di Bella6adbc832021-06-05 02:47:47786#include <__algorithm/swap_ranges.h>
Louis Dionne134723e2021-06-17 15:30:11787#include <__algorithm/transform.h>
Louis Dionne134723e2021-06-17 15:30:11788#include <__algorithm/unique.h>
Arthur O'Dwyer4d81a462022-01-07 14:45:05789#include <__algorithm/unique_copy.h>
Louis Dionne134723e2021-06-17 15:30:11790#include <__algorithm/unwrap_iter.h>
791#include <__algorithm/upper_bound.h>
Eric Fiselierc1bd9192014-08-10 23:53:08792
Howard Hinnant073458b2011-10-17 20:05:10793#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Arthur O'Dwyerfa6b9e42022-02-02 01:16:40794# pragma GCC system_header
Howard Hinnant073458b2011-10-17 20:05:10795#endif
Howard Hinnant3e519522010-05-11 19:42:16796
Louis Dionne0a06eb92019-08-05 18:29:14797#if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17
Louis Dionne95689242019-08-06 21:11:24798# include <__pstl_algorithm>
Louis Dionne0a06eb92019-08-05 18:29:14799#endif
800
Louis Dionne4cd6ca12021-04-20 16:03:32801#endif // _LIBCPP_ALGORITHM