1// -*- C++ -*- 2//===----------------------------------------------------------------------===// 3// 4// 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 7// 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 21namespace ranges { 22 template <class I, class F> 23 struct in_fun_result; // since C++20 24 25 template <class I1, class I2> 26 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 30 31 template <class I, class O1, class O2> 32 struct in_out_out_result; // since C++20 33 34 template <class I1, class I2> 35 struct min_max_result; // since C++20 36 37 template <class I> 38 struct in_found_result; // since C++20 39 40 template<forward_iterator I, sentinel_for<I> S, class Proj = identity, 41 indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less> // since C++20 42 constexpr I min_element(I first, S last, Comp comp = {}, Proj proj = {}); 43 44 template<forward_range R, class Proj = identity, 45 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less> // since C++20 46 constexpr borrowed_iterator_t<R> min_element(R&& r, Comp comp = {}, Proj proj = {}); 47 48 template<forward_iterator I, sentinel_for<I> S, class Proj = identity, 49 indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less> 50 constexpr I ranges::max_element(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20 51 52 template<forward_range R, class Proj = identity, 53 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less> 54 constexpr borrowed_iterator_t<R> ranges::max_element(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 55 56 57 template <input_iterator I1, sentinel_for<_I1> S1, input_iterator I2, sentinel_for<_I2> S2, 58 class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> 59 requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2> 60 constexpr mismatch_result<_I1, _I2> 61 mismatch()(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}) // since C++20 62 63 template <input_range R1, input_range R2, 64 class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> 65 requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2> 66 constexpr mismatch_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>> 67 mismatch(R1&& r1, R2&& r2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}) // since C++20 68 69 requires indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*> 70 constexpr I find(I first, S last, const T& value, Proj proj = {}); // since C++20 71 72 template<input_range R, class T, class Proj = identity> 73 requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*> 74 constexpr borrowed_iterator_t<R> 75 find(R&& r, const T& value, Proj proj = {}); // since C++20 76 77 template<input_iterator I, sentinel_for<I> S, class Proj = identity, 78 indirect_unary_predicate<projected<I, Proj>> Pred> 79 constexpr I find_if(I first, S last, Pred pred, Proj proj = {}); // since C++20 80 81 template<input_range R, class Proj = identity, 82 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred> 83 constexpr borrowed_iterator_t<R> 84 find_if(R&& r, Pred pred, Proj proj = {}); // since C++20 85 86 template<input_iterator I, sentinel_for<I> S, class Proj = identity, 87 indirect_unary_predicate<projected<I, Proj>> Pred> 88 constexpr I find_if_not(I first, S last, Pred pred, Proj proj = {}); // since C++20 89 90 template<input_range R, class Proj = identity, 91 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred> 92 constexpr borrowed_iterator_t<R> 93 find_if_not(R&& r, Pred pred, Proj proj = {}); // since C++20 94 95 template<class T, class Proj = identity, 96 indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less> 97 constexpr const T& min(const T& a, const T& b, Comp comp = {}, Proj proj = {}); // since C++20 98 99 template<copyable T, class Proj = identity, 100 indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less> 101 constexpr T min(initializer_list<T> r, Comp comp = {}, Proj proj = {}); // since C++20 102 103 template<input_range R, class Proj = identity, 104 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less> 105 requires indirectly_copyable_storable<iterator_t<R>, range_value_t<R>*> 106 constexpr range_value_t<R> 107 min(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 108 109 template<class T, class Proj = identity, 110 indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less> 111 constexpr const T& max(const T& a, const T& b, Comp comp = {}, Proj proj = {}); // since C++20 112 113 template<copyable T, class Proj = identity, 114 indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less> 115 constexpr T max(initializer_list<T> r, Comp comp = {}, Proj proj = {}); // since C++20 116 117 template<input_range R, class Proj = identity, 118 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less> 119 requires indirectly_copyable_storable<iterator_t<R>, range_value_t<R>*> 120 constexpr range_value_t<R> 121 max(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 122 123 template<class I, class O> 124 using unary_transform_result = in_out_result<I, O>; // since C++20 125 126 template<class I1, class I2, class O> 127 using binary_transform_result = in_in_out_result<I1, I2, O>; // since C++20 128 129 template<input_iterator I, sentinel_for<I> S, weakly_incrementable O, 130 copy_constructible F, class Proj = identity> 131 requires indirectly_writable<O, indirect_result_t<F&, projected<I, Proj>>> 132 constexpr ranges::unary_transform_result<I, O> 133 transform(I first1, S last1, O result, F op, Proj proj = {}); // since C++20 134 135 template<input_range R, weakly_incrementable O, copy_constructible F, 136 class Proj = identity> 137 requires indirectly_writable<O, indirect_result_t<F&, projected<iterator_t<R>, Proj>>> 138 constexpr ranges::unary_transform_result<borrowed_iterator_t<R>, O> 139 transform(R&& r, O result, F op, Proj proj = {}); // since C++20 140 141 template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2, 142 weakly_incrementable O, copy_constructible F, class Proj1 = identity, 143 class Proj2 = identity> 144 requires indirectly_writable<O, indirect_result_t<F&, projected<I1, Proj1>, 145 projected<I2, Proj2>>> 146 constexpr ranges::binary_transform_result<I1, I2, O> 147 transform(I1 first1, S1 last1, I2 first2, S2 last2, O result, 148 F binary_op, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 149 150 template<input_range R1, input_range R2, weakly_incrementable O, 151 copy_constructible F, class Proj1 = identity, class Proj2 = identity> 152 requires indirectly_writable<O, indirect_result_t<F&, projected<iterator_t<R1>, Proj1>, 153 projected<iterator_t<R2>, Proj2>>> 154 constexpr ranges::binary_transform_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>, O> 155 transform(R1&& r1, R2&& r2, O result, 156 F binary_op, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 157 158 template<input_iterator I, sentinel_for<I> S, class T, class Proj = identity> 159 requires indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*> 160 constexpr iter_difference_t<I> 161 count(I first, S last, const T& value, Proj proj = {}); // since C++20 162 163 template<input_range R, class T, class Proj = identity> 164 requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*> 165 constexpr range_difference_t<R> 166 count(R&& r, const T& value, Proj proj = {}); // since C++20 167 168 template<input_iterator I, sentinel_for<I> S, class Proj = identity, 169 indirect_unary_predicate<projected<I, Proj>> Pred> 170 constexpr iter_difference_t<I> 171 count_if(I first, S last, Pred pred, Proj proj = {}); // since C++20 172 173 template<input_range R, class Proj = identity, 174 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred> 175 constexpr range_difference_t<R> 176 count_if(R&& r, Pred pred, Proj proj = {}); // since C++20 177 178 template<class T, class Proj = identity, 179 indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less> 180 constexpr ranges::minmax_result<const T&> 181 minmax(const T& a, const T& b, Comp comp = {}, Proj proj = {}); // since C++20 182 183 template<copyable T, class Proj = identity, 184 indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less> 185 constexpr ranges::minmax_result<T> 186 minmax(initializer_list<T> r, Comp comp = {}, Proj proj = {}); // since C++20 187 188 template<input_range R, class Proj = identity, 189 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less> 190 requires indirectly_copyable_storable<iterator_t<R>, range_value_t<R>*> 191 constexpr ranges::minmax_result<range_value_t<R>> 192 minmax(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 193 194 template<forward_iterator I, sentinel_for<I> S, class Proj = identity, 195 indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less> 196 constexpr ranges::minmax_element_result<I> 197 minmax_element(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20 198 199 template<forward_range R, class Proj = identity, 200 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less> 201 constexpr ranges::minmax_element_result<borrowed_iterator_t<R>> 202 minmax_element(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 203 204 template<class I, class O> 205 using copy_result = in_out_result<I, O>; // since C++20 206 207 template<class I, class O> 208 using copy_n_result = in_out_result<I, O>; // since C++20 209 210 template<class I, class O> 211 using copy_if_result = in_out_result<I, O>; // since C++20 212 213 template<class I1, class I2> 214 using copy_backward_result = in_out_result<I1, I2>; // since C++20 215 216 template<input_iterator I, sentinel_for<I> S, weakly_incrementable O> 217 requires indirectly_copyable<I, O> 218 constexpr ranges::copy_result<I, O> ranges::copy(I first, S last, O result); // since C++20 219 220 template<input_range R, weakly_incrementable O> 221 requires indirectly_copyable<iterator_t<R>, O> 222 constexpr ranges::copy_result<borrowed_iterator_t<R>, O> ranges::copy(R&& r, O result); // since C++20 223 224 template<input_iterator I, weakly_incrementable O> 225 requires indirectly_copyable<I, O> 226 constexpr ranges::copy_n_result<I, O> 227 ranges::copy_n(I first, iter_difference_t<I> n, O result); // since C++20 228 229 template<input_iterator I, sentinel_for<I> S, weakly_incrementable O, class Proj = identity, 230 indirect_unary_predicate<projected<I, Proj>> Pred> 231 requires indirectly_copyable<I, O> 232 constexpr ranges::copy_if_result<I, O> 233 ranges::copy_if(I first, S last, O result, Pred pred, Proj proj = {}); // since C++20 234 235 template<input_range R, weakly_incrementable O, class Proj = identity, 236 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred> 237 requires indirectly_copyable<iterator_t<R>, O> 238 constexpr ranges::copy_if_result<borrowed_iterator_t<R>, O> 239 ranges::copy_if(R&& r, O result, Pred pred, Proj proj = {}); // since C++20 240 241 template<bidirectional_iterator I1, sentinel_for<I1> S1, bidirectional_iterator I2> 242 requires indirectly_copyable<I1, I2> 243 constexpr ranges::copy_backward_result<I1, I2> 244 ranges::copy_backward(I1 first, S1 last, I2 result); // since C++20 245 246 template<bidirectional_range R, bidirectional_iterator I> 247 requires indirectly_copyable<iterator_t<R>, I> 248 constexpr ranges::copy_backward_result<borrowed_iterator_t<R>, I> 249 ranges::copy_backward(R&& r, I result); // since C++20 250 251 template<class I, class F> 252 using for_each_result = in_fun_result<I, F>; // since C++20 253 254 template<input_iterator I, sentinel_for<I> S, class Proj = identity, 255 indirectly_unary_invocable<projected<I, Proj>> Fun> 256 constexpr ranges::for_each_result<I, Fun> 257 ranges::for_each(I first, S last, Fun f, Proj proj = {}); // since C++20 258 259 template<input_range R, class Proj = identity, 260 indirectly_unary_invocable<projected<iterator_t<R>, Proj>> Fun> 261 constexpr ranges::for_each_result<borrowed_iterator_t<R>, Fun> 262 ranges::for_each(R&& r, Fun f, Proj proj = {}); // since C++20 263 264 template<input_iterator I, class Proj = identity, 265 indirectly_unary_invocable<projected<I, Proj>> Fun> 266 constexpr ranges::for_each_n_result<I, Fun> 267 ranges::for_each_n(I first, iter_difference_t<I> n, Fun f, Proj proj = {}); // since C++20 268 269 template<input_iterator I, sentinel_for<I> S, class Proj = identity, 270 indirect_unary_predicate<projected<I, Proj>> Pred> 271 constexpr bool ranges::is_partitioned(I first, S last, Pred pred, Proj proj = {}); // since C++20 272 273 template<input_range R, class Proj = identity, 274 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred> 275 constexpr bool ranges::is_partitioned(R&& r, Pred pred, Proj proj = {}); // since C++20 276 277 278 template<bidirectional_iterator I, sentinel_for<I> S> 279 requires permutable<I> 280 constexpr I ranges::reverse(I first, S last); // since C++20 281 282 template<bidirectional_range R> 283 requires permutable<iterator_t<R>> 284 constexpr borrowed_iterator_t<R> ranges::reverse(R&& r); // since C++20 285 286 template<class T, output_iterator<const T&> O, sentinel_for<O> S> 287 constexpr O ranges::fill(O first, S last, const T& value); // since C++20 288 289 template<class T, output_range<const T&> R> 290 constexpr borrowed_iterator_t<R> ranges::fill(R&& r, const T& value); // since C++20 291 292 template<class T, output_iterator<const T&> O> 293 constexpr O ranges::fill_n(O first, iter_difference_t<O> n, const T& value); // since C++20 294 295 template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2, 296 class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> 297 requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2> 298 constexpr bool ranges::equal(I1 first1, S1 last1, I2 first2, S2 last2, 299 Pred pred = {}, 300 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 301 302 template<input_range R1, input_range R2, class Pred = ranges::equal_to, 303 class Proj1 = identity, class Proj2 = identity> 304 requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2> 305 constexpr bool ranges::equal(R1&& r1, R2&& r2, Pred pred = {}, 306 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 307 308 template<input_iterator I, sentinel_for<I> S, class Proj = identity, 309 indirect_unary_predicate<projected<I, Proj>> Pred> 310 constexpr bool ranges::all_of(I first, S last, Pred pred, Proj proj = {}); // since C++20 311 312 template<input_range R, class Proj = identity, 313 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred> 314 constexpr bool ranges::all_of(R&& r, Pred pred, Proj proj = {}); // since C++20 315 316 template<input_iterator I, sentinel_for<I> S, class Proj = identity, 317 indirect_unary_predicate<projected<I, Proj>> Pred> 318 constexpr bool ranges::any_of(I first, S last, Pred pred, Proj proj = {}); // since C++20 319 320 template<input_range R, class Proj = identity, 321 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred> 322 constexpr bool ranges::any_of(R&& r, Pred pred, Proj proj = {}); // since C++20 323 324 template<input_iterator I, sentinel_for<I> S, class Proj = identity, 325 indirect_unary_predicate<projected<I, Proj>> Pred> 326 constexpr bool ranges::none_of(I first, S last, Pred pred, Proj proj = {}); // since C++20 327 328 template<input_range R, class Proj = identity, 329 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred> 330 constexpr bool ranges::none_of(R&& r, Pred pred, Proj proj = {}); // since C++20 331 332 template<forward_iterator I, sentinel_for<I> S, class Proj = identity, 333 indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less> 334 constexpr bool ranges::is_sorted(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20 335 336 template<forward_range R, class Proj = identity, 337 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less> 338 constexpr bool ranges::is_sorted(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 339 340 template<forward_iterator I, sentinel_for<I> S, class Proj = identity, 341 indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less> 342 constexpr I ranges::is_sorted_until(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20 343 344 template<forward_range R, class Proj = identity, 345 indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less> 346 constexpr borrowed_iterator_t<R> 347 ranges::is_sorted_until(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 348 349 template<forward_iterator I, sentinel_for<I> S, class T, class Proj = identity, 350 indirect_strict_weak_order<const T*, projected<I, Proj>> Comp = ranges::less> 351 constexpr I upper_bound(I first, S last, const T& value, Comp comp = {}, Proj proj = {}); // since C++20 352 353 template<forward_range R, class T, class Proj = identity, 354 indirect_strict_weak_order<const T*, projected<iterator_t<R>, Proj>> Comp = 355 ranges::less> 356 constexpr borrowed_iterator_t<R> 357 upper_bound(R&& r, const T& value, Comp comp = {}, Proj proj = {}); // since C++20 358 359 template<forward_iterator I, sentinel_for<I> S, class T, class Proj = identity, 360 indirect_strict_weak_order<const T*, projected<I, Proj>> Comp = ranges::less> 361 constexpr I lower_bound(I first, S last, const T& value, Comp comp = {}, 362 Proj proj = {}); // since C++20 363 template<forward_range R, class T, class Proj = identity, 364 indirect_strict_weak_order<const T*, projected<iterator_t<R>, Proj>> Comp = 365 ranges::less> 366 constexpr borrowed_iterator_t<R> 367 lower_bound(R&& r, const T& value, Comp comp = {}, Proj proj = {}); // since C++20 368 369 template<forward_iterator I, sentinel_for<I> S, class T, class Proj = identity, 370 indirect_strict_weak_order<const T*, projected<I, Proj>> Comp = ranges::less> 371 constexpr bool binary_search(I first, S last, const T& value, Comp comp = {}, 372 Proj proj = {}); // since C++20 373 374 template<forward_range R, class T, class Proj = identity, 375 indirect_strict_weak_order<const T*, projected<iterator_t<R>, Proj>> Comp = 376 ranges::less> 377 constexpr bool binary_search(R&& r, const T& value, Comp comp = {}, 378 Proj proj = {}); // since C++20 379 template<input_iterator I1, sentinel_for<I1> S1, forward_iterator I2, sentinel_for<I2> S2, 380 class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> 381 requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2> 382 constexpr I1 ranges::find_first_of(I1 first1, S1 last1, I2 first2, S2 last2, 383 Pred pred = {}, 384 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 385 386 template<input_range R1, forward_range R2, 387 class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> 388 requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2> 389 constexpr borrowed_iterator_t<R1> 390 ranges::find_first_of(R1&& r1, R2&& r2, 391 Pred pred = {}, 392 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 393 394 template<forward_iterator I, sentinel_for<I> S, class Proj = identity, 395 indirect_binary_predicate<projected<I, Proj>, 396 projected<I, Proj>> Pred = ranges::equal_to> 397 constexpr I ranges::adjacent_find(I first, S last, Pred pred = {}, Proj proj = {}); // since C+20 398 399 template<forward_range R, class Proj = identity, 400 indirect_binary_predicate<projected<iterator_t<R>, Proj>, 401 projected<iterator_t<R>, Proj>> Pred = ranges::equal_to> 402 constexpr borrowed_iterator_t<R> ranges::adjacent_find(R&& r, Pred pred = {}, Proj proj = {}); // since C++20 403 404} 405 406 constexpr bool // constexpr in C++20 407 all_of(InputIterator first, InputIterator last, Predicate pred); 408 409template <class InputIterator, class Predicate> 410 constexpr bool // constexpr in C++20 411 any_of(InputIterator first, InputIterator last, Predicate pred); 412 413template <class InputIterator, class Predicate> 414 constexpr bool // constexpr in C++20 415 none_of(InputIterator first, InputIterator last, Predicate pred); 416 417template <class InputIterator, class Function> 418 constexpr Function // constexpr in C++20 419 for_each(InputIterator first, InputIterator last, Function f); 420 421template<class InputIterator, class Size, class Function> 422 constexpr InputIterator // constexpr in C++20 423 for_each_n(InputIterator first, Size n, Function f); // C++17 424 425template <class InputIterator, class T> 426 constexpr InputIterator // constexpr in C++20 427 find(InputIterator first, InputIterator last, const T& value); 428 429template <class InputIterator, class Predicate> 430 constexpr InputIterator // constexpr in C++20 431 find_if(InputIterator first, InputIterator last, Predicate pred); 432 433template<class InputIterator, class Predicate> 434 constexpr InputIterator // constexpr in C++20 435 find_if_not(InputIterator first, InputIterator last, Predicate pred); 436 437template <class ForwardIterator1, class ForwardIterator2> 438 constexpr ForwardIterator1 // constexpr in C++20 439 find_end(ForwardIterator1 first1, ForwardIterator1 last1, 440 ForwardIterator2 first2, ForwardIterator2 last2); 441 442template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate> 443 constexpr ForwardIterator1 // constexpr in C++20 444 find_end(ForwardIterator1 first1, ForwardIterator1 last1, 445 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred); 446 447template <class ForwardIterator1, class ForwardIterator2> 448 constexpr ForwardIterator1 // constexpr in C++20 449 find_first_of(ForwardIterator1 first1, ForwardIterator1 last1, 450 ForwardIterator2 first2, ForwardIterator2 last2); 451 452template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate> 453 constexpr ForwardIterator1 // constexpr in C++20 454 find_first_of(ForwardIterator1 first1, ForwardIterator1 last1, 455 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred); 456 457template <class ForwardIterator> 458 constexpr ForwardIterator // constexpr in C++20 459 adjacent_find(ForwardIterator first, ForwardIterator last); 460 461template <class ForwardIterator, class BinaryPredicate> 462 constexpr ForwardIterator // constexpr in C++20 463 adjacent_find(ForwardIterator first, ForwardIterator last, BinaryPredicate pred); 464 465template <class InputIterator, class T> 466 constexpr typename iterator_traits<InputIterator>::difference_type // constexpr in C++20 467 count(InputIterator first, InputIterator last, const T& value); 468 469template <class InputIterator, class Predicate> 470 constexpr typename iterator_traits<InputIterator>::difference_type // constexpr in C++20 471 count_if(InputIterator first, InputIterator last, Predicate pred); 472 473template <class InputIterator1, class InputIterator2> 474 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20 475 mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2); 476 477template <class InputIterator1, class InputIterator2> 478 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20 479 mismatch(InputIterator1 first1, InputIterator1 last1, 480 InputIterator2 first2, InputIterator2 last2); // **C++14** 481 482template <class InputIterator1, class InputIterator2, class BinaryPredicate> 483 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20 484 mismatch(InputIterator1 first1, InputIterator1 last1, 485 InputIterator2 first2, BinaryPredicate pred); 486 487template <class InputIterator1, class InputIterator2, class BinaryPredicate> 488 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20 489 mismatch(InputIterator1 first1, InputIterator1 last1, 490 InputIterator2 first2, InputIterator2 last2, 491 BinaryPredicate pred); // **C++14** 492 493template <class InputIterator1, class InputIterator2> 494 constexpr bool // constexpr in C++20 495 equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2); 496 497template <class InputIterator1, class InputIterator2> 498 constexpr bool // constexpr in C++20 499 equal(InputIterator1 first1, InputIterator1 last1, 500 InputIterator2 first2, InputIterator2 last2); // **C++14** 501 502template <class InputIterator1, class InputIterator2, class BinaryPredicate> 503 constexpr bool // constexpr in C++20 504 equal(InputIterator1 first1, InputIterator1 last1, 505 InputIterator2 first2, BinaryPredicate pred); 506 507template <class InputIterator1, class InputIterator2, class BinaryPredicate> 508 constexpr bool // constexpr in C++20 509 equal(InputIterator1 first1, InputIterator1 last1, 510 InputIterator2 first2, InputIterator2 last2, 511 BinaryPredicate pred); // **C++14** 512 513template<class ForwardIterator1, class ForwardIterator2> 514 constexpr bool // constexpr in C++20 515 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1, 516 ForwardIterator2 first2); 517 518template<class ForwardIterator1, class ForwardIterator2> 519 constexpr bool // constexpr in C++20 520 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1, 521 ForwardIterator2 first2, ForwardIterator2 last2); // **C++14** 522 523template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate> 524 constexpr bool // constexpr in C++20 525 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1, 526 ForwardIterator2 first2, BinaryPredicate pred); 527 528template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate> 529 constexpr bool // constexpr in C++20 530 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1, 531 ForwardIterator2 first2, ForwardIterator2 last2, 532 BinaryPredicate pred); // **C++14** 533 534template <class ForwardIterator1, class ForwardIterator2> 535 constexpr ForwardIterator1 // constexpr in C++20 536 search(ForwardIterator1 first1, ForwardIterator1 last1, 537 ForwardIterator2 first2, ForwardIterator2 last2); 538 539template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate> 540 constexpr ForwardIterator1 // constexpr in C++20 541 search(ForwardIterator1 first1, ForwardIterator1 last1, 542 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred); 543 544template <class ForwardIterator, class Size, class T> 545 constexpr ForwardIterator // constexpr in C++20 546 search_n(ForwardIterator first, ForwardIterator last, Size count, const T& value); 547 548template <class ForwardIterator, class Size, class T, class BinaryPredicate> 549 constexpr ForwardIterator // constexpr in C++20 550 search_n(ForwardIterator first, ForwardIterator last, 551 Size count, const T& value, BinaryPredicate pred); 552 553template <class InputIterator, class OutputIterator> 554 constexpr OutputIterator // constexpr in C++20 555 copy(InputIterator first, InputIterator last, OutputIterator result); 556 557template<class InputIterator, class OutputIterator, class Predicate> 558 constexpr OutputIterator // constexpr in C++20 559 copy_if(InputIterator first, InputIterator last, 560 OutputIterator result, Predicate pred); 561 562template<class InputIterator, class Size, class OutputIterator> 563 constexpr OutputIterator // constexpr in C++20 564 copy_n(InputIterator first, Size n, OutputIterator result); 565 566template <class BidirectionalIterator1, class BidirectionalIterator2> 567 constexpr BidirectionalIterator2 // constexpr in C++20 568 copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last, 569 BidirectionalIterator2 result); 570 571template <class ForwardIterator1, class ForwardIterator2> 572 constexpr ForwardIterator2 // constexpr in C++20 573 swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2); 574 575template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2> 576 requires indirectly_swappable<I1, I2> 577 constexpr ranges::swap_ranges_result<I1, I2> 578 ranges::swap_ranges(I1 first1, S1 last1, I2 first2, S2 last2); 579 580template<input_range R1, input_range R2> 581 requires indirectly_swappable<iterator_t<R1>, iterator_t<R2>> 582 constexpr ranges::swap_ranges_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>> 583 ranges::swap_ranges(R1&& r1, R2&& r2); 584 585template <class ForwardIterator1, class ForwardIterator2> 586 constexpr void // constexpr in C++20 587 iter_swap(ForwardIterator1 a, ForwardIterator2 b); 588 589template <class InputIterator, class OutputIterator, class UnaryOperation> 590 constexpr OutputIterator // constexpr in C++20 591 transform(InputIterator first, InputIterator last, OutputIterator result, UnaryOperation op); 592 593template <class InputIterator1, class InputIterator2, class OutputIterator, class BinaryOperation> 594 constexpr OutputIterator // constexpr in C++20 595 transform(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, 596 OutputIterator result, BinaryOperation binary_op); 597 598template <class ForwardIterator, class T> 599 constexpr void // constexpr in C++20 600 replace(ForwardIterator first, ForwardIterator last, const T& old_value, const T& new_value); 601 602template <class ForwardIterator, class Predicate, class T> 603 constexpr void // constexpr in C++20 604 replace_if(ForwardIterator first, ForwardIterator last, Predicate pred, const T& new_value); 605 606template <class InputIterator, class OutputIterator, class T> 607 constexpr OutputIterator // constexpr in C++20 608 replace_copy(InputIterator first, InputIterator last, OutputIterator result, 609 const T& old_value, const T& new_value); 610 611template <class InputIterator, class OutputIterator, class Predicate, class T> 612 constexpr OutputIterator // constexpr in C++20 613 replace_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred, const T& new_value); 614 615template <class ForwardIterator, class T> 616 constexpr void // constexpr in C++20 617 fill(ForwardIterator first, ForwardIterator last, const T& value); 618 619template <class OutputIterator, class Size, class T> 620 constexpr OutputIterator // constexpr in C++20 621 fill_n(OutputIterator first, Size n, const T& value); 622 623template <class ForwardIterator, class Generator> 624 constexpr void // constexpr in C++20 625 generate(ForwardIterator first, ForwardIterator last, Generator gen); 626 627template <class OutputIterator, class Size, class Generator> 628 constexpr OutputIterator // constexpr in C++20 629 generate_n(OutputIterator first, Size n, Generator gen); 630 631template <class ForwardIterator, class T> 632 constexpr ForwardIterator // constexpr in C++20 633 remove(ForwardIterator first, ForwardIterator last, const T& value); 634 635template <class ForwardIterator, class Predicate> 636 constexpr ForwardIterator // constexpr in C++20 637 remove_if(ForwardIterator first, ForwardIterator last, Predicate pred); 638 639template <class InputIterator, class OutputIterator, class T> 640 constexpr OutputIterator // constexpr in C++20 641 remove_copy(InputIterator first, InputIterator last, OutputIterator result, const T& value); 642 643template <class InputIterator, class OutputIterator, class Predicate> 644 constexpr OutputIterator // constexpr in C++20 645 remove_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred); 646 647template <class ForwardIterator> 648 constexpr ForwardIterator // constexpr in C++20 649 unique(ForwardIterator first, ForwardIterator last); 650 651template <class ForwardIterator, class BinaryPredicate> 652 constexpr ForwardIterator // constexpr in C++20 653 unique(ForwardIterator first, ForwardIterator last, BinaryPredicate pred); 654 655template <class InputIterator, class OutputIterator> 656 constexpr OutputIterator // constexpr in C++20 657 unique_copy(InputIterator first, InputIterator last, OutputIterator result); 658 659template <class InputIterator, class OutputIterator, class BinaryPredicate> 660 constexpr OutputIterator // constexpr in C++20 661 unique_copy(InputIterator first, InputIterator last, OutputIterator result, BinaryPredicate pred); 662 663template <class BidirectionalIterator> 664 constexpr void // constexpr in C++20 665 reverse(BidirectionalIterator first, BidirectionalIterator last); 666 667template <class BidirectionalIterator, class OutputIterator> 668 constexpr OutputIterator // constexpr in C++20 669 reverse_copy(BidirectionalIterator first, BidirectionalIterator last, OutputIterator result); 670 671template <class ForwardIterator> 672 constexpr ForwardIterator // constexpr in C++20 673 rotate(ForwardIterator first, ForwardIterator middle, ForwardIterator last); 674 675template <class ForwardIterator, class OutputIterator> 676 constexpr OutputIterator // constexpr in C++20 677 rotate_copy(ForwardIterator first, ForwardIterator middle, ForwardIterator last, OutputIterator result); 678 679template <class RandomAccessIterator> 680 void 681 random_shuffle(RandomAccessIterator first, RandomAccessIterator last); // deprecated in C++14, removed in C++17 682 683template <class RandomAccessIterator, class RandomNumberGenerator> 684 void 685 random_shuffle(RandomAccessIterator first, RandomAccessIterator last, 686 RandomNumberGenerator& rand); // deprecated in C++14, removed in C++17 687 688template<class PopulationIterator, class SampleIterator, 689 class Distance, class UniformRandomBitGenerator> 690 SampleIterator sample(PopulationIterator first, PopulationIterator last, 691 SampleIterator out, Distance n, 692 UniformRandomBitGenerator&& g); // C++17 693 694template<class RandomAccessIterator, class UniformRandomNumberGenerator> 695 void shuffle(RandomAccessIterator first, RandomAccessIterator last, 696 UniformRandomNumberGenerator&& g); 697 698template<class ForwardIterator> 699 constexpr ForwardIterator 700 shift_left(ForwardIterator first, ForwardIterator last, 701 typename iterator_traits<ForwardIterator>::difference_type n); // C++20 702 703template<class ForwardIterator> 704 constexpr ForwardIterator 705 shift_right(ForwardIterator first, ForwardIterator last, 706 typename iterator_traits<ForwardIterator>::difference_type n); // C++20 707 708template <class InputIterator, class Predicate> 709 constexpr bool // constexpr in C++20 710 is_partitioned(InputIterator first, InputIterator last, Predicate pred); 711 712template <class ForwardIterator, class Predicate> 713 constexpr ForwardIterator // constexpr in C++20 714 partition(ForwardIterator first, ForwardIterator last, Predicate pred); 715 716template <class InputIterator, class OutputIterator1, 717 class OutputIterator2, class Predicate> 718 constexpr pair<OutputIterator1, OutputIterator2> // constexpr in C++20 719 partition_copy(InputIterator first, InputIterator last, 720 OutputIterator1 out_true, OutputIterator2 out_false, 721 Predicate pred); 722 723template <class ForwardIterator, class Predicate> 724 ForwardIterator 725 stable_partition(ForwardIterator first, ForwardIterator last, Predicate pred); 726 727template<class ForwardIterator, class Predicate> 728 constexpr ForwardIterator // constexpr in C++20 729 partition_point(ForwardIterator first, ForwardIterator last, Predicate pred); 730 731template <class ForwardIterator> 732 constexpr bool // constexpr in C++20 733 is_sorted(ForwardIterator first, ForwardIterator last); 734 735template <class ForwardIterator, class Compare> 736 constexpr bool // constexpr in C++20 737 is_sorted(ForwardIterator first, ForwardIterator last, Compare comp); 738 739template<class ForwardIterator> 740 constexpr ForwardIterator // constexpr in C++20 741 is_sorted_until(ForwardIterator first, ForwardIterator last); 742 743template <class ForwardIterator, class Compare> 744 constexpr ForwardIterator // constexpr in C++20 745 is_sorted_until(ForwardIterator first, ForwardIterator last, Compare comp); 746 747template <class RandomAccessIterator> 748 constexpr void // constexpr in C++20 749 sort(RandomAccessIterator first, RandomAccessIterator last); 750 751template <class RandomAccessIterator, class Compare> 752 constexpr void // constexpr in C++20 753 sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp); 754 755template <class RandomAccessIterator> 756 void 757 stable_sort(RandomAccessIterator first, RandomAccessIterator last); 758 759template <class RandomAccessIterator, class Compare> 760 void 761 stable_sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp); 762 763template <class RandomAccessIterator> 764 constexpr void // constexpr in C++20 765 partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last); 766 767template <class RandomAccessIterator, class Compare> 768 constexpr void // constexpr in C++20 769 partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last, Compare comp); 770 771template <class InputIterator, class RandomAccessIterator> 772 constexpr RandomAccessIterator // constexpr in C++20 773 partial_sort_copy(InputIterator first, InputIterator last, 774 RandomAccessIterator result_first, RandomAccessIterator result_last); 775 776template <class InputIterator, class RandomAccessIterator, class Compare> 777 constexpr RandomAccessIterator // constexpr in C++20 778 partial_sort_copy(InputIterator first, InputIterator last, 779 RandomAccessIterator result_first, RandomAccessIterator result_last, Compare comp); 780 781template <class RandomAccessIterator> 782 constexpr void // constexpr in C++20 783 nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last); 784 785template <class RandomAccessIterator, class Compare> 786 constexpr void // constexpr in C++20 787 nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last, Compare comp); 788 789template <class ForwardIterator, class T> 790 constexpr ForwardIterator // constexpr in C++20 791 lower_bound(ForwardIterator first, ForwardIterator last, const T& value); 792 793template <class ForwardIterator, class T, class Compare> 794 constexpr ForwardIterator // constexpr in C++20 795 lower_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp); 796 797template <class ForwardIterator, class T> 798 constexpr ForwardIterator // constexpr in C++20 799 upper_bound(ForwardIterator first, ForwardIterator last, const T& value); 800 801template <class ForwardIterator, class T, class Compare> 802 constexpr ForwardIterator // constexpr in C++20 803 upper_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp); 804 805template <class ForwardIterator, class T> 806 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++20 807 equal_range(ForwardIterator first, ForwardIterator last, const T& value); 808 809template <class ForwardIterator, class T, class Compare> 810 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++20 811 equal_range(ForwardIterator first, ForwardIterator last, const T& value, Compare comp); 812 813template <class ForwardIterator, class T> 814 constexpr bool // constexpr in C++20 815 binary_search(ForwardIterator first, ForwardIterator last, const T& value); 816 817template <class ForwardIterator, class T, class Compare> 818 constexpr bool // constexpr in C++20 819 binary_search(ForwardIterator first, ForwardIterator last, const T& value, Compare comp); 820 821template <class InputIterator1, class InputIterator2, class OutputIterator> 822 constexpr OutputIterator // constexpr in C++20 823 merge(InputIterator1 first1, InputIterator1 last1, 824 InputIterator2 first2, InputIterator2 last2, OutputIterator result); 825 826template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare> 827 constexpr OutputIterator // constexpr in C++20 828 merge(InputIterator1 first1, InputIterator1 last1, 829 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp); 830 831template <class BidirectionalIterator> 832 void 833 inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last); 834 835template <class BidirectionalIterator, class Compare> 836 void 837 inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last, Compare comp); 838 839template <class InputIterator1, class InputIterator2> 840 constexpr bool // constexpr in C++20 841 includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2); 842 843template <class InputIterator1, class InputIterator2, class Compare> 844 constexpr bool // constexpr in C++20 845 includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, Compare comp); 846 847template <class InputIterator1, class InputIterator2, class OutputIterator> 848 constexpr OutputIterator // constexpr in C++20 849 set_union(InputIterator1 first1, InputIterator1 last1, 850 InputIterator2 first2, InputIterator2 last2, OutputIterator result); 851 852template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare> 853 constexpr OutputIterator // constexpr in C++20 854 set_union(InputIterator1 first1, InputIterator1 last1, 855 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp); 856 857template <class InputIterator1, class InputIterator2, class OutputIterator> 858 constexpr OutputIterator // constexpr in C++20 859 set_intersection(InputIterator1 first1, InputIterator1 last1, 860 InputIterator2 first2, InputIterator2 last2, OutputIterator result); 861 862template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare> 863 constexpr OutputIterator // constexpr in C++20 864 set_intersection(InputIterator1 first1, InputIterator1 last1, 865 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp); 866 867template <class InputIterator1, class InputIterator2, class OutputIterator> 868 constexpr OutputIterator // constexpr in C++20 869 set_difference(InputIterator1 first1, InputIterator1 last1, 870 InputIterator2 first2, InputIterator2 last2, OutputIterator result); 871 872template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare> 873 constexpr OutputIterator // constexpr in C++20 874 set_difference(InputIterator1 first1, InputIterator1 last1, 875 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp); 876 877template <class InputIterator1, class InputIterator2, class OutputIterator> 878 constexpr OutputIterator // constexpr in C++20 879 set_symmetric_difference(InputIterator1 first1, InputIterator1 last1, 880 InputIterator2 first2, InputIterator2 last2, OutputIterator result); 881 882template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare> 883 constexpr OutputIterator // constexpr in C++20 884 set_symmetric_difference(InputIterator1 first1, InputIterator1 last1, 885 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp); 886 887template <class RandomAccessIterator> 888 constexpr void // constexpr in C++20 889 push_heap(RandomAccessIterator first, RandomAccessIterator last); 890 891template <class RandomAccessIterator, class Compare> 892 constexpr void // constexpr in C++20 893 push_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp); 894 895template <class RandomAccessIterator> 896 constexpr void // constexpr in C++20 897 pop_heap(RandomAccessIterator first, RandomAccessIterator last); 898 899template <class RandomAccessIterator, class Compare> 900 constexpr void // constexpr in C++20 901 pop_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp); 902 903template <class RandomAccessIterator> 904 constexpr void // constexpr in C++20 905 make_heap(RandomAccessIterator first, RandomAccessIterator last); 906 907template <class RandomAccessIterator, class Compare> 908 constexpr void // constexpr in C++20 909 make_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp); 910 911template <class RandomAccessIterator> 912 constexpr void // constexpr in C++20 913 sort_heap(RandomAccessIterator first, RandomAccessIterator last); 914 915template <class RandomAccessIterator, class Compare> 916 constexpr void // constexpr in C++20 917 sort_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp); 918 919template <class RandomAccessIterator> 920 constexpr bool // constexpr in C++20 921 is_heap(RandomAccessIterator first, RandomAccessiterator last); 922 923template <class RandomAccessIterator, class Compare> 924 constexpr bool // constexpr in C++20 925 is_heap(RandomAccessIterator first, RandomAccessiterator last, Compare comp); 926 927template <class RandomAccessIterator> 928 constexpr RandomAccessIterator // constexpr in C++20 929 is_heap_until(RandomAccessIterator first, RandomAccessiterator last); 930 931template <class RandomAccessIterator, class Compare> 932 constexpr RandomAccessIterator // constexpr in C++20 933 is_heap_until(RandomAccessIterator first, RandomAccessiterator last, Compare comp); 934 935template <class ForwardIterator> 936 constexpr ForwardIterator // constexpr in C++14 937 min_element(ForwardIterator first, ForwardIterator last); 938 939template <class ForwardIterator, class Compare> 940 constexpr ForwardIterator // constexpr in C++14 941 min_element(ForwardIterator first, ForwardIterator last, Compare comp); 942 943template <class T> 944 constexpr const T& // constexpr in C++14 945 min(const T& a, const T& b); 946 947template <class T, class Compare> 948 constexpr const T& // constexpr in C++14 949 min(const T& a, const T& b, Compare comp); 950 951template<class T> 952 constexpr T // constexpr in C++14 953 min(initializer_list<T> t); 954 955template<class T, class Compare> 956 constexpr T // constexpr in C++14 957 min(initializer_list<T> t, Compare comp); 958 959template<class T> 960 constexpr const T& clamp(const T& v, const T& lo, const T& hi); // C++17 961 962template<class T, class Compare> 963 constexpr const T& clamp(const T& v, const T& lo, const T& hi, Compare comp); // C++17 964 965template <class ForwardIterator> 966 constexpr ForwardIterator // constexpr in C++14 967 max_element(ForwardIterator first, ForwardIterator last); 968 969template <class ForwardIterator, class Compare> 970 constexpr ForwardIterator // constexpr in C++14 971 max_element(ForwardIterator first, ForwardIterator last, Compare comp); 972 973template <class T> 974 constexpr const T& // constexpr in C++14 975 max(const T& a, const T& b); 976 977template <class T, class Compare> 978 constexpr const T& // constexpr in C++14 979 max(const T& a, const T& b, Compare comp); 980 981template<class T> 982 constexpr T // constexpr in C++14 983 max(initializer_list<T> t); 984 985template<class T, class Compare> 986 constexpr T // constexpr in C++14 987 max(initializer_list<T> t, Compare comp); 988 989template<class ForwardIterator> 990 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++14 991 minmax_element(ForwardIterator first, ForwardIterator last); 992 993template<class ForwardIterator, class Compare> 994 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++14 995 minmax_element(ForwardIterator first, ForwardIterator last, Compare comp); 996 997template<class T> 998 constexpr pair<const T&, const T&> // constexpr in C++14 999 minmax(const T& a, const T& b); 1000 1001template<class T, class Compare> 1002 constexpr pair<const T&, const T&> // constexpr in C++14 1003 minmax(const T& a, const T& b, Compare comp); 1004 1005template<class T> 1006 constexpr pair<T, T> // constexpr in C++14 1007 minmax(initializer_list<T> t); 1008 1009template<class T, class Compare> 1010 constexpr pair<T, T> // constexpr in C++14 1011 minmax(initializer_list<T> t, Compare comp); 1012 1013template <class InputIterator1, class InputIterator2> 1014 constexpr bool // constexpr in C++20 1015 lexicographical_compare(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2); 1016 1017template <class InputIterator1, class InputIterator2, class Compare> 1018 constexpr bool // constexpr in C++20 1019 lexicographical_compare(InputIterator1 first1, InputIterator1 last1, 1020 InputIterator2 first2, InputIterator2 last2, Compare comp); 1021 1022template <class BidirectionalIterator> 1023 constexpr bool // constexpr in C++20 1024 next_permutation(BidirectionalIterator first, BidirectionalIterator last); 1025 1026template <class BidirectionalIterator, class Compare> 1027 constexpr bool // constexpr in C++20 1028 next_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp); 1029 1030template <class BidirectionalIterator> 1031 constexpr bool // constexpr in C++20 1032 prev_permutation(BidirectionalIterator first, BidirectionalIterator last); 1033 1034template <class BidirectionalIterator, class Compare> 1035 constexpr bool // constexpr in C++20 1036 prev_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp); 1037} // std 1038 1039*/ 1040 1041#include <__assert> // all public C++ headers provide the assertion handler 1042#include <__bits> 1043#include <__config> 1044#include <__debug> 1045#include <cstddef> 1046#include <cstring> 1047#include <initializer_list> 1048#include <iterator> 1049#include <memory> 1050#include <type_traits> 1051#include <version> 1052 1053#include <__algorithm/adjacent_find.h> 1054#include <__algorithm/all_of.h> 1055#include <__algorithm/any_of.h> 1056#include <__algorithm/binary_search.h> 1057#include <__algorithm/clamp.h> 1058#include <__algorithm/comp.h> 1059#include <__algorithm/comp_ref_type.h> 1060#include <__algorithm/copy.h> 1061#include <__algorithm/copy_backward.h> 1062#include <__algorithm/copy_if.h> 1063#include <__algorithm/copy_n.h> 1064#include <__algorithm/count.h> 1065#include <__algorithm/count_if.h> 1066#include <__algorithm/equal.h> 1067#include <__algorithm/equal_range.h> 1068#include <__algorithm/fill.h> 1069#include <__algorithm/fill_n.h> 1070#include <__algorithm/find.h> 1071#include <__algorithm/find_end.h> 1072#include <__algorithm/find_first_of.h> 1073#include <__algorithm/find_if.h> 1074#include <__algorithm/find_if_not.h> 1075#include <__algorithm/for_each.h> 1076#include <__algorithm/for_each_n.h> 1077#include <__algorithm/generate.h> 1078#include <__algorithm/generate_n.h> 1079#include <__algorithm/half_positive.h> 1080#include <__algorithm/in_found_result.h> 1081#include <__algorithm/in_fun_result.h> 1082#include <__algorithm/in_in_out_result.h> 1083#include <__algorithm/in_in_result.h> 1084#include <__algorithm/in_out_out_result.h> 1085#include <__algorithm/in_out_result.h> 1086#include <__algorithm/includes.h> 1087#include <__algorithm/inplace_merge.h> 1088#include <__algorithm/is_heap.h> 1089#include <__algorithm/is_heap_until.h> 1090#include <__algorithm/is_partitioned.h> 1091#include <__algorithm/is_permutation.h> 1092#include <__algorithm/is_sorted.h> 1093#include <__algorithm/is_sorted_until.h> 1094#include <__algorithm/iter_swap.h> 1095#include <__algorithm/lexicographical_compare.h> 1096#include <__algorithm/lower_bound.h> 1097#include <__algorithm/make_heap.h> 1098#include <__algorithm/max.h> 1099#include <__algorithm/max_element.h> 1100#include <__algorithm/merge.h> 1101#include <__algorithm/min.h> 1102#include <__algorithm/min_element.h> 1103#include <__algorithm/min_max_result.h> 1104#include <__algorithm/minmax.h> 1105#include <__algorithm/minmax_element.h> 1106#include <__algorithm/mismatch.h> 1107#include <__algorithm/move.h> 1108#include <__algorithm/move_backward.h> 1109#include <__algorithm/next_permutation.h> 1110#include <__algorithm/none_of.h> 1111#include <__algorithm/nth_element.h> 1112#include <__algorithm/partial_sort.h> 1113#include <__algorithm/partial_sort_copy.h> 1114#include <__algorithm/partition.h> 1115#include <__algorithm/partition_copy.h> 1116#include <__algorithm/partition_point.h> 1117#include <__algorithm/pop_heap.h> 1118#include <__algorithm/prev_permutation.h> 1119#include <__algorithm/push_heap.h> 1120#include <__algorithm/ranges_adjacent_find.h> 1121#include <__algorithm/ranges_all_of.h> 1122#include <__algorithm/ranges_any_of.h> 1123#include <__algorithm/ranges_binary_search.h> 1124#include <__algorithm/ranges_copy.h> 1125#include <__algorithm/ranges_copy_backward.h> 1126#include <__algorithm/ranges_copy_if.h> 1127#include <__algorithm/ranges_copy_n.h> 1128#include <__algorithm/ranges_count.h> 1129#include <__algorithm/ranges_count_if.h> 1130#include <__algorithm/ranges_equal.h> 1131#include <__algorithm/ranges_fill.h> 1132#include <__algorithm/ranges_fill_n.h> 1133#include <__algorithm/ranges_find.h> 1134#include <__algorithm/ranges_find_first_of.h> 1135#include <__algorithm/ranges_find_if.h> 1136#include <__algorithm/ranges_find_if_not.h> 1137#include <__algorithm/ranges_for_each.h> 1138#include <__algorithm/ranges_for_each_n.h> 1139#include <__algorithm/ranges_is_partitioned.h> 1140#include <__algorithm/ranges_is_sorted.h> 1141#include <__algorithm/ranges_is_sorted_until.h> 1142#include <__algorithm/ranges_lower_bound.h> 1143#include <__algorithm/ranges_max.h> 1144#include <__algorithm/ranges_max_element.h> 1145#include <__algorithm/ranges_min.h> 1146#include <__algorithm/ranges_min_element.h> 1147#include <__algorithm/ranges_minmax.h> 1148#include <__algorithm/ranges_minmax_element.h> 1149#include <__algorithm/ranges_mismatch.h> 1150#include <__algorithm/ranges_none_of.h> 1151#include <__algorithm/ranges_reverse.h> 1152#include <__algorithm/ranges_swap_ranges.h> 1153#include <__algorithm/ranges_transform.h> 1154#include <__algorithm/ranges_upper_bound.h> 1155#include <__algorithm/remove.h> 1156#include <__algorithm/remove_copy.h> 1157#include <__algorithm/remove_copy_if.h> 1158#include <__algorithm/remove_if.h> 1159#include <__algorithm/replace.h> 1160#include <__algorithm/replace_copy.h> 1161#include <__algorithm/replace_copy_if.h> 1162#include <__algorithm/replace_if.h> 1163#include <__algorithm/reverse.h> 1164#include <__algorithm/reverse_copy.h> 1165#include <__algorithm/rotate.h> 1166#include <__algorithm/rotate_copy.h> 1167#include <__algorithm/sample.h> 1168#include <__algorithm/search.h> 1169#include <__algorithm/search_n.h> 1170#include <__algorithm/set_difference.h> 1171#include <__algorithm/set_intersection.h> 1172#include <__algorithm/set_symmetric_difference.h> 1173#include <__algorithm/set_union.h> 1174#include <__algorithm/shift_left.h> 1175#include <__algorithm/shift_right.h> 1176#include <__algorithm/shuffle.h> 1177#include <__algorithm/sift_down.h> 1178#include <__algorithm/sort.h> 1179#include <__algorithm/sort_heap.h> 1180#include <__algorithm/stable_partition.h> 1181#include <__algorithm/stable_sort.h> 1182#include <__algorithm/swap_ranges.h> 1183#include <__algorithm/transform.h> 1184#include <__algorithm/unique.h> 1185#include <__algorithm/unique_copy.h> 1186#include <__algorithm/unwrap_iter.h> 1187#include <__algorithm/upper_bound.h> 1188 1189#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 1190# pragma GCC system_header 1191#endif 1192 1193#if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17 1194# include <__pstl_algorithm> 1195#endif 1196 1197#endif // _LIBCPP_ALGORITHM 1198