xref: /freebsd/contrib/llvm-project/libcxx/include/algorithm (revision bdd1243df58e60e85101c09001d9812a789b6bc4)
10b57cec5SDimitry Andric// -*- C++ -*-
2349cc55cSDimitry Andric//===----------------------------------------------------------------------===//
30b57cec5SDimitry Andric//
40b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
50b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information.
60b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
70b57cec5SDimitry Andric//
80b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
90b57cec5SDimitry Andric
100b57cec5SDimitry Andric#ifndef _LIBCPP_ALGORITHM
110b57cec5SDimitry Andric#define _LIBCPP_ALGORITHM
120b57cec5SDimitry Andric
130b57cec5SDimitry Andric/*
140b57cec5SDimitry Andric    algorithm synopsis
150b57cec5SDimitry Andric
160b57cec5SDimitry Andric#include <initializer_list>
170b57cec5SDimitry Andric
180b57cec5SDimitry Andricnamespace std
190b57cec5SDimitry Andric{
200b57cec5SDimitry Andric
2104eeddc0SDimitry Andricnamespace ranges {
2281ad6265SDimitry Andric
2381ad6265SDimitry Andric  // [algorithms.results], algorithm result types
2481ad6265SDimitry Andric  template <class I, class F>
2581ad6265SDimitry Andric    struct in_fun_result;     // since C++20
2681ad6265SDimitry Andric
2704eeddc0SDimitry Andric  template <class I1, class I2>
2804eeddc0SDimitry Andric    struct in_in_result;      // since C++20
291fd87a68SDimitry Andric
3081ad6265SDimitry Andric  template <class I, class O>
3181ad6265SDimitry Andric    struct in_out_result;  // since C++20
3281ad6265SDimitry Andric
331fd87a68SDimitry Andric  template <class I1, class I2, class O>
341fd87a68SDimitry Andric    struct in_in_out_result;  // since C++20
3581ad6265SDimitry Andric
3681ad6265SDimitry Andric  template <class I, class O1, class O2>
3781ad6265SDimitry Andric    struct in_out_out_result; // since C++20
3881ad6265SDimitry Andric
3981ad6265SDimitry Andric  template <class I1, class I2>
4081ad6265SDimitry Andric    struct min_max_result;    // since C++20
4181ad6265SDimitry Andric
4281ad6265SDimitry Andric  template <class I>
4381ad6265SDimitry Andric    struct in_found_result;   // since C++20
4481ad6265SDimitry Andric
4581ad6265SDimitry Andric  template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
4681ad6265SDimitry Andric    indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>             // since C++20
4781ad6265SDimitry Andric  constexpr I min_element(I first, S last, Comp comp = {}, Proj proj = {});
4881ad6265SDimitry Andric
4981ad6265SDimitry Andric  template<forward_range R, class Proj = identity,
5081ad6265SDimitry Andric    indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less> // since C++20
5181ad6265SDimitry Andric  constexpr borrowed_iterator_t<R> min_element(R&& r, Comp comp = {}, Proj proj = {});
5281ad6265SDimitry Andric
5381ad6265SDimitry Andric  template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
5481ad6265SDimitry Andric    indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
5581ad6265SDimitry Andric  constexpr I ranges::max_element(I first, S last, Comp comp = {}, Proj proj = {});                        // since C++20
5681ad6265SDimitry Andric
5781ad6265SDimitry Andric  template<forward_range R, class Proj = identity,
5881ad6265SDimitry Andric    indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
5981ad6265SDimitry Andric  constexpr borrowed_iterator_t<R> ranges::max_element(R&& r, Comp comp = {}, Proj proj = {});             // since C++20
6081ad6265SDimitry Andric
6181ad6265SDimitry Andric  template<class I1, class I2>
6281ad6265SDimitry Andric    using mismatch_result = in_in_result<I1, I2>;
6381ad6265SDimitry Andric
6481ad6265SDimitry Andric  template <input_iterator I1, sentinel_for<_I1> S1, input_iterator I2, sentinel_for<_I2> S2,
6581ad6265SDimitry Andric          class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
6681ad6265SDimitry Andric    requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
6781ad6265SDimitry Andric  constexpr mismatch_result<_I1, _I2>
6881ad6265SDimitry Andric  mismatch()(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}) // since C++20
6981ad6265SDimitry Andric
7081ad6265SDimitry Andric  template <input_range R1, input_range R2,
7181ad6265SDimitry Andric          class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
7281ad6265SDimitry Andric    requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
7381ad6265SDimitry Andric  constexpr mismatch_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>>
7481ad6265SDimitry Andric  mismatch(R1&& r1, R2&& r2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {})                           // since C++20
7581ad6265SDimitry Andric
7681ad6265SDimitry Andric    requires indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
7781ad6265SDimitry Andric    constexpr I find(I first, S last, const T& value, Proj proj = {});              // since C++20
7881ad6265SDimitry Andric
7981ad6265SDimitry Andric  template<input_range R, class T, class Proj = identity>
8081ad6265SDimitry Andric    requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*>
8181ad6265SDimitry Andric    constexpr borrowed_iterator_t<R>
8281ad6265SDimitry Andric      find(R&& r, const T& value, Proj proj = {});                                  // since C++20
8381ad6265SDimitry Andric
8481ad6265SDimitry Andric  template<input_iterator I, sentinel_for<I> S, class Proj = identity,
8581ad6265SDimitry Andric           indirect_unary_predicate<projected<I, Proj>> Pred>
8681ad6265SDimitry Andric    constexpr I find_if(I first, S last, Pred pred, Proj proj = {});                // since C++20
8781ad6265SDimitry Andric
8881ad6265SDimitry Andric  template<input_range R, class Proj = identity,
8981ad6265SDimitry Andric           indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
9081ad6265SDimitry Andric    constexpr borrowed_iterator_t<R>
9181ad6265SDimitry Andric      find_if(R&& r, Pred pred, Proj proj = {});                                    // since C++20
9281ad6265SDimitry Andric
9381ad6265SDimitry Andric  template<input_iterator I, sentinel_for<I> S, class Proj = identity,
9481ad6265SDimitry Andric           indirect_unary_predicate<projected<I, Proj>> Pred>
9581ad6265SDimitry Andric    constexpr I find_if_not(I first, S last, Pred pred, Proj proj = {});            // since C++20
9681ad6265SDimitry Andric
9781ad6265SDimitry Andric  template<input_range R, class Proj = identity,
9881ad6265SDimitry Andric           indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
9981ad6265SDimitry Andric    constexpr borrowed_iterator_t<R>
10081ad6265SDimitry Andric      find_if_not(R&& r, Pred pred, Proj proj = {});                                // since C++20
10181ad6265SDimitry Andric
10281ad6265SDimitry Andric  template<class T, class Proj = identity,
10381ad6265SDimitry Andric           indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
10481ad6265SDimitry Andric    constexpr const T& min(const T& a, const T& b, Comp comp = {}, Proj proj = {}); // since C++20
10581ad6265SDimitry Andric
10681ad6265SDimitry Andric  template<copyable T, class Proj = identity,
10781ad6265SDimitry Andric           indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
10881ad6265SDimitry Andric    constexpr T min(initializer_list<T> r, Comp comp = {}, Proj proj = {});         // since C++20
10981ad6265SDimitry Andric
11081ad6265SDimitry Andric template<input_range R, class Proj = identity,
11181ad6265SDimitry Andric          indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
11281ad6265SDimitry Andric   requires indirectly_copyable_storable<iterator_t<R>, range_value_t<R>*>
11381ad6265SDimitry Andric   constexpr range_value_t<R>
11481ad6265SDimitry Andric     min(R&& r, Comp comp = {}, Proj proj = {});                                    // since C++20
11581ad6265SDimitry Andric
11681ad6265SDimitry Andric  template<class T, class Proj = identity,
11781ad6265SDimitry Andric           indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
11881ad6265SDimitry Andric    constexpr const T& max(const T& a, const T& b, Comp comp = {}, Proj proj = {}); // since C++20
11981ad6265SDimitry Andric
12081ad6265SDimitry Andric  template<copyable T, class Proj = identity,
12181ad6265SDimitry Andric           indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
12281ad6265SDimitry Andric    constexpr T max(initializer_list<T> r, Comp comp = {}, Proj proj = {});         // since C++20
12381ad6265SDimitry Andric
12481ad6265SDimitry Andric  template<input_range R, class Proj = identity,
12581ad6265SDimitry Andric           indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
12681ad6265SDimitry Andric    requires indirectly_copyable_storable<iterator_t<R>, range_value_t<R>*>
12781ad6265SDimitry Andric    constexpr range_value_t<R>
12881ad6265SDimitry Andric      max(R&& r, Comp comp = {}, Proj proj = {});                                   // since C++20
12981ad6265SDimitry Andric
13081ad6265SDimitry Andric  template<class I, class O>
13181ad6265SDimitry Andric    using unary_transform_result = in_out_result<I, O>;                             // since C++20
13281ad6265SDimitry Andric
13381ad6265SDimitry Andric  template<class I1, class I2, class O>
13481ad6265SDimitry Andric    using binary_transform_result = in_in_out_result<I1, I2, O>;                    // since C++20
13581ad6265SDimitry Andric
13681ad6265SDimitry Andric  template<input_iterator I, sentinel_for<I> S, weakly_incrementable O,
13781ad6265SDimitry Andric           copy_constructible F, class Proj = identity>
13881ad6265SDimitry Andric    requires indirectly_writable<O, indirect_result_t<F&, projected<I, Proj>>>
13981ad6265SDimitry Andric    constexpr ranges::unary_transform_result<I, O>
14081ad6265SDimitry Andric      transform(I first1, S last1, O result, F op, Proj proj = {});                 // since C++20
14181ad6265SDimitry Andric
14281ad6265SDimitry Andric  template<input_range R, weakly_incrementable O, copy_constructible F,
14381ad6265SDimitry Andric           class Proj = identity>
14481ad6265SDimitry Andric    requires indirectly_writable<O, indirect_result_t<F&, projected<iterator_t<R>, Proj>>>
14581ad6265SDimitry Andric    constexpr ranges::unary_transform_result<borrowed_iterator_t<R>, O>
14681ad6265SDimitry Andric      transform(R&& r, O result, F op, Proj proj = {});                             // since C++20
14781ad6265SDimitry Andric
14881ad6265SDimitry Andric  template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
14981ad6265SDimitry Andric           weakly_incrementable O, copy_constructible F, class Proj1 = identity,
15081ad6265SDimitry Andric           class Proj2 = identity>
15181ad6265SDimitry Andric    requires indirectly_writable<O, indirect_result_t<F&, projected<I1, Proj1>,
15281ad6265SDimitry Andric                                           projected<I2, Proj2>>>
15381ad6265SDimitry Andric    constexpr ranges::binary_transform_result<I1, I2, O>
15481ad6265SDimitry Andric      transform(I1 first1, S1 last1, I2 first2, S2 last2, O result,
15581ad6265SDimitry Andric                        F binary_op, Proj1 proj1 = {}, Proj2 proj2 = {});           // since C++20
15681ad6265SDimitry Andric
15781ad6265SDimitry Andric  template<input_range R1, input_range R2, weakly_incrementable O,
15881ad6265SDimitry Andric           copy_constructible F, class Proj1 = identity, class Proj2 = identity>
15981ad6265SDimitry Andric    requires indirectly_writable<O, indirect_result_t<F&, projected<iterator_t<R1>, Proj1>,
16081ad6265SDimitry Andric                                           projected<iterator_t<R2>, Proj2>>>
16181ad6265SDimitry Andric    constexpr ranges::binary_transform_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>, O>
16281ad6265SDimitry Andric      transform(R1&& r1, R2&& r2, O result,
16381ad6265SDimitry Andric                        F binary_op, Proj1 proj1 = {}, Proj2 proj2 = {});           // since C++20
16481ad6265SDimitry Andric
16581ad6265SDimitry Andric  template<input_iterator I, sentinel_for<I> S, class T, class Proj = identity>
16681ad6265SDimitry Andric    requires indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
16781ad6265SDimitry Andric    constexpr iter_difference_t<I>
16881ad6265SDimitry Andric      count(I first, S last, const T& value, Proj proj = {});                       // since C++20
16981ad6265SDimitry Andric
17081ad6265SDimitry Andric  template<input_range R, class T, class Proj = identity>
17181ad6265SDimitry Andric    requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*>
17281ad6265SDimitry Andric    constexpr range_difference_t<R>
17381ad6265SDimitry Andric      count(R&& r, const T& value, Proj proj = {});                                 // since C++20
17481ad6265SDimitry Andric
17581ad6265SDimitry Andric  template<input_iterator I, sentinel_for<I> S, class Proj = identity,
17681ad6265SDimitry Andric           indirect_unary_predicate<projected<I, Proj>> Pred>
17781ad6265SDimitry Andric    constexpr iter_difference_t<I>
17881ad6265SDimitry Andric      count_if(I first, S last, Pred pred, Proj proj = {});                         // since C++20
17981ad6265SDimitry Andric
18081ad6265SDimitry Andric  template<input_range R, class Proj = identity,
18181ad6265SDimitry Andric           indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
18281ad6265SDimitry Andric    constexpr range_difference_t<R>
18381ad6265SDimitry Andric      count_if(R&& r, Pred pred, Proj proj = {});                                   // since C++20
18481ad6265SDimitry Andric
18581ad6265SDimitry Andric  template<class T>
18681ad6265SDimitry Andric  using minmax_result = min_max_result<T>;
18781ad6265SDimitry Andric
18881ad6265SDimitry Andric  template<class T, class Proj = identity,
18981ad6265SDimitry Andric           indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
19081ad6265SDimitry Andric    constexpr ranges::minmax_result<const T&>
19181ad6265SDimitry Andric      minmax(const T& a, const T& b, Comp comp = {}, Proj proj = {});                     // since C++20
19281ad6265SDimitry Andric
19381ad6265SDimitry Andric  template<copyable T, class Proj = identity,
19481ad6265SDimitry Andric           indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
19581ad6265SDimitry Andric    constexpr ranges::minmax_result<T>
19681ad6265SDimitry Andric      minmax(initializer_list<T> r, Comp comp = {}, Proj proj = {});                      // since C++20
19781ad6265SDimitry Andric
19881ad6265SDimitry Andric  template<input_range R, class Proj = identity,
19981ad6265SDimitry Andric           indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
20081ad6265SDimitry Andric    requires indirectly_copyable_storable<iterator_t<R>, range_value_t<R>*>
20181ad6265SDimitry Andric    constexpr ranges::minmax_result<range_value_t<R>>
20281ad6265SDimitry Andric      minmax(R&& r, Comp comp = {}, Proj proj = {});                                      // since C++20
20381ad6265SDimitry Andric
20481ad6265SDimitry Andric  template<class I>
20581ad6265SDimitry Andric  using minmax_element_result = min_max_result<I>;
20681ad6265SDimitry Andric
20781ad6265SDimitry Andric  template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
20881ad6265SDimitry Andric           indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
20981ad6265SDimitry Andric    constexpr ranges::minmax_element_result<I>
21081ad6265SDimitry Andric      minmax_element(I first, S last, Comp comp = {}, Proj proj = {});                    // since C++20
21181ad6265SDimitry Andric
21281ad6265SDimitry Andric  template<forward_range R, class Proj = identity,
21381ad6265SDimitry Andric           indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
21481ad6265SDimitry Andric    constexpr ranges::minmax_element_result<borrowed_iterator_t<R>>
21581ad6265SDimitry Andric      minmax_element(R&& r, Comp comp = {}, Proj proj = {});                              // since C++20
21681ad6265SDimitry Andric
21781ad6265SDimitry Andric  template<class I, class O>
21881ad6265SDimitry Andric    using copy_result = in_out_result<I, O>;                                              // since C++20
21981ad6265SDimitry Andric
22081ad6265SDimitry Andric  template<class I, class O>
22181ad6265SDimitry Andric    using copy_n_result = in_out_result<I, O>;                                            // since C++20
22281ad6265SDimitry Andric
22381ad6265SDimitry Andric  template<class I, class O>
22481ad6265SDimitry Andric    using copy_if_result = in_out_result<I, O>;                                             // since C++20
22581ad6265SDimitry Andric
22681ad6265SDimitry Andric  template<class I1, class I2>
22781ad6265SDimitry Andric    using copy_backward_result = in_out_result<I1, I2>;                                     // since C++20
22881ad6265SDimitry Andric
22981ad6265SDimitry Andric  template<input_iterator I, sentinel_for<I> S, weakly_incrementable O>
23081ad6265SDimitry Andric    requires indirectly_copyable<I, O>
23181ad6265SDimitry Andric    constexpr ranges::copy_result<I, O> ranges::copy(I first, S last, O result);            // since C++20
23281ad6265SDimitry Andric
23381ad6265SDimitry Andric  template<input_range R, weakly_incrementable O>
23481ad6265SDimitry Andric    requires indirectly_copyable<iterator_t<R>, O>
23581ad6265SDimitry Andric    constexpr ranges::copy_result<borrowed_iterator_t<R>, O> ranges::copy(R&& r, O result); // since C++20
23681ad6265SDimitry Andric
23781ad6265SDimitry Andric  template<input_iterator I, weakly_incrementable O>
23881ad6265SDimitry Andric    requires indirectly_copyable<I, O>
23981ad6265SDimitry Andric    constexpr ranges::copy_n_result<I, O>
24081ad6265SDimitry Andric      ranges::copy_n(I first, iter_difference_t<I> n, O result);                            // since C++20
24181ad6265SDimitry Andric
24281ad6265SDimitry Andric  template<input_iterator I, sentinel_for<I> S, weakly_incrementable O, class Proj = identity,
24381ad6265SDimitry Andric           indirect_unary_predicate<projected<I, Proj>> Pred>
24481ad6265SDimitry Andric    requires indirectly_copyable<I, O>
24581ad6265SDimitry Andric    constexpr ranges::copy_if_result<I, O>
24681ad6265SDimitry Andric      ranges::copy_if(I first, S last, O result, Pred pred, Proj proj = {});                // since C++20
24781ad6265SDimitry Andric
24881ad6265SDimitry Andric  template<input_range R, weakly_incrementable O, class Proj = identity,
24981ad6265SDimitry Andric           indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
25081ad6265SDimitry Andric    requires indirectly_copyable<iterator_t<R>, O>
25181ad6265SDimitry Andric    constexpr ranges::copy_if_result<borrowed_iterator_t<R>, O>
25281ad6265SDimitry Andric      ranges::copy_if(R&& r, O result, Pred pred, Proj proj = {});                          // since C++20
25381ad6265SDimitry Andric
25481ad6265SDimitry Andric  template<bidirectional_iterator I1, sentinel_for<I1> S1, bidirectional_iterator I2>
25581ad6265SDimitry Andric    requires indirectly_copyable<I1, I2>
25681ad6265SDimitry Andric    constexpr ranges::copy_backward_result<I1, I2>
25781ad6265SDimitry Andric      ranges::copy_backward(I1 first, S1 last, I2 result);                                  // since C++20
25881ad6265SDimitry Andric
25981ad6265SDimitry Andric  template<bidirectional_range R, bidirectional_iterator I>
26081ad6265SDimitry Andric    requires indirectly_copyable<iterator_t<R>, I>
26181ad6265SDimitry Andric    constexpr ranges::copy_backward_result<borrowed_iterator_t<R>, I>
26281ad6265SDimitry Andric      ranges::copy_backward(R&& r, I result);                                               // since C++20
26381ad6265SDimitry Andric
26481ad6265SDimitry Andric  template<class I, class F>
26581ad6265SDimitry Andric    using for_each_result = in_fun_result<I, F>;                                            // since C++20
26681ad6265SDimitry Andric
26781ad6265SDimitry Andric  template<input_iterator I, sentinel_for<I> S, class Proj = identity,
26881ad6265SDimitry Andric           indirectly_unary_invocable<projected<I, Proj>> Fun>
26981ad6265SDimitry Andric    constexpr ranges::for_each_result<I, Fun>
27081ad6265SDimitry Andric      ranges::for_each(I first, S last, Fun f, Proj proj = {});                             // since C++20
27181ad6265SDimitry Andric
27281ad6265SDimitry Andric  template<input_range R, class Proj = identity,
27381ad6265SDimitry Andric           indirectly_unary_invocable<projected<iterator_t<R>, Proj>> Fun>
27481ad6265SDimitry Andric    constexpr ranges::for_each_result<borrowed_iterator_t<R>, Fun>
27581ad6265SDimitry Andric      ranges::for_each(R&& r, Fun f, Proj proj = {});                                       // since C++20
27681ad6265SDimitry Andric
27781ad6265SDimitry Andric  template<input_iterator I, class Proj = identity,
27881ad6265SDimitry Andric           indirectly_unary_invocable<projected<I, Proj>> Fun>
27981ad6265SDimitry Andric    constexpr ranges::for_each_n_result<I, Fun>
28081ad6265SDimitry Andric      ranges::for_each_n(I first, iter_difference_t<I> n, Fun f, Proj proj = {});           // since C++20
28181ad6265SDimitry Andric
28281ad6265SDimitry Andric  template<input_iterator I, sentinel_for<I> S, class Proj = identity,
28381ad6265SDimitry Andric           indirect_unary_predicate<projected<I, Proj>> Pred>
28481ad6265SDimitry Andric    constexpr bool ranges::is_partitioned(I first, S last, Pred pred, Proj proj = {});      // since C++20
28581ad6265SDimitry Andric
28681ad6265SDimitry Andric  template<input_range R, class Proj = identity,
28781ad6265SDimitry Andric           indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
28881ad6265SDimitry Andric    constexpr bool ranges::is_partitioned(R&& r, Pred pred, Proj proj = {});                // since C++20
28981ad6265SDimitry Andric
290753f127fSDimitry Andric  template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less,
291753f127fSDimitry Andric          class Proj = identity>
292753f127fSDimitry Andric    requires sortable<I, Comp, Proj>
293753f127fSDimitry Andric    constexpr I
294753f127fSDimitry Andric      ranges::push_heap(I first, S last, Comp comp = {}, Proj proj = {});                   // since C++20
295753f127fSDimitry Andric
296753f127fSDimitry Andric  template<random_access_range R, class Comp = ranges::less, class Proj = identity>
297753f127fSDimitry Andric    requires sortable<iterator_t<R>, Comp, Proj>
298753f127fSDimitry Andric    constexpr borrowed_iterator_t<R>
299753f127fSDimitry Andric      ranges::push_heap(R&& r, Comp comp = {}, Proj proj = {});                             // since C++20
300753f127fSDimitry Andric
301753f127fSDimitry Andric  template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less,
302753f127fSDimitry Andric          class Proj = identity>
303753f127fSDimitry Andric    requires sortable<I, Comp, Proj>
304753f127fSDimitry Andric    constexpr I
305753f127fSDimitry Andric      ranges::pop_heap(I first, S last, Comp comp = {}, Proj proj = {});                    // since C++20
306753f127fSDimitry Andric
307753f127fSDimitry Andric  template<random_access_range R, class Comp = ranges::less, class Proj = identity>
308753f127fSDimitry Andric    requires sortable<iterator_t<R>, Comp, Proj>
309753f127fSDimitry Andric    constexpr borrowed_iterator_t<R>
310753f127fSDimitry Andric      ranges::pop_heap(R&& r, Comp comp = {}, Proj proj = {});                              // since C++20
311753f127fSDimitry Andric
312753f127fSDimitry Andric  template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less,
313753f127fSDimitry Andric          class Proj = identity>
314753f127fSDimitry Andric    requires sortable<I, Comp, Proj>
315753f127fSDimitry Andric    constexpr I
316753f127fSDimitry Andric      ranges::make_heap(I first, S last, Comp comp = {}, Proj proj = {});                   // since C++20
317753f127fSDimitry Andric
318753f127fSDimitry Andric  template<random_access_range R, class Comp = ranges::less, class Proj = identity>
319753f127fSDimitry Andric    requires sortable<iterator_t<R>, Comp, Proj>
320753f127fSDimitry Andric    constexpr borrowed_iterator_t<R>
321753f127fSDimitry Andric      ranges::make_heap(R&& r, Comp comp = {}, Proj proj = {});                             // since C++20
322753f127fSDimitry Andric
323753f127fSDimitry Andric  template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less,
324753f127fSDimitry Andric          class Proj = identity>
325753f127fSDimitry Andric    requires sortable<I, Comp, Proj>
326753f127fSDimitry Andric    constexpr I
327753f127fSDimitry Andric      ranges::sort_heap(I first, S last, Comp comp = {}, Proj proj = {});                   // since C++20
328753f127fSDimitry Andric
329753f127fSDimitry Andric  template<random_access_range R, class Comp = ranges::less, class Proj = identity>
330753f127fSDimitry Andric    requires sortable<iterator_t<R>, Comp, Proj>
331753f127fSDimitry Andric    constexpr borrowed_iterator_t<R>
332753f127fSDimitry Andric      ranges::sort_heap(R&& r, Comp comp = {}, Proj proj = {});                             // since C++20
333753f127fSDimitry Andric
334972a253aSDimitry Andric  template<random_access_iterator I, sentinel_for<I> S, class Proj = identity,
335972a253aSDimitry Andric            indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
336972a253aSDimitry Andric    constexpr bool is_heap(I first, S last, Comp comp = {}, Proj proj = {});                // Since C++20
337972a253aSDimitry Andric
338972a253aSDimitry Andric  template<random_access_range R, class Proj = identity,
339972a253aSDimitry Andric            indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
340972a253aSDimitry Andric    constexpr bool is_heap(R&& r, Comp comp = {}, Proj proj = {});                          // Since C++20
341972a253aSDimitry Andric
342972a253aSDimitry Andric  template<random_access_iterator I, sentinel_for<I> S, class Proj = identity,
343972a253aSDimitry Andric           indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
344972a253aSDimitry Andric    constexpr I is_heap_until(I first, S last, Comp comp = {}, Proj proj = {});             // Since C++20
345972a253aSDimitry Andric
346972a253aSDimitry Andric  template<random_access_range R, class Proj = identity,
347972a253aSDimitry Andric           indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
348972a253aSDimitry Andric    constexpr borrowed_iterator_t<R>
349972a253aSDimitry Andric      is_heap_until(R&& r, Comp comp = {}, Proj proj = {});                                 // Since C++20
350972a253aSDimitry Andric
35181ad6265SDimitry Andric  template<bidirectional_iterator I, sentinel_for<I> S>
35281ad6265SDimitry Andric    requires permutable<I>
35381ad6265SDimitry Andric    constexpr I ranges::reverse(I first, S last);                                           // since C++20
35481ad6265SDimitry Andric
35581ad6265SDimitry Andric  template<bidirectional_range R>
35681ad6265SDimitry Andric    requires permutable<iterator_t<R>>
35781ad6265SDimitry Andric    constexpr borrowed_iterator_t<R> ranges::reverse(R&& r);                                // since C++20
35881ad6265SDimitry Andric
35981ad6265SDimitry Andric  template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less,
36081ad6265SDimitry Andric            class Proj = identity>
36181ad6265SDimitry Andric    requires sortable<I, Comp, Proj>
36281ad6265SDimitry Andric    constexpr I
36381ad6265SDimitry Andric      ranges::sort(I first, S last, Comp comp = {}, Proj proj = {});                        // since C++20
36481ad6265SDimitry Andric
36581ad6265SDimitry Andric  template<random_access_range R, class Comp = ranges::less, class Proj = identity>
36681ad6265SDimitry Andric    requires sortable<iterator_t<R>, Comp, Proj>
36781ad6265SDimitry Andric    constexpr borrowed_iterator_t<R>
36881ad6265SDimitry Andric      ranges::sort(R&& r, Comp comp = {}, Proj proj = {});                                  // since C++20
36981ad6265SDimitry Andric
37081ad6265SDimitry Andric  template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less,
37181ad6265SDimitry Andric          class Proj = identity>
37281ad6265SDimitry Andric    requires sortable<I, Comp, Proj>
37381ad6265SDimitry Andric    I ranges::stable_sort(I first, S last, Comp comp = {}, Proj proj = {});                 // since C++20
37481ad6265SDimitry Andric
37581ad6265SDimitry Andric  template<random_access_range R, class Comp = ranges::less, class Proj = identity>
37681ad6265SDimitry Andric    requires sortable<iterator_t<R>, Comp, Proj>
37781ad6265SDimitry Andric    borrowed_iterator_t<R>
37881ad6265SDimitry Andric      ranges::stable_sort(R&& r, Comp comp = {}, Proj proj = {});                           // since C++20
37981ad6265SDimitry Andric
380fcaf7f86SDimitry Andric  template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less,
381fcaf7f86SDimitry Andric           class Proj = identity>
382fcaf7f86SDimitry Andric    requires sortable<I, Comp, Proj>
383fcaf7f86SDimitry Andric    constexpr I
384fcaf7f86SDimitry Andric      ranges::partial_sort(I first, I middle, S last, Comp comp = {}, Proj proj = {});      // since C++20
385fcaf7f86SDimitry Andric
386fcaf7f86SDimitry Andric  template<random_access_range R, class Comp = ranges::less, class Proj = identity>
387fcaf7f86SDimitry Andric    requires sortable<iterator_t<R>, Comp, Proj>
388fcaf7f86SDimitry Andric    constexpr borrowed_iterator_t<R>
389fcaf7f86SDimitry Andric      ranges::partial_sort(R&& r, iterator_t<R> middle, Comp comp = {}, Proj proj = {});    // since C++20
390fcaf7f86SDimitry Andric
39181ad6265SDimitry Andric  template<class T, output_iterator<const T&> O, sentinel_for<O> S>
39281ad6265SDimitry Andric    constexpr O ranges::fill(O first, S last, const T& value);                              // since C++20
39381ad6265SDimitry Andric
39481ad6265SDimitry Andric  template<class T, output_range<const T&> R>
39581ad6265SDimitry Andric    constexpr borrowed_iterator_t<R> ranges::fill(R&& r, const T& value);                   // since C++20
39681ad6265SDimitry Andric
39781ad6265SDimitry Andric  template<class T, output_iterator<const T&> O>
39881ad6265SDimitry Andric    constexpr O ranges::fill_n(O first, iter_difference_t<O> n, const T& value);            // since C++20
39981ad6265SDimitry Andric
400972a253aSDimitry Andric  template<input_or_output_iterator O, sentinel_for<O> S, copy_constructible F>
401972a253aSDimitry Andric    requires invocable<F&> && indirectly_writable<O, invoke_result_t<F&>>
402972a253aSDimitry Andric    constexpr O generate(O first, S last, F gen);                                           // Since C++20
403972a253aSDimitry Andric
404972a253aSDimitry Andric  template<class R, copy_constructible F>
405972a253aSDimitry Andric    requires invocable<F&> && output_range<R, invoke_result_t<F&>>
406972a253aSDimitry Andric    constexpr borrowed_iterator_t<R> generate(R&& r, F gen);                                // Since C++20
407972a253aSDimitry Andric
408972a253aSDimitry Andric  template<input_or_output_iterator O, copy_constructible F>
409972a253aSDimitry Andric    requires invocable<F&> && indirectly_writable<O, invoke_result_t<F&>>
410972a253aSDimitry Andric    constexpr O generate_n(O first, iter_difference_t<O> n, F gen);                         // Since C++20
411972a253aSDimitry Andric
41281ad6265SDimitry Andric template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
41381ad6265SDimitry Andric          class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
41481ad6265SDimitry Andric   requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
41581ad6265SDimitry Andric   constexpr bool ranges::equal(I1 first1, S1 last1, I2 first2, S2 last2,
41681ad6265SDimitry Andric                                Pred pred = {},
41781ad6265SDimitry Andric                                Proj1 proj1 = {}, Proj2 proj2 = {});                        // since C++20
41881ad6265SDimitry Andric
41981ad6265SDimitry Andric template<input_range R1, input_range R2, class Pred = ranges::equal_to,
42081ad6265SDimitry Andric          class Proj1 = identity, class Proj2 = identity>
42181ad6265SDimitry Andric   requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
42281ad6265SDimitry Andric   constexpr bool ranges::equal(R1&& r1, R2&& r2, Pred pred = {},
42381ad6265SDimitry Andric                                Proj1 proj1 = {}, Proj2 proj2 = {});                        // since C++20
42481ad6265SDimitry Andric
42581ad6265SDimitry Andric  template<input_iterator I, sentinel_for<I> S, class Proj = identity,
42681ad6265SDimitry Andric           indirect_unary_predicate<projected<I, Proj>> Pred>
42781ad6265SDimitry Andric    constexpr bool ranges::all_of(I first, S last, Pred pred, Proj proj = {});      // since C++20
42881ad6265SDimitry Andric
42981ad6265SDimitry Andric  template<input_range R, class Proj = identity,
43081ad6265SDimitry Andric           indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
43181ad6265SDimitry Andric    constexpr bool ranges::all_of(R&& r, Pred pred, Proj proj = {});                // since C++20
43281ad6265SDimitry Andric
43381ad6265SDimitry Andric  template<input_iterator I, sentinel_for<I> S, class Proj = identity,
43481ad6265SDimitry Andric           indirect_unary_predicate<projected<I, Proj>> Pred>
43581ad6265SDimitry Andric    constexpr bool ranges::any_of(I first, S last, Pred pred, Proj proj = {});      // since C++20
43681ad6265SDimitry Andric
43781ad6265SDimitry Andric  template<input_range R, class Proj = identity,
43881ad6265SDimitry Andric           indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
43981ad6265SDimitry Andric    constexpr bool ranges::any_of(R&& r, Pred pred, Proj proj = {});                // since C++20
44081ad6265SDimitry Andric
44181ad6265SDimitry Andric  template<input_iterator I, sentinel_for<I> S, class Proj = identity,
44281ad6265SDimitry Andric           indirect_unary_predicate<projected<I, Proj>> Pred>
44381ad6265SDimitry Andric    constexpr bool ranges::none_of(I first, S last, Pred pred, Proj proj = {});     // since C++20
44481ad6265SDimitry Andric
44581ad6265SDimitry Andric  template<input_range R, class Proj = identity,
44681ad6265SDimitry Andric           indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
44781ad6265SDimitry Andric    constexpr bool ranges::none_of(R&& r, Pred pred, Proj proj = {});               // since C++20
44881ad6265SDimitry Andric
44961cfbce3SDimitry Andric  template<input_iterator I1, sentinel_for<I1> S1,
45061cfbce3SDimitry Andric          random_access_iterator I2, sentinel_for<I2> S2,
45161cfbce3SDimitry Andric          class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity>
45261cfbce3SDimitry Andric    requires indirectly_copyable<I1, I2> && sortable<I2, Comp, Proj2> &&
45361cfbce3SDimitry Andric            indirect_strict_weak_order<Comp, projected<I1, Proj1>, projected<I2, Proj2>>
45461cfbce3SDimitry Andric    constexpr partial_sort_copy_result<I1, I2>
45561cfbce3SDimitry Andric      partial_sort_copy(I1 first, S1 last, I2 result_first, S2 result_last,
45661cfbce3SDimitry Andric                        Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {});        // Since C++20
45761cfbce3SDimitry Andric
45861cfbce3SDimitry Andric  template<input_range R1, random_access_range R2, class Comp = ranges::less,
45961cfbce3SDimitry Andric          class Proj1 = identity, class Proj2 = identity>
46061cfbce3SDimitry Andric    requires indirectly_copyable<iterator_t<R1>, iterator_t<R2>> &&
46161cfbce3SDimitry Andric            sortable<iterator_t<R2>, Comp, Proj2> &&
46261cfbce3SDimitry Andric            indirect_strict_weak_order<Comp, projected<iterator_t<R1>, Proj1>,
46361cfbce3SDimitry Andric                                        projected<iterator_t<R2>, Proj2>>
46461cfbce3SDimitry Andric    constexpr partial_sort_copy_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>>
46561cfbce3SDimitry Andric      partial_sort_copy(R1&& r, R2&& result_r, Comp comp = {},
46661cfbce3SDimitry Andric                        Proj1 proj1 = {}, Proj2 proj2 = {});                        // Since C++20
46761cfbce3SDimitry Andric
46881ad6265SDimitry Andric  template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
46981ad6265SDimitry Andric           indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
47081ad6265SDimitry Andric    constexpr bool ranges::is_sorted(I first, S last, Comp comp = {}, Proj proj = {});      // since C++20
47181ad6265SDimitry Andric
47281ad6265SDimitry Andric  template<forward_range R, class Proj = identity,
47381ad6265SDimitry Andric           indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
47481ad6265SDimitry Andric    constexpr bool ranges::is_sorted(R&& r, Comp comp = {}, Proj proj = {});                // since C++20
47581ad6265SDimitry Andric
47681ad6265SDimitry Andric  template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
47781ad6265SDimitry Andric           indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
47881ad6265SDimitry Andric    constexpr I ranges::is_sorted_until(I first, S last, Comp comp = {}, Proj proj = {});   // since C++20
47981ad6265SDimitry Andric
48081ad6265SDimitry Andric  template<forward_range R, class Proj = identity,
48181ad6265SDimitry Andric           indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
48281ad6265SDimitry Andric    constexpr borrowed_iterator_t<R>
48381ad6265SDimitry Andric      ranges::is_sorted_until(R&& r, Comp comp = {}, Proj proj = {});                       // since C++20
48481ad6265SDimitry Andric
485753f127fSDimitry Andric  template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less,
486753f127fSDimitry Andric          class Proj = identity>
487753f127fSDimitry Andric    requires sortable<I, Comp, Proj>
488753f127fSDimitry Andric    constexpr I
489753f127fSDimitry Andric      ranges::nth_element(I first, I nth, S last, Comp comp = {}, Proj proj = {});            // since C++20
490753f127fSDimitry Andric
491753f127fSDimitry Andric  template<random_access_range R, class Comp = ranges::less, class Proj = identity>
492753f127fSDimitry Andric    requires sortable<iterator_t<R>, Comp, Proj>
493753f127fSDimitry Andric    constexpr borrowed_iterator_t<R>
494753f127fSDimitry Andric      ranges::nth_element(R&& r, iterator_t<R> nth, Comp comp = {}, Proj proj = {});          // since C++20
495753f127fSDimitry Andric
49681ad6265SDimitry Andric  template<forward_iterator I, sentinel_for<I> S, class T, class Proj = identity,
49781ad6265SDimitry Andric           indirect_strict_weak_order<const T*, projected<I, Proj>> Comp = ranges::less>
49881ad6265SDimitry Andric    constexpr I upper_bound(I first, S last, const T& value, Comp comp = {}, Proj proj = {}); // since C++20
49981ad6265SDimitry Andric
50081ad6265SDimitry Andric  template<forward_range R, class T, class Proj = identity,
50181ad6265SDimitry Andric           indirect_strict_weak_order<const T*, projected<iterator_t<R>, Proj>> Comp =
50281ad6265SDimitry Andric             ranges::less>
50381ad6265SDimitry Andric    constexpr borrowed_iterator_t<R>
50481ad6265SDimitry Andric      upper_bound(R&& r, const T& value, Comp comp = {}, Proj proj = {});                     // since C++20
50581ad6265SDimitry Andric
50681ad6265SDimitry Andric  template<forward_iterator I, sentinel_for<I> S, class T, class Proj = identity,
50781ad6265SDimitry Andric           indirect_strict_weak_order<const T*, projected<I, Proj>> Comp = ranges::less>
50881ad6265SDimitry Andric    constexpr I lower_bound(I first, S last, const T& value, Comp comp = {},
50981ad6265SDimitry Andric                                    Proj proj = {});                                          // since C++20
51081ad6265SDimitry Andric  template<forward_range R, class T, class Proj = identity,
51181ad6265SDimitry Andric           indirect_strict_weak_order<const T*, projected<iterator_t<R>, Proj>> Comp =
51281ad6265SDimitry Andric             ranges::less>
51381ad6265SDimitry Andric    constexpr borrowed_iterator_t<R>
51481ad6265SDimitry Andric      lower_bound(R&& r, const T& value, Comp comp = {}, Proj proj = {});                     // since C++20
51581ad6265SDimitry Andric
51681ad6265SDimitry Andric  template<forward_iterator I, sentinel_for<I> S, class T, class Proj = identity,
51781ad6265SDimitry Andric           indirect_strict_weak_order<const T*, projected<I, Proj>> Comp = ranges::less>
51881ad6265SDimitry Andric    constexpr bool binary_search(I first, S last, const T& value, Comp comp = {},
51981ad6265SDimitry Andric                                         Proj proj = {});                                     // since C++20
52081ad6265SDimitry Andric
52181ad6265SDimitry Andric  template<forward_range R, class T, class Proj = identity,
52281ad6265SDimitry Andric           indirect_strict_weak_order<const T*, projected<iterator_t<R>, Proj>> Comp =
52381ad6265SDimitry Andric             ranges::less>
52481ad6265SDimitry Andric    constexpr bool binary_search(R&& r, const T& value, Comp comp = {},
52581ad6265SDimitry Andric                                         Proj proj = {});                                     // since C++20
526fcaf7f86SDimitry Andric
527fcaf7f86SDimitry Andric  template<permutable I, sentinel_for<I> S, class Proj = identity,
528fcaf7f86SDimitry Andric           indirect_unary_predicate<projected<I, Proj>> Pred>
529fcaf7f86SDimitry Andric    constexpr subrange<I>
530fcaf7f86SDimitry Andric      partition(I first, S last, Pred pred, Proj proj = {});                                  // Since C++20
531fcaf7f86SDimitry Andric
532fcaf7f86SDimitry Andric  template<forward_range R, class Proj = identity,
533fcaf7f86SDimitry Andric           indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
534fcaf7f86SDimitry Andric    requires permutable<iterator_t<R>>
535fcaf7f86SDimitry Andric    constexpr borrowed_subrange_t<R>
536fcaf7f86SDimitry Andric      partition(R&& r, Pred pred, Proj proj = {});                                            // Since C++20
537fcaf7f86SDimitry Andric
538fcaf7f86SDimitry Andric  template<bidirectional_iterator I, sentinel_for<I> S, class Proj = identity,
539fcaf7f86SDimitry Andric           indirect_unary_predicate<projected<I, Proj>> Pred>
540fcaf7f86SDimitry Andric    requires permutable<I>
541fcaf7f86SDimitry Andric    subrange<I> stable_partition(I first, S last, Pred pred, Proj proj = {});                 // Since C++20
542fcaf7f86SDimitry Andric
543fcaf7f86SDimitry Andric  template<bidirectional_range R, class Proj = identity,
544fcaf7f86SDimitry Andric           indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
545fcaf7f86SDimitry Andric    requires permutable<iterator_t<R>>
546fcaf7f86SDimitry Andric    borrowed_subrange_t<R> stable_partition(R&& r, Pred pred, Proj proj = {});                // Since C++20
547fcaf7f86SDimitry Andric
54881ad6265SDimitry Andric  template<input_iterator I1, sentinel_for<I1> S1, forward_iterator I2, sentinel_for<I2> S2,
54981ad6265SDimitry Andric           class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
55081ad6265SDimitry Andric    requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
55181ad6265SDimitry Andric    constexpr I1 ranges::find_first_of(I1 first1, S1 last1, I2 first2, S2 last2,
55281ad6265SDimitry Andric                                       Pred pred = {},
55381ad6265SDimitry Andric                                       Proj1 proj1 = {}, Proj2 proj2 = {});                 // since C++20
55481ad6265SDimitry Andric
55581ad6265SDimitry Andric  template<input_range R1, forward_range R2,
55681ad6265SDimitry Andric           class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
55781ad6265SDimitry Andric    requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
55881ad6265SDimitry Andric    constexpr borrowed_iterator_t<R1>
55981ad6265SDimitry Andric      ranges::find_first_of(R1&& r1, R2&& r2,
56081ad6265SDimitry Andric                            Pred pred = {},
56181ad6265SDimitry Andric                            Proj1 proj1 = {}, Proj2 proj2 = {});                            // since C++20
56281ad6265SDimitry Andric
56381ad6265SDimitry Andric  template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
56481ad6265SDimitry Andric           indirect_binary_predicate<projected<I, Proj>,
56581ad6265SDimitry Andric                                     projected<I, Proj>> Pred = ranges::equal_to>
56681ad6265SDimitry Andric    constexpr I ranges::adjacent_find(I first, S last, Pred pred = {}, Proj proj = {});     // since C+20
56781ad6265SDimitry Andric
56881ad6265SDimitry Andric  template<forward_range R, class Proj = identity,
56981ad6265SDimitry Andric           indirect_binary_predicate<projected<iterator_t<R>, Proj>,
57081ad6265SDimitry Andric                                     projected<iterator_t<R>, Proj>> Pred = ranges::equal_to>
57181ad6265SDimitry Andric    constexpr borrowed_iterator_t<R> ranges::adjacent_find(R&& r, Pred pred = {}, Proj proj = {});  // since C++20
57281ad6265SDimitry Andric
57381ad6265SDimitry Andric  template<input_iterator I, sentinel_for<I> S, class T1, class T2, class Proj = identity>
57481ad6265SDimitry Andric    requires indirectly_writable<I, const T2&> &&
57581ad6265SDimitry Andric             indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T1*>
57681ad6265SDimitry Andric    constexpr I
57781ad6265SDimitry Andric      ranges::replace(I first, S last, const T1& old_value, const T2& new_value, Proj proj = {});   // since C++20
57881ad6265SDimitry Andric
57981ad6265SDimitry Andric  template<input_range R, class T1, class T2, class Proj = identity>
58081ad6265SDimitry Andric    requires indirectly_writable<iterator_t<R>, const T2&> &&
58181ad6265SDimitry Andric             indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T1*>
58281ad6265SDimitry Andric    constexpr borrowed_iterator_t<R>
58381ad6265SDimitry Andric      ranges::replace(R&& r, const T1& old_value, const T2& new_value, Proj proj = {});             // since C++20
58481ad6265SDimitry Andric
58581ad6265SDimitry Andric  template<input_iterator I, sentinel_for<I> S, class T, class Proj = identity,
58681ad6265SDimitry Andric           indirect_unary_predicate<projected<I, Proj>> Pred>
58781ad6265SDimitry Andric    requires indirectly_writable<I, const T&>
58881ad6265SDimitry Andric    constexpr I ranges::replace_if(I first, S last, Pred pred, const T& new_value, Proj proj = {}); // since C++20
58981ad6265SDimitry Andric
59081ad6265SDimitry Andric  template<input_range R, class T, class Proj = identity,
59181ad6265SDimitry Andric           indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
59281ad6265SDimitry Andric    requires indirectly_writable<iterator_t<R>, const T&>
59381ad6265SDimitry Andric    constexpr borrowed_iterator_t<R>
59481ad6265SDimitry Andric      ranges::replace_if(R&& r, Pred pred, const T& new_value, Proj proj = {});                     // since C++20
59581ad6265SDimitry Andric
59661cfbce3SDimitry Andric  template<class T, class Proj = identity,
59761cfbce3SDimitry Andric           indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
59861cfbce3SDimitry Andric    constexpr const T&
59961cfbce3SDimitry Andric      ranges::clamp(const T& v, const T& lo, const T& hi, Comp comp = {}, Proj proj = {});          // since C++20
60061cfbce3SDimitry Andric
60181ad6265SDimitry Andric  template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
60281ad6265SDimitry Andric           class Proj1 = identity, class Proj2 = identity,
60381ad6265SDimitry Andric           indirect_strict_weak_order<projected<I1, Proj1>,
60481ad6265SDimitry Andric                                      projected<I2, Proj2>> Comp = ranges::less>
60581ad6265SDimitry Andric    constexpr bool
60681ad6265SDimitry Andric      ranges::lexicographical_compare(I1 first1, S1 last1, I2 first2, S2 last2,
60781ad6265SDimitry Andric                                      Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {});    // since C++20
60881ad6265SDimitry Andric
60981ad6265SDimitry Andric  template<input_range R1, input_range R2, class Proj1 = identity,
61081ad6265SDimitry Andric           class Proj2 = identity,
61181ad6265SDimitry Andric           indirect_strict_weak_order<projected<iterator_t<R1>, Proj1>,
61281ad6265SDimitry Andric                                      projected<iterator_t<R2>, Proj2>> Comp = ranges::less>
61381ad6265SDimitry Andric    constexpr bool
61481ad6265SDimitry Andric      ranges::lexicographical_compare(R1&& r1, R2&& r2, Comp comp = {},
61581ad6265SDimitry Andric                                      Proj1 proj1 = {}, Proj2 proj2 = {});                    // since C++20
61681ad6265SDimitry Andric
61781ad6265SDimitry Andric  template<bidirectional_iterator I1, sentinel_for<I1> S1, bidirectional_iterator I2>
61881ad6265SDimitry Andric    requires indirectly_movable<I1, I2>
61981ad6265SDimitry Andric    constexpr ranges::move_backward_result<I1, I2>
62081ad6265SDimitry Andric      ranges::move_backward(I1 first, S1 last, I2 result);                                          // since C++20
62181ad6265SDimitry Andric
62281ad6265SDimitry Andric  template<bidirectional_range R, bidirectional_iterator I>
62381ad6265SDimitry Andric    requires indirectly_movable<iterator_t<R>, I>
62481ad6265SDimitry Andric    constexpr ranges::move_backward_result<borrowed_iterator_t<R>, I>
62581ad6265SDimitry Andric      ranges::move_backward(R&& r, I result);                                                       // since C++20
62681ad6265SDimitry Andric
62781ad6265SDimitry Andric  template<input_iterator I, sentinel_for<I> S, weakly_incrementable O>
62881ad6265SDimitry Andric    requires indirectly_movable<I, O>
62981ad6265SDimitry Andric    constexpr ranges::move_result<I, O>
63081ad6265SDimitry Andric      ranges::move(I first, S last, O result);                                                      // since C++20
63181ad6265SDimitry Andric
63281ad6265SDimitry Andric  template<input_range R, weakly_incrementable O>
63381ad6265SDimitry Andric    requires indirectly_movable<iterator_t<R>, O>
63481ad6265SDimitry Andric    constexpr ranges::move_result<borrowed_iterator_t<R>, O>
63581ad6265SDimitry Andric      ranges::move(R&& r, O result);                                                                // since C++20
63681ad6265SDimitry Andric
637fcaf7f86SDimitry Andric  template<class I, class O1, class O2>
638fcaf7f86SDimitry Andric      using partition_copy_result = in_out_out_result<I, O1, O2>;                                   // since C++20
639fcaf7f86SDimitry Andric
640fcaf7f86SDimitry Andric  template<input_iterator I, sentinel_for<I> S,
641fcaf7f86SDimitry Andric          weakly_incrementable O1, weakly_incrementable O2,
642fcaf7f86SDimitry Andric          class Proj = identity, indirect_unary_predicate<projected<I, Proj>> Pred>
643fcaf7f86SDimitry Andric    requires indirectly_copyable<I, O1> && indirectly_copyable<I, O2>
644fcaf7f86SDimitry Andric    constexpr partition_copy_result<I, O1, O2>
645fcaf7f86SDimitry Andric      partition_copy(I first, S last, O1 out_true, O2 out_false, Pred pred,
646fcaf7f86SDimitry Andric                    Proj proj = {});                                                                // Since C++20
647fcaf7f86SDimitry Andric
648fcaf7f86SDimitry Andric  template<input_range R, weakly_incrementable O1, weakly_incrementable O2,
649fcaf7f86SDimitry Andric          class Proj = identity,
650fcaf7f86SDimitry Andric          indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
651fcaf7f86SDimitry Andric    requires indirectly_copyable<iterator_t<R>, O1> &&
652fcaf7f86SDimitry Andric            indirectly_copyable<iterator_t<R>, O2>
653fcaf7f86SDimitry Andric    constexpr partition_copy_result<borrowed_iterator_t<R>, O1, O2>
654fcaf7f86SDimitry Andric      partition_copy(R&& r, O1 out_true, O2 out_false, Pred pred, Proj proj = {});                  // Since C++20
655fcaf7f86SDimitry Andric
656fcaf7f86SDimitry Andric  template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
657fcaf7f86SDimitry Andric           indirect_unary_predicate<projected<I, Proj>> Pred>
658fcaf7f86SDimitry Andric    constexpr I partition_point(I first, S last, Pred pred, Proj proj = {});                        // Since C++20
659fcaf7f86SDimitry Andric
660fcaf7f86SDimitry Andric  template<forward_range R, class Proj = identity,
661fcaf7f86SDimitry Andric           indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
662fcaf7f86SDimitry Andric    constexpr borrowed_iterator_t<R>
663fcaf7f86SDimitry Andric      partition_point(R&& r, Pred pred, Proj proj = {});                                            // Since C++20
664fcaf7f86SDimitry Andric
665753f127fSDimitry Andric  template<class I1, class I2, class O>
666753f127fSDimitry Andric    using merge_result = in_in_out_result<I1, I2, O>;                                               // since C++20
667753f127fSDimitry Andric
668753f127fSDimitry Andric  template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
669753f127fSDimitry Andric           weakly_incrementable O, class Comp = ranges::less, class Proj1 = identity,
670753f127fSDimitry Andric           class Proj2 = identity>
671753f127fSDimitry Andric    requires mergeable<I1, I2, O, Comp, Proj1, Proj2>
672753f127fSDimitry Andric    constexpr merge_result<I1, I2, O>
673753f127fSDimitry Andric      merge(I1 first1, S1 last1, I2 first2, S2 last2, O result,
674753f127fSDimitry Andric            Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {});                                    // since C++20
675753f127fSDimitry Andric
676753f127fSDimitry Andric  template<input_range R1, input_range R2, weakly_incrementable O, class Comp = ranges::less,
677753f127fSDimitry Andric           class Proj1 = identity, class Proj2 = identity>
678753f127fSDimitry Andric    requires mergeable<iterator_t<R1>, iterator_t<R2>, O, Comp, Proj1, Proj2>
679753f127fSDimitry Andric    constexpr merge_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>, O>
680753f127fSDimitry Andric      merge(R1&& r1, R2&& r2, O result,
681753f127fSDimitry Andric            Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {});                                    // since C++20
682753f127fSDimitry Andric
683753f127fSDimitry Andric  template<permutable I, sentinel_for<I> S, class T, class Proj = identity>
684753f127fSDimitry Andric    requires indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
685753f127fSDimitry Andric    constexpr subrange<I> ranges::remove(I first, S last, const T& value, Proj proj = {});          // since C++20
686753f127fSDimitry Andric
687753f127fSDimitry Andric  template<forward_range R, class T, class Proj = identity>
688753f127fSDimitry Andric    requires permutable<iterator_t<R>> &&
689753f127fSDimitry Andric             indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*>
690753f127fSDimitry Andric    constexpr borrowed_subrange_t<R>
691753f127fSDimitry Andric      ranges::remove(R&& r, const T& value, Proj proj = {});                                        // since C++20
692753f127fSDimitry Andric
693753f127fSDimitry Andric  template<permutable I, sentinel_for<I> S, class Proj = identity,
694753f127fSDimitry Andric           indirect_unary_predicate<projected<I, Proj>> Pred>
695753f127fSDimitry Andric    constexpr subrange<I> ranges::remove_if(I first, S last, Pred pred, Proj proj = {});            // since C++20
696753f127fSDimitry Andric
697753f127fSDimitry Andric  template<forward_range R, class Proj = identity,
698753f127fSDimitry Andric           indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
699753f127fSDimitry Andric    requires permutable<iterator_t<R>>
700753f127fSDimitry Andric    constexpr borrowed_subrange_t<R>
701753f127fSDimitry Andric      ranges::remove_if(R&& r, Pred pred, Proj proj = {});                                          // since C++20
702753f127fSDimitry Andric
703753f127fSDimitry Andric  template<class I, class O>
704753f127fSDimitry Andric    using set_difference_result = in_out_result<I, O>;                                              // since C++20
705753f127fSDimitry Andric
706753f127fSDimitry Andric  template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
707753f127fSDimitry Andric           weakly_incrementable O, class Comp = ranges::less,
708753f127fSDimitry Andric           class Proj1 = identity, class Proj2 = identity>
709753f127fSDimitry Andric    requires mergeable<I1, I2, O, Comp, Proj1, Proj2>
710753f127fSDimitry Andric    constexpr set_difference_result<I1, O>
711753f127fSDimitry Andric      set_difference(I1 first1, S1 last1, I2 first2, S2 last2, O result,
712753f127fSDimitry Andric                     Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {});                           // since C++20
713753f127fSDimitry Andric
714753f127fSDimitry Andric  template<input_range R1, input_range R2, weakly_incrementable O,
715753f127fSDimitry Andric           class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity>
716753f127fSDimitry Andric    requires mergeable<iterator_t<R1>, iterator_t<R2>, O, Comp, Proj1, Proj2>
717753f127fSDimitry Andric    constexpr set_difference_result<borrowed_iterator_t<R1>, O>
718753f127fSDimitry Andric      set_difference(R1&& r1, R2&& r2, O result,
719753f127fSDimitry Andric                     Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {});                           // since C++20
720753f127fSDimitry Andric
721753f127fSDimitry Andric  template<class I1, class I2, class O>
722753f127fSDimitry Andric    using set_intersection_result = in_in_out_result<I1, I2, O>;                                    // since C++20
723753f127fSDimitry Andric
724753f127fSDimitry Andric  template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
725753f127fSDimitry Andric           weakly_incrementable O, class Comp = ranges::less,
726753f127fSDimitry Andric           class Proj1 = identity, class Proj2 = identity>
727753f127fSDimitry Andric    requires mergeable<I1, I2, O, Comp, Proj1, Proj2>
728753f127fSDimitry Andric    constexpr set_intersection_result<I1, I2, O>
729753f127fSDimitry Andric      set_intersection(I1 first1, S1 last1, I2 first2, S2 last2, O result,
730753f127fSDimitry Andric                       Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {});                         // since C++20
731753f127fSDimitry Andric
732753f127fSDimitry Andric  template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
733753f127fSDimitry Andric           weakly_incrementable O, class Comp = ranges::less,
734753f127fSDimitry Andric           class Proj1 = identity, class Proj2 = identity>
735753f127fSDimitry Andric    requires mergeable<I1, I2, O, Comp, Proj1, Proj2>
736753f127fSDimitry Andric    constexpr set_intersection_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>, O>
737753f127fSDimitry Andric      set_intersection(R1&& r1, R2&& r2, O result,
738753f127fSDimitry Andric                       Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {});                         // since C++20
739753f127fSDimitry Andric
740753f127fSDimitry Andric  template <class _InIter, class _OutIter>
741753f127fSDimitry Andric  using reverse_copy_result = in_out_result<_InIter, _OutIter>;                                     // since C++20
742753f127fSDimitry Andric
743753f127fSDimitry Andric  template<bidirectional_iterator I, sentinel_for<I> S, weakly_incrementable O>
744753f127fSDimitry Andric    requires indirectly_copyable<I, O>
745753f127fSDimitry Andric    constexpr ranges::reverse_copy_result<I, O>
746753f127fSDimitry Andric      ranges::reverse_copy(I first, S last, O result);                                              // since C++20
747753f127fSDimitry Andric
748753f127fSDimitry Andric  template<bidirectional_range R, weakly_incrementable O>
749753f127fSDimitry Andric    requires indirectly_copyable<iterator_t<R>, O>
750753f127fSDimitry Andric    constexpr ranges::reverse_copy_result<borrowed_iterator_t<R>, O>
751753f127fSDimitry Andric      ranges::reverse_copy(R&& r, O result);                                                        // since C++20
752753f127fSDimitry Andric
75361cfbce3SDimitry Andric  template<permutable I, sentinel_for<I> S>
75461cfbce3SDimitry Andric    constexpr subrange<I> rotate(I first, I middle, S last);                                        // since C++20
75561cfbce3SDimitry Andric
75661cfbce3SDimitry Andric  template<forward_range R>
75761cfbce3SDimitry Andric    requires permutable<iterator_t<R>>
75861cfbce3SDimitry Andric    constexpr borrowed_subrange_t<R> rotate(R&& r, iterator_t<R> middle);                           // Since C++20
75961cfbce3SDimitry Andric
760753f127fSDimitry Andric  template <class _InIter, class _OutIter>
761753f127fSDimitry Andric  using rotate_copy_result = in_out_result<_InIter, _OutIter>;                                      // since C++20
762753f127fSDimitry Andric
763753f127fSDimitry Andric  template<forward_iterator I, sentinel_for<I> S, weakly_incrementable O>
764753f127fSDimitry Andric    requires indirectly_copyable<I, O>
765753f127fSDimitry Andric    constexpr ranges::rotate_copy_result<I, O>
766753f127fSDimitry Andric      ranges::rotate_copy(I first, I middle, S last, O result);                                     // since C++20
767753f127fSDimitry Andric
768753f127fSDimitry Andric  template<forward_range R, weakly_incrementable O>
769753f127fSDimitry Andric    requires indirectly_copyable<iterator_t<R>, O>
770753f127fSDimitry Andric    constexpr ranges::rotate_copy_result<borrowed_iterator_t<R>, O>
771753f127fSDimitry Andric      ranges::rotate_copy(R&& r, iterator_t<R> middle, O result);                                   // since C++20
772753f127fSDimitry Andric
77361cfbce3SDimitry Andric  template<input_iterator I, sentinel_for<I> S, weakly_incrementable O, class Gen>
77461cfbce3SDimitry Andric    requires (forward_iterator<I> || random_access_iterator<O>) &&
77561cfbce3SDimitry Andric            indirectly_copyable<I, O> &&
77661cfbce3SDimitry Andric            uniform_random_bit_generator<remove_reference_t<Gen>>
77761cfbce3SDimitry Andric    O sample(I first, S last, O out, iter_difference_t<I> n, Gen&& g);                              // Since C++20
77861cfbce3SDimitry Andric
77961cfbce3SDimitry Andric  template<input_range R, weakly_incrementable O, class Gen>
78061cfbce3SDimitry Andric    requires (forward_range<R> || random_access_iterator<O>) &&
78161cfbce3SDimitry Andric            indirectly_copyable<iterator_t<R>, O> &&
78261cfbce3SDimitry Andric            uniform_random_bit_generator<remove_reference_t<Gen>>
78361cfbce3SDimitry Andric    O sample(R&& r, O out, range_difference_t<R> n, Gen&& g);                                       // Since C++20
78461cfbce3SDimitry Andric
785fcaf7f86SDimitry Andric  template<random_access_iterator I, sentinel_for<I> S, class Gen>
786fcaf7f86SDimitry Andric    requires permutable<I> &&
787fcaf7f86SDimitry Andric            uniform_random_bit_generator<remove_reference_t<Gen>>
788fcaf7f86SDimitry Andric    I shuffle(I first, S last, Gen&& g);                                                           // Since C++20
789fcaf7f86SDimitry Andric
790fcaf7f86SDimitry Andric  template<random_access_range R, class Gen>
791fcaf7f86SDimitry Andric    requires permutable<iterator_t<R>> &&
792fcaf7f86SDimitry Andric            uniform_random_bit_generator<remove_reference_t<Gen>>
793fcaf7f86SDimitry Andric    borrowed_iterator_t<R> shuffle(R&& r, Gen&& g);                                                // Since C++20
794fcaf7f86SDimitry Andric
795753f127fSDimitry Andric  template<forward_iterator I1, sentinel_for<I1> S1, forward_iterator I2,
79661cfbce3SDimitry Andric         sentinel_for<I2> S2, class Proj1 = identity, class Proj2 = identity,
79761cfbce3SDimitry Andric         indirect_equivalence_relation<projected<I1, Proj1>,
79861cfbce3SDimitry Andric                                       projected<I2, Proj2>> Pred = ranges::equal_to>
79961cfbce3SDimitry Andric  constexpr bool ranges::is_permutation(I1 first1, S1 last1, I2 first2, S2 last2,
80061cfbce3SDimitry Andric                                        Pred pred = {},
80161cfbce3SDimitry Andric                                        Proj1 proj1 = {}, Proj2 proj2 = {});                       // Since C++20
80261cfbce3SDimitry Andric
80361cfbce3SDimitry Andric  template<forward_range R1, forward_range R2,
80461cfbce3SDimitry Andric         class Proj1 = identity, class Proj2 = identity,
80561cfbce3SDimitry Andric         indirect_equivalence_relation<projected<iterator_t<R1>, Proj1>,
80661cfbce3SDimitry Andric                                       projected<iterator_t<R2>, Proj2>> Pred = ranges::equal_to>
80761cfbce3SDimitry Andric  constexpr bool ranges::is_permutation(R1&& r1, R2&& r2, Pred pred = {},
80861cfbce3SDimitry Andric                                        Proj1 proj1 = {}, Proj2 proj2 = {});                       // Since C++20
80961cfbce3SDimitry Andric
81061cfbce3SDimitry Andric  template<forward_iterator I1, sentinel_for<I1> S1, forward_iterator I2,
811753f127fSDimitry Andric           sentinel_for<I2> S2, class Pred = ranges::equal_to,
812753f127fSDimitry Andric           class Proj1 = identity, class Proj2 = identity>
813753f127fSDimitry Andric    requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
814753f127fSDimitry Andric    constexpr subrange<I1>
815753f127fSDimitry Andric      ranges::search(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {},
816753f127fSDimitry Andric                     Proj1 proj1 = {}, Proj2 proj2 = {});                                           // since C++20
817753f127fSDimitry Andric
818753f127fSDimitry Andric  template<forward_range R1, forward_range R2, class Pred = ranges::equal_to,
819753f127fSDimitry Andric           class Proj1 = identity, class Proj2 = identity>
820753f127fSDimitry Andric    requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
821753f127fSDimitry Andric    constexpr borrowed_subrange_t<R1>
822753f127fSDimitry Andric      ranges::search(R1&& r1, R2&& r2, Pred pred = {},
823753f127fSDimitry Andric                     Proj1 proj1 = {}, Proj2 proj2 = {});                                           // since C++20
824753f127fSDimitry Andric
825753f127fSDimitry Andric  template<forward_iterator I, sentinel_for<I> S, class T,
826753f127fSDimitry Andric           class Pred = ranges::equal_to, class Proj = identity>
827753f127fSDimitry Andric    requires indirectly_comparable<I, const T*, Pred, Proj>
828753f127fSDimitry Andric    constexpr subrange<I>
829753f127fSDimitry Andric      ranges::search_n(I first, S last, iter_difference_t<I> count,
830753f127fSDimitry Andric                       const T& value, Pred pred = {}, Proj proj = {});                             // since C++20
831753f127fSDimitry Andric
832753f127fSDimitry Andric  template<forward_range R, class T, class Pred = ranges::equal_to,
833753f127fSDimitry Andric           class Proj = identity>
834753f127fSDimitry Andric    requires indirectly_comparable<iterator_t<R>, const T*, Pred, Proj>
835753f127fSDimitry Andric    constexpr borrowed_subrange_t<R>
836753f127fSDimitry Andric      ranges::search_n(R&& r, range_difference_t<R> count,
837753f127fSDimitry Andric                       const T& value, Pred pred = {}, Proj proj = {});                             // since C++20
838753f127fSDimitry Andric
839753f127fSDimitry Andric  template<forward_iterator I1, sentinel_for<I1> S1, forward_iterator I2, sentinel_for<I2> S2,
840753f127fSDimitry Andric           class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
841753f127fSDimitry Andric    requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
842753f127fSDimitry Andric    constexpr subrange<I1>
843753f127fSDimitry Andric      ranges::find_end(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {},
844753f127fSDimitry Andric                       Proj1 proj1 = {}, Proj2 proj2 = {});                                         // since C++20
845753f127fSDimitry Andric
846753f127fSDimitry Andric  template<forward_range R1, forward_range R2,
847753f127fSDimitry Andric           class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
848753f127fSDimitry Andric    requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
849753f127fSDimitry Andric    constexpr borrowed_subrange_t<R1>
850753f127fSDimitry Andric      ranges::find_end(R1&& r1, R2&& r2, Pred pred = {},
851753f127fSDimitry Andric                       Proj1 proj1 = {}, Proj2 proj2 = {});                                         // since C++20
852753f127fSDimitry Andric
853753f127fSDimitry Andric  template<class I1, class I2, class O>
854753f127fSDimitry Andric    using set_symmetric_difference_result = in_in_out_result<I1, I2, O>;                            // since C++20
855753f127fSDimitry Andric
856753f127fSDimitry Andric  template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
857753f127fSDimitry Andric           weakly_incrementable O, class Comp = ranges::less,
858753f127fSDimitry Andric           class Proj1 = identity, class Proj2 = identity>
859753f127fSDimitry Andric    requires mergeable<I1, I2, O, Comp, Proj1, Proj2>
860753f127fSDimitry Andric    constexpr set_symmetric_difference_result<I1, I2, O>
861753f127fSDimitry Andric      set_symmetric_difference(I1 first1, S1 last1, I2 first2, S2 last2, O result,
862753f127fSDimitry Andric                               Comp comp = {}, Proj1 proj1 = {},
863753f127fSDimitry Andric                               Proj2 proj2 = {});                                                   // since C++20
864753f127fSDimitry Andric
865753f127fSDimitry Andric  template<input_range R1, input_range R2, weakly_incrementable O,
866753f127fSDimitry Andric           class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity>
867753f127fSDimitry Andric    requires mergeable<iterator_t<R1>, iterator_t<R2>, O, Comp, Proj1, Proj2>
868753f127fSDimitry Andric    constexpr set_symmetric_difference_result<borrowed_iterator_t<R1>,
869753f127fSDimitry Andric                                                      borrowed_iterator_t<R2>, O>
870753f127fSDimitry Andric      set_symmetric_difference(R1&& r1, R2&& r2, O result, Comp comp = {},
871753f127fSDimitry Andric                               Proj1 proj1 = {}, Proj2 proj2 = {});                                 // since C++20
87281ad6265SDimitry Andric
873fcaf7f86SDimitry Andric  template<forward_iterator I, sentinel_for<I> S, class T, class Proj = identity,
874fcaf7f86SDimitry Andric           indirect_strict_weak_order<const T*, projected<I, Proj>> Comp = ranges::less>
875fcaf7f86SDimitry Andric    constexpr subrange<I>
876fcaf7f86SDimitry Andric      equal_range(I first, S last, const T& value, Comp comp = {}, Proj proj = {});                 // since C++20
877fcaf7f86SDimitry Andric
878fcaf7f86SDimitry Andric  template<forward_range R, class T, class Proj = identity,
879fcaf7f86SDimitry Andric           indirect_strict_weak_order<const T*, projected<iterator_t<R>, Proj>> Comp =
880fcaf7f86SDimitry Andric             ranges::less>
881fcaf7f86SDimitry Andric    constexpr borrowed_subrange_t<R>
882fcaf7f86SDimitry Andric      equal_range(R&& r, const T& value, Comp comp = {}, Proj proj = {});                           // since C++20
883fcaf7f86SDimitry Andric
884fcaf7f86SDimitry Andric  template<class I1, class I2, class O>
885fcaf7f86SDimitry Andric    using set_union_result = in_in_out_result<I1, I2, O>;                                           // since C++20
886fcaf7f86SDimitry Andric
887fcaf7f86SDimitry Andric  template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
888fcaf7f86SDimitry Andric           weakly_incrementable O, class Comp = ranges::less,
889fcaf7f86SDimitry Andric           class Proj1 = identity, class Proj2 = identity>
890fcaf7f86SDimitry Andric    requires mergeable<I1, I2, O, Comp, Proj1, Proj2>
891fcaf7f86SDimitry Andric    constexpr set_union_result<I1, I2, O>
892fcaf7f86SDimitry Andric      set_union(I1 first1, S1 last1, I2 first2, S2 last2, O result, Comp comp = {},
893fcaf7f86SDimitry Andric                Proj1 proj1 = {}, Proj2 proj2 = {});                                                // since C++20
894fcaf7f86SDimitry Andric
895fcaf7f86SDimitry Andric  template<input_range R1, input_range R2, weakly_incrementable O,
896fcaf7f86SDimitry Andric           class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity>
897fcaf7f86SDimitry Andric    requires mergeable<iterator_t<R1>, iterator_t<R2>, O, Comp, Proj1, Proj2>
898fcaf7f86SDimitry Andric    constexpr set_union_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>, O>
899fcaf7f86SDimitry Andric      set_union(R1&& r1, R2&& r2, O result, Comp comp = {},
900fcaf7f86SDimitry Andric                Proj1 proj1 = {}, Proj2 proj2 = {});                                                // since C++20
901fcaf7f86SDimitry Andric
902fcaf7f86SDimitry Andric  template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
903fcaf7f86SDimitry Andric           class Proj1 = identity, class Proj2 = identity,
904fcaf7f86SDimitry Andric           indirect_strict_weak_order<projected<I1, Proj1>, projected<I2, Proj2>> Comp =
905fcaf7f86SDimitry Andric             ranges::less>
906fcaf7f86SDimitry Andric    constexpr bool includes(I1 first1, S1 last1, I2 first2, S2 last2, Comp comp = {},
907fcaf7f86SDimitry Andric                            Proj1 proj1 = {}, Proj2 proj2 = {});                                   // Since C++20
908fcaf7f86SDimitry Andric
909fcaf7f86SDimitry Andric  template<input_range R1, input_range R2, class Proj1 = identity,
910fcaf7f86SDimitry Andric           class Proj2 = identity,
911fcaf7f86SDimitry Andric           indirect_strict_weak_order<projected<iterator_t<R1>, Proj1>,
912fcaf7f86SDimitry Andric                                      projected<iterator_t<R2>, Proj2>> Comp = ranges::less>
913fcaf7f86SDimitry Andric    constexpr bool includes(R1&& r1, R2&& r2, Comp comp = {},
914fcaf7f86SDimitry Andric                            Proj1 proj1 = {}, Proj2 proj2 = {});                                   // Since C++20
91561cfbce3SDimitry Andric
91661cfbce3SDimitry Andric  template<bidirectional_iterator I, sentinel_for<I> S, class Comp = ranges::less,
91761cfbce3SDimitry Andric           class Proj = identity>
91861cfbce3SDimitry Andric    requires sortable<I, Comp, Proj>
91961cfbce3SDimitry Andric    I inplace_merge(I first, I middle, S last, Comp comp = {}, Proj proj = {});                    // Since C++20
92061cfbce3SDimitry Andric
92161cfbce3SDimitry Andric  template<bidirectional_range R, class Comp = ranges::less, class Proj = identity>
92261cfbce3SDimitry Andric    requires sortable<iterator_t<R>, Comp, Proj>
92361cfbce3SDimitry Andric    borrowed_iterator_t<R>
92461cfbce3SDimitry Andric      inplace_merge(R&& r, iterator_t<R> middle, Comp comp = {},
92561cfbce3SDimitry Andric                    Proj proj = {});                                                               // Since C++20
92661cfbce3SDimitry Andric
92761cfbce3SDimitry Andric  template<permutable I, sentinel_for<I> S, class Proj = identity,
92861cfbce3SDimitry Andric           indirect_equivalence_relation<projected<I, Proj>> C = ranges::equal_to>
92961cfbce3SDimitry Andric    constexpr subrange<I> unique(I first, S last, C comp = {}, Proj proj = {});                    // Since C++20
93061cfbce3SDimitry Andric
93161cfbce3SDimitry Andric  template<forward_range R, class Proj = identity,
93261cfbce3SDimitry Andric           indirect_equivalence_relation<projected<iterator_t<R>, Proj>> C = ranges::equal_to>
93361cfbce3SDimitry Andric    requires permutable<iterator_t<R>>
93461cfbce3SDimitry Andric    constexpr borrowed_subrange_t<R>
93561cfbce3SDimitry Andric      unique(R&& r, C comp = {}, Proj proj = {});                                                  // Since C++20
93661cfbce3SDimitry Andric
93761cfbce3SDimitry Andric  template<input_iterator I, sentinel_for<I> S, weakly_incrementable O, class Proj = identity,
93861cfbce3SDimitry Andric           indirect_equivalence_relation<projected<I, Proj>> C = ranges::equal_to>
93961cfbce3SDimitry Andric    requires indirectly_copyable<I, O> &&
94061cfbce3SDimitry Andric             (forward_iterator<I> ||
94161cfbce3SDimitry Andric              (input_iterator<O> && same_as<iter_value_t<I>, iter_value_t<O>>) ||
94261cfbce3SDimitry Andric              indirectly_copyable_storable<I, O>)
94361cfbce3SDimitry Andric    constexpr unique_copy_result<I, O>
94461cfbce3SDimitry Andric      unique_copy(I first, S last, O result, C comp = {}, Proj proj = {});                         // Since C++20
94561cfbce3SDimitry Andric
94661cfbce3SDimitry Andric  template<input_range R, weakly_incrementable O, class Proj = identity,
94761cfbce3SDimitry Andric           indirect_equivalence_relation<projected<iterator_t<R>, Proj>> C = ranges::equal_to>
94861cfbce3SDimitry Andric    requires indirectly_copyable<iterator_t<R>, O> &&
94961cfbce3SDimitry Andric             (forward_iterator<iterator_t<R>> ||
95061cfbce3SDimitry Andric              (input_iterator<O> && same_as<range_value_t<R>, iter_value_t<O>>) ||
95161cfbce3SDimitry Andric              indirectly_copyable_storable<iterator_t<R>, O>)
95261cfbce3SDimitry Andric    constexpr unique_copy_result<borrowed_iterator_t<R>, O>
95361cfbce3SDimitry Andric      unique_copy(R&& r, O result, C comp = {}, Proj proj = {});                                   // Since C++20
95461cfbce3SDimitry Andric
95561cfbce3SDimitry Andric  template<class I, class O>
95661cfbce3SDimitry Andric      using remove_copy_result = in_out_result<I, O>;                                              // Since C++20
95761cfbce3SDimitry Andric
95861cfbce3SDimitry Andric  template<input_iterator I, sentinel_for<I> S, weakly_incrementable O, class T,
95961cfbce3SDimitry Andric           class Proj = identity>
96061cfbce3SDimitry Andric             indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
96161cfbce3SDimitry Andric    constexpr remove_copy_result<I, O>
96261cfbce3SDimitry Andric      remove_copy(I first, S last, O result, const T& value, Proj proj = {});                      // Since C++20
96361cfbce3SDimitry Andric
96461cfbce3SDimitry Andric  template<input_range R, weakly_incrementable O, class T, class Proj = identity>
96561cfbce3SDimitry Andric    requires indirectly_copyable<iterator_t<R>, O> &&
96661cfbce3SDimitry Andric             indirect_binary_predicate<ranges::equal_to,
96761cfbce3SDimitry Andric                                       projected<iterator_t<R>, Proj>, const T*>
96861cfbce3SDimitry Andric    constexpr remove_copy_result<borrowed_iterator_t<R>, O>
96961cfbce3SDimitry Andric      remove_copy(R&& r, O result, const T& value, Proj proj = {});                                // Since C++20
97061cfbce3SDimitry Andric
97161cfbce3SDimitry Andric  template<class I, class O>
97261cfbce3SDimitry Andric      using remove_copy_if_result = in_out_result<I, O>;                                           // Since C++20
97361cfbce3SDimitry Andric
97461cfbce3SDimitry Andric  template<input_iterator I, sentinel_for<I> S, weakly_incrementable O,
97561cfbce3SDimitry Andric           class Proj = identity, indirect_unary_predicate<projected<I, Proj>> Pred>
97661cfbce3SDimitry Andric    requires indirectly_copyable<I, O>
97761cfbce3SDimitry Andric    constexpr remove_copy_if_result<I, O>
97861cfbce3SDimitry Andric      remove_copy_if(I first, S last, O result, Pred pred, Proj proj = {});                        // Since C++20
97961cfbce3SDimitry Andric
98061cfbce3SDimitry Andric  template<input_range R, weakly_incrementable O, class Proj = identity,
98161cfbce3SDimitry Andric           indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
98261cfbce3SDimitry Andric    requires indirectly_copyable<iterator_t<R>, O>
98361cfbce3SDimitry Andric    constexpr remove_copy_if_result<borrowed_iterator_t<R>, O>
98461cfbce3SDimitry Andric      remove_copy_if(R&& r, O result, Pred pred, Proj proj = {});                                  // Since C++20
98561cfbce3SDimitry Andric
98661cfbce3SDimitry Andric  template<class I, class O>
98761cfbce3SDimitry Andric      using replace_copy_result = in_out_result<I, O>;                                             // Since C++20
98861cfbce3SDimitry Andric
98961cfbce3SDimitry Andric  template<input_iterator I, sentinel_for<I> S, class T1, class T2,
99061cfbce3SDimitry Andric           output_iterator<const T2&> O, class Proj = identity>
99161cfbce3SDimitry Andric    requires indirectly_copyable<I, O> &&
99261cfbce3SDimitry Andric             indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T1*>
99361cfbce3SDimitry Andric    constexpr replace_copy_result<I, O>
99461cfbce3SDimitry Andric      replace_copy(I first, S last, O result, const T1& old_value, const T2& new_value,
99561cfbce3SDimitry Andric                   Proj proj = {});                                                                // Since C++20
99661cfbce3SDimitry Andric
99761cfbce3SDimitry Andric  template<input_range R, class T1, class T2, output_iterator<const T2&> O,
99861cfbce3SDimitry Andric           class Proj = identity>
99961cfbce3SDimitry Andric    requires indirectly_copyable<iterator_t<R>, O> &&
100061cfbce3SDimitry Andric             indirect_binary_predicate<ranges::equal_to,
100161cfbce3SDimitry Andric                                       projected<iterator_t<R>, Proj>, const T1*>
100261cfbce3SDimitry Andric    constexpr replace_copy_result<borrowed_iterator_t<R>, O>
100361cfbce3SDimitry Andric      replace_copy(R&& r, O result, const T1& old_value, const T2& new_value,
100461cfbce3SDimitry Andric                   Proj proj = {});                                                                // Since C++20
100561cfbce3SDimitry Andric
100661cfbce3SDimitry Andric  template<class I, class O>
100761cfbce3SDimitry Andric      using replace_copy_if_result = in_out_result<I, O>;                                          // Since C++20
100861cfbce3SDimitry Andric
100961cfbce3SDimitry Andric  template<input_iterator I, sentinel_for<I> S, class T, output_iterator<const T&> O,
101061cfbce3SDimitry Andric           class Proj = identity, indirect_unary_predicate<projected<I, Proj>> Pred>
101161cfbce3SDimitry Andric    requires indirectly_copyable<I, O>
101261cfbce3SDimitry Andric    constexpr replace_copy_if_result<I, O>
101361cfbce3SDimitry Andric      replace_copy_if(I first, S last, O result, Pred pred, const T& new_value,
101461cfbce3SDimitry Andric                      Proj proj = {});                                                             // Since C++20
101561cfbce3SDimitry Andric
101661cfbce3SDimitry Andric  template<input_range R, class T, output_iterator<const T&> O, class Proj = identity,
101761cfbce3SDimitry Andric           indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
101861cfbce3SDimitry Andric    requires indirectly_copyable<iterator_t<R>, O>
101961cfbce3SDimitry Andric    constexpr replace_copy_if_result<borrowed_iterator_t<R>, O>
102061cfbce3SDimitry Andric      replace_copy_if(R&& r, O result, Pred pred, const T& new_value,
102161cfbce3SDimitry Andric                      Proj proj = {});                                                             // Since C++20
102261cfbce3SDimitry Andric
102361cfbce3SDimitry Andric  template<class I>
102461cfbce3SDimitry Andric    using prev_permutation_result = in_found_result<I>;                                            // Since C++20
102561cfbce3SDimitry Andric
102661cfbce3SDimitry Andric  template<bidirectional_iterator I, sentinel_for<I> S, class Comp = ranges::less,
102761cfbce3SDimitry Andric           class Proj = identity>
102861cfbce3SDimitry Andric    requires sortable<I, Comp, Proj>
102961cfbce3SDimitry Andric    constexpr ranges::prev_permutation_result<I>
103061cfbce3SDimitry Andric      ranges::prev_permutation(I first, S last, Comp comp = {}, Proj proj = {});                   // Since C++20
103161cfbce3SDimitry Andric
103261cfbce3SDimitry Andric  template<bidirectional_range R, class Comp = ranges::less,
103361cfbce3SDimitry Andric           class Proj = identity>
103461cfbce3SDimitry Andric    requires sortable<iterator_t<R>, Comp, Proj>
103561cfbce3SDimitry Andric    constexpr ranges::prev_permutation_result<borrowed_iterator_t<R>>
103661cfbce3SDimitry Andric      ranges::prev_permutation(R&& r, Comp comp = {}, Proj proj = {});                             // Since C++20
103761cfbce3SDimitry Andric
103861cfbce3SDimitry Andric  template<class I>
103961cfbce3SDimitry Andric    using next_permutation_result = in_found_result<I>;                                            // Since C++20
104061cfbce3SDimitry Andric
104161cfbce3SDimitry Andric  template<bidirectional_iterator I, sentinel_for<I> S, class Comp = ranges::less,
104261cfbce3SDimitry Andric           class Proj = identity>
104361cfbce3SDimitry Andric    requires sortable<I, Comp, Proj>
104461cfbce3SDimitry Andric    constexpr ranges::next_permutation_result<I>
104561cfbce3SDimitry Andric      ranges::next_permutation(I first, S last, Comp comp = {}, Proj proj = {});                   // Since C++20
104661cfbce3SDimitry Andric
104761cfbce3SDimitry Andric  template<bidirectional_range R, class Comp = ranges::less,
104861cfbce3SDimitry Andric           class Proj = identity>
104961cfbce3SDimitry Andric    requires sortable<iterator_t<R>, Comp, Proj>
105061cfbce3SDimitry Andric    constexpr ranges::next_permutation_result<borrowed_iterator_t<R>>
105161cfbce3SDimitry Andric      ranges::next_permutation(R&& r, Comp comp = {}, Proj proj = {});                             // Since C++20
105261cfbce3SDimitry Andric
105304eeddc0SDimitry Andric}
105404eeddc0SDimitry Andric
105561cfbce3SDimitry Andrictemplate <class InputIterator, class Predicate>
10560b57cec5SDimitry Andric    constexpr bool     // constexpr in C++20
10570b57cec5SDimitry Andric    all_of(InputIterator first, InputIterator last, Predicate pred);
10580b57cec5SDimitry Andric
10590b57cec5SDimitry Andrictemplate <class InputIterator, class Predicate>
10600b57cec5SDimitry Andric    constexpr bool     // constexpr in C++20
10610b57cec5SDimitry Andric    any_of(InputIterator first, InputIterator last, Predicate pred);
10620b57cec5SDimitry Andric
10630b57cec5SDimitry Andrictemplate <class InputIterator, class Predicate>
10640b57cec5SDimitry Andric    constexpr bool     // constexpr in C++20
10650b57cec5SDimitry Andric    none_of(InputIterator first, InputIterator last, Predicate pred);
10660b57cec5SDimitry Andric
10670b57cec5SDimitry Andrictemplate <class InputIterator, class Function>
10680b57cec5SDimitry Andric    constexpr Function          // constexpr in C++20
10690b57cec5SDimitry Andric    for_each(InputIterator first, InputIterator last, Function f);
10700b57cec5SDimitry Andric
10710b57cec5SDimitry Andrictemplate<class InputIterator, class Size, class Function>
10720b57cec5SDimitry Andric    constexpr InputIterator     // constexpr in C++20
10730b57cec5SDimitry Andric    for_each_n(InputIterator first, Size n, Function f); // C++17
10740b57cec5SDimitry Andric
10750b57cec5SDimitry Andrictemplate <class InputIterator, class T>
10760b57cec5SDimitry Andric    constexpr InputIterator     // constexpr in C++20
10770b57cec5SDimitry Andric    find(InputIterator first, InputIterator last, const T& value);
10780b57cec5SDimitry Andric
10790b57cec5SDimitry Andrictemplate <class InputIterator, class Predicate>
10800b57cec5SDimitry Andric    constexpr InputIterator     // constexpr in C++20
10810b57cec5SDimitry Andric    find_if(InputIterator first, InputIterator last, Predicate pred);
10820b57cec5SDimitry Andric
10830b57cec5SDimitry Andrictemplate<class InputIterator, class Predicate>
1084e8d8bef9SDimitry Andric    constexpr InputIterator     // constexpr in C++20
10850b57cec5SDimitry Andric    find_if_not(InputIterator first, InputIterator last, Predicate pred);
10860b57cec5SDimitry Andric
10870b57cec5SDimitry Andrictemplate <class ForwardIterator1, class ForwardIterator2>
1088e8d8bef9SDimitry Andric    constexpr ForwardIterator1  // constexpr in C++20
10890b57cec5SDimitry Andric    find_end(ForwardIterator1 first1, ForwardIterator1 last1,
10900b57cec5SDimitry Andric             ForwardIterator2 first2, ForwardIterator2 last2);
10910b57cec5SDimitry Andric
10920b57cec5SDimitry Andrictemplate <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
1093e8d8bef9SDimitry Andric    constexpr ForwardIterator1  // constexpr in C++20
10940b57cec5SDimitry Andric    find_end(ForwardIterator1 first1, ForwardIterator1 last1,
10950b57cec5SDimitry Andric             ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
10960b57cec5SDimitry Andric
10970b57cec5SDimitry Andrictemplate <class ForwardIterator1, class ForwardIterator2>
10980b57cec5SDimitry Andric    constexpr ForwardIterator1  // constexpr in C++20
10990b57cec5SDimitry Andric    find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
11000b57cec5SDimitry Andric                  ForwardIterator2 first2, ForwardIterator2 last2);
11010b57cec5SDimitry Andric
11020b57cec5SDimitry Andrictemplate <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
11030b57cec5SDimitry Andric    constexpr ForwardIterator1  // constexpr in C++20
11040b57cec5SDimitry Andric    find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
11050b57cec5SDimitry Andric                  ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
11060b57cec5SDimitry Andric
11070b57cec5SDimitry Andrictemplate <class ForwardIterator>
11080b57cec5SDimitry Andric    constexpr ForwardIterator   // constexpr in C++20
11090b57cec5SDimitry Andric    adjacent_find(ForwardIterator first, ForwardIterator last);
11100b57cec5SDimitry Andric
11110b57cec5SDimitry Andrictemplate <class ForwardIterator, class BinaryPredicate>
11120b57cec5SDimitry Andric    constexpr ForwardIterator   // constexpr in C++20
11130b57cec5SDimitry Andric    adjacent_find(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
11140b57cec5SDimitry Andric
11150b57cec5SDimitry Andrictemplate <class InputIterator, class T>
11160b57cec5SDimitry Andric    constexpr typename iterator_traits<InputIterator>::difference_type  // constexpr in C++20
11170b57cec5SDimitry Andric    count(InputIterator first, InputIterator last, const T& value);
11180b57cec5SDimitry Andric
11190b57cec5SDimitry Andrictemplate <class InputIterator, class Predicate>
11200b57cec5SDimitry Andric    constexpr typename iterator_traits<InputIterator>::difference_type // constexpr in C++20
11210b57cec5SDimitry Andric    count_if(InputIterator first, InputIterator last, Predicate pred);
11220b57cec5SDimitry Andric
11230b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2>
11240b57cec5SDimitry Andric    constexpr pair<InputIterator1, InputIterator2>   // constexpr in C++20
11250b57cec5SDimitry Andric    mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
11260b57cec5SDimitry Andric
11270b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2>
11280b57cec5SDimitry Andric    constexpr pair<InputIterator1, InputIterator2>   // constexpr in C++20
11290b57cec5SDimitry Andric    mismatch(InputIterator1 first1, InputIterator1 last1,
11300b57cec5SDimitry Andric             InputIterator2 first2, InputIterator2 last2); // **C++14**
11310b57cec5SDimitry Andric
11320b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2, class BinaryPredicate>
11330b57cec5SDimitry Andric    constexpr pair<InputIterator1, InputIterator2>   // constexpr in C++20
11340b57cec5SDimitry Andric    mismatch(InputIterator1 first1, InputIterator1 last1,
11350b57cec5SDimitry Andric             InputIterator2 first2, BinaryPredicate pred);
11360b57cec5SDimitry Andric
11370b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2, class BinaryPredicate>
11380b57cec5SDimitry Andric    constexpr pair<InputIterator1, InputIterator2>   // constexpr in C++20
11390b57cec5SDimitry Andric    mismatch(InputIterator1 first1, InputIterator1 last1,
11400b57cec5SDimitry Andric             InputIterator2 first2, InputIterator2 last2,
11410b57cec5SDimitry Andric             BinaryPredicate pred); // **C++14**
11420b57cec5SDimitry Andric
11430b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2>
11440b57cec5SDimitry Andric    constexpr bool      // constexpr in C++20
11450b57cec5SDimitry Andric    equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
11460b57cec5SDimitry Andric
11470b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2>
11480b57cec5SDimitry Andric    constexpr bool      // constexpr in C++20
11490b57cec5SDimitry Andric    equal(InputIterator1 first1, InputIterator1 last1,
11500b57cec5SDimitry Andric          InputIterator2 first2, InputIterator2 last2); // **C++14**
11510b57cec5SDimitry Andric
11520b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2, class BinaryPredicate>
11530b57cec5SDimitry Andric    constexpr bool      // constexpr in C++20
11540b57cec5SDimitry Andric    equal(InputIterator1 first1, InputIterator1 last1,
11550b57cec5SDimitry Andric          InputIterator2 first2, BinaryPredicate pred);
11560b57cec5SDimitry Andric
11570b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2, class BinaryPredicate>
11580b57cec5SDimitry Andric    constexpr bool      // constexpr in C++20
11590b57cec5SDimitry Andric    equal(InputIterator1 first1, InputIterator1 last1,
11600b57cec5SDimitry Andric          InputIterator2 first2, InputIterator2 last2,
11610b57cec5SDimitry Andric          BinaryPredicate pred); // **C++14**
11620b57cec5SDimitry Andric
11630b57cec5SDimitry Andrictemplate<class ForwardIterator1, class ForwardIterator2>
11640b57cec5SDimitry Andric    constexpr bool      // constexpr in C++20
11650b57cec5SDimitry Andric    is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
11660b57cec5SDimitry Andric                   ForwardIterator2 first2);
11670b57cec5SDimitry Andric
11680b57cec5SDimitry Andrictemplate<class ForwardIterator1, class ForwardIterator2>
11690b57cec5SDimitry Andric    constexpr bool      // constexpr in C++20
11700b57cec5SDimitry Andric    is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
11710b57cec5SDimitry Andric                   ForwardIterator2 first2, ForwardIterator2 last2); // **C++14**
11720b57cec5SDimitry Andric
11730b57cec5SDimitry Andrictemplate<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
11740b57cec5SDimitry Andric    constexpr bool      // constexpr in C++20
11750b57cec5SDimitry Andric    is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
11760b57cec5SDimitry Andric                   ForwardIterator2 first2, BinaryPredicate pred);
11770b57cec5SDimitry Andric
11780b57cec5SDimitry Andrictemplate<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
11790b57cec5SDimitry Andric    constexpr bool      // constexpr in C++20
11800b57cec5SDimitry Andric    is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
11810b57cec5SDimitry Andric                   ForwardIterator2 first2, ForwardIterator2 last2,
11820b57cec5SDimitry Andric                   BinaryPredicate pred);  // **C++14**
11830b57cec5SDimitry Andric
11840b57cec5SDimitry Andrictemplate <class ForwardIterator1, class ForwardIterator2>
11850b57cec5SDimitry Andric    constexpr ForwardIterator1      // constexpr in C++20
11860b57cec5SDimitry Andric    search(ForwardIterator1 first1, ForwardIterator1 last1,
11870b57cec5SDimitry Andric           ForwardIterator2 first2, ForwardIterator2 last2);
11880b57cec5SDimitry Andric
11890b57cec5SDimitry Andrictemplate <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
11900b57cec5SDimitry Andric    constexpr ForwardIterator1      // constexpr in C++20
11910b57cec5SDimitry Andric    search(ForwardIterator1 first1, ForwardIterator1 last1,
11920b57cec5SDimitry Andric           ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
11930b57cec5SDimitry Andric
11940b57cec5SDimitry Andrictemplate <class ForwardIterator, class Size, class T>
11950b57cec5SDimitry Andric    constexpr ForwardIterator       // constexpr in C++20
11960b57cec5SDimitry Andric    search_n(ForwardIterator first, ForwardIterator last, Size count, const T& value);
11970b57cec5SDimitry Andric
11980b57cec5SDimitry Andrictemplate <class ForwardIterator, class Size, class T, class BinaryPredicate>
11990b57cec5SDimitry Andric    constexpr ForwardIterator       // constexpr in C++20
12000b57cec5SDimitry Andric    search_n(ForwardIterator first, ForwardIterator last,
12010b57cec5SDimitry Andric             Size count, const T& value, BinaryPredicate pred);
12020b57cec5SDimitry Andric
12030b57cec5SDimitry Andrictemplate <class InputIterator, class OutputIterator>
1204480093f4SDimitry Andric    constexpr OutputIterator      // constexpr in C++20
12050b57cec5SDimitry Andric    copy(InputIterator first, InputIterator last, OutputIterator result);
12060b57cec5SDimitry Andric
12070b57cec5SDimitry Andrictemplate<class InputIterator, class OutputIterator, class Predicate>
1208480093f4SDimitry Andric    constexpr OutputIterator      // constexpr in C++20
12090b57cec5SDimitry Andric    copy_if(InputIterator first, InputIterator last,
12100b57cec5SDimitry Andric            OutputIterator result, Predicate pred);
12110b57cec5SDimitry Andric
12120b57cec5SDimitry Andrictemplate<class InputIterator, class Size, class OutputIterator>
1213480093f4SDimitry Andric    constexpr OutputIterator      // constexpr in C++20
12140b57cec5SDimitry Andric    copy_n(InputIterator first, Size n, OutputIterator result);
12150b57cec5SDimitry Andric
12160b57cec5SDimitry Andrictemplate <class BidirectionalIterator1, class BidirectionalIterator2>
1217480093f4SDimitry Andric    constexpr BidirectionalIterator2      // constexpr in C++20
12180b57cec5SDimitry Andric    copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last,
12190b57cec5SDimitry Andric                  BidirectionalIterator2 result);
12200b57cec5SDimitry Andric
122181ad6265SDimitry Andric// [alg.move], move
122281ad6265SDimitry Andrictemplate<class InputIterator, class OutputIterator>
122381ad6265SDimitry Andric    constexpr OutputIterator move(InputIterator first, InputIterator last,
122481ad6265SDimitry Andric                                OutputIterator result);
122581ad6265SDimitry Andric
122681ad6265SDimitry Andrictemplate<class BidirectionalIterator1, class BidirectionalIterator2>
122781ad6265SDimitry Andric    constexpr BidirectionalIterator2
122881ad6265SDimitry Andric    move_backward(BidirectionalIterator1 first, BidirectionalIterator1 last,
122981ad6265SDimitry Andric                  BidirectionalIterator2 result);
123081ad6265SDimitry Andric
12310b57cec5SDimitry Andrictemplate <class ForwardIterator1, class ForwardIterator2>
1232e8d8bef9SDimitry Andric    constexpr ForwardIterator2    // constexpr in C++20
12330b57cec5SDimitry Andric    swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2);
12340b57cec5SDimitry Andric
123581ad6265SDimitry Andricnamespace ranges {
123681ad6265SDimitry Andric    template<class I1, class I2>
123781ad6265SDimitry Andric    using swap_ranges_result = in_in_result<I1, I2>;
123881ad6265SDimitry Andric
123981ad6265SDimitry Andrictemplate<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2>
124081ad6265SDimitry Andric        requires indirectly_swappable<I1, I2>
124181ad6265SDimitry Andric    constexpr ranges::swap_ranges_result<I1, I2>
124281ad6265SDimitry Andric        swap_ranges(I1 first1, S1 last1, I2 first2, S2 last2);
124381ad6265SDimitry Andric
124481ad6265SDimitry Andrictemplate<input_range R1, input_range R2>
124581ad6265SDimitry Andric        requires indirectly_swappable<iterator_t<R1>, iterator_t<R2>>
124681ad6265SDimitry Andric    constexpr ranges::swap_ranges_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>>
124781ad6265SDimitry Andric        swap_ranges(R1&& r1, R2&& r2);
124881ad6265SDimitry Andric}
124981ad6265SDimitry Andric
12500b57cec5SDimitry Andrictemplate <class ForwardIterator1, class ForwardIterator2>
1251e8d8bef9SDimitry Andric    constexpr void                // constexpr in C++20
12520b57cec5SDimitry Andric    iter_swap(ForwardIterator1 a, ForwardIterator2 b);
12530b57cec5SDimitry Andric
12540b57cec5SDimitry Andrictemplate <class InputIterator, class OutputIterator, class UnaryOperation>
12550b57cec5SDimitry Andric    constexpr OutputIterator      // constexpr in C++20
12560b57cec5SDimitry Andric    transform(InputIterator first, InputIterator last, OutputIterator result, UnaryOperation op);
12570b57cec5SDimitry Andric
12580b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2, class OutputIterator, class BinaryOperation>
12590b57cec5SDimitry Andric    constexpr OutputIterator      // constexpr in C++20
12600b57cec5SDimitry Andric    transform(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2,
12610b57cec5SDimitry Andric              OutputIterator result, BinaryOperation binary_op);
12620b57cec5SDimitry Andric
12630b57cec5SDimitry Andrictemplate <class ForwardIterator, class T>
12640b57cec5SDimitry Andric    constexpr void      // constexpr in C++20
12650b57cec5SDimitry Andric    replace(ForwardIterator first, ForwardIterator last, const T& old_value, const T& new_value);
12660b57cec5SDimitry Andric
12670b57cec5SDimitry Andrictemplate <class ForwardIterator, class Predicate, class T>
12680b57cec5SDimitry Andric    constexpr void      // constexpr in C++20
12690b57cec5SDimitry Andric    replace_if(ForwardIterator first, ForwardIterator last, Predicate pred, const T& new_value);
12700b57cec5SDimitry Andric
12710b57cec5SDimitry Andrictemplate <class InputIterator, class OutputIterator, class T>
12720b57cec5SDimitry Andric    constexpr OutputIterator      // constexpr in C++20
12730b57cec5SDimitry Andric    replace_copy(InputIterator first, InputIterator last, OutputIterator result,
12740b57cec5SDimitry Andric                 const T& old_value, const T& new_value);
12750b57cec5SDimitry Andric
12760b57cec5SDimitry Andrictemplate <class InputIterator, class OutputIterator, class Predicate, class T>
12770b57cec5SDimitry Andric    constexpr OutputIterator      // constexpr in C++20
12780b57cec5SDimitry Andric    replace_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred, const T& new_value);
12790b57cec5SDimitry Andric
12800b57cec5SDimitry Andrictemplate <class ForwardIterator, class T>
12810b57cec5SDimitry Andric    constexpr void      // constexpr in C++20
12820b57cec5SDimitry Andric    fill(ForwardIterator first, ForwardIterator last, const T& value);
12830b57cec5SDimitry Andric
12840b57cec5SDimitry Andrictemplate <class OutputIterator, class Size, class T>
12850b57cec5SDimitry Andric    constexpr OutputIterator      // constexpr in C++20
12860b57cec5SDimitry Andric    fill_n(OutputIterator first, Size n, const T& value);
12870b57cec5SDimitry Andric
12880b57cec5SDimitry Andrictemplate <class ForwardIterator, class Generator>
12890b57cec5SDimitry Andric    constexpr void      // constexpr in C++20
12900b57cec5SDimitry Andric    generate(ForwardIterator first, ForwardIterator last, Generator gen);
12910b57cec5SDimitry Andric
12920b57cec5SDimitry Andrictemplate <class OutputIterator, class Size, class Generator>
12930b57cec5SDimitry Andric    constexpr OutputIterator      // constexpr in C++20
12940b57cec5SDimitry Andric    generate_n(OutputIterator first, Size n, Generator gen);
12950b57cec5SDimitry Andric
12960b57cec5SDimitry Andrictemplate <class ForwardIterator, class T>
12970b57cec5SDimitry Andric    constexpr ForwardIterator     // constexpr in C++20
12980b57cec5SDimitry Andric    remove(ForwardIterator first, ForwardIterator last, const T& value);
12990b57cec5SDimitry Andric
13000b57cec5SDimitry Andrictemplate <class ForwardIterator, class Predicate>
13010b57cec5SDimitry Andric    constexpr ForwardIterator     // constexpr in C++20
13020b57cec5SDimitry Andric    remove_if(ForwardIterator first, ForwardIterator last, Predicate pred);
13030b57cec5SDimitry Andric
13040b57cec5SDimitry Andrictemplate <class InputIterator, class OutputIterator, class T>
13050b57cec5SDimitry Andric    constexpr OutputIterator     // constexpr in C++20
13060b57cec5SDimitry Andric    remove_copy(InputIterator first, InputIterator last, OutputIterator result, const T& value);
13070b57cec5SDimitry Andric
13080b57cec5SDimitry Andrictemplate <class InputIterator, class OutputIterator, class Predicate>
13090b57cec5SDimitry Andric    constexpr OutputIterator     // constexpr in C++20
13100b57cec5SDimitry Andric    remove_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred);
13110b57cec5SDimitry Andric
13120b57cec5SDimitry Andrictemplate <class ForwardIterator>
1313e8d8bef9SDimitry Andric    constexpr ForwardIterator    // constexpr in C++20
13140b57cec5SDimitry Andric    unique(ForwardIterator first, ForwardIterator last);
13150b57cec5SDimitry Andric
13160b57cec5SDimitry Andrictemplate <class ForwardIterator, class BinaryPredicate>
1317e8d8bef9SDimitry Andric    constexpr ForwardIterator    // constexpr in C++20
13180b57cec5SDimitry Andric    unique(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
13190b57cec5SDimitry Andric
13200b57cec5SDimitry Andrictemplate <class InputIterator, class OutputIterator>
1321e8d8bef9SDimitry Andric    constexpr OutputIterator     // constexpr in C++20
13220b57cec5SDimitry Andric    unique_copy(InputIterator first, InputIterator last, OutputIterator result);
13230b57cec5SDimitry Andric
13240b57cec5SDimitry Andrictemplate <class InputIterator, class OutputIterator, class BinaryPredicate>
1325e8d8bef9SDimitry Andric    constexpr OutputIterator     // constexpr in C++20
13260b57cec5SDimitry Andric    unique_copy(InputIterator first, InputIterator last, OutputIterator result, BinaryPredicate pred);
13270b57cec5SDimitry Andric
13280b57cec5SDimitry Andrictemplate <class BidirectionalIterator>
1329e8d8bef9SDimitry Andric    constexpr void               // constexpr in C++20
13300b57cec5SDimitry Andric    reverse(BidirectionalIterator first, BidirectionalIterator last);
13310b57cec5SDimitry Andric
13320b57cec5SDimitry Andrictemplate <class BidirectionalIterator, class OutputIterator>
13330b57cec5SDimitry Andric    constexpr OutputIterator       // constexpr in C++20
13340b57cec5SDimitry Andric    reverse_copy(BidirectionalIterator first, BidirectionalIterator last, OutputIterator result);
13350b57cec5SDimitry Andric
13360b57cec5SDimitry Andrictemplate <class ForwardIterator>
1337e8d8bef9SDimitry Andric    constexpr ForwardIterator      // constexpr in C++20
13380b57cec5SDimitry Andric    rotate(ForwardIterator first, ForwardIterator middle, ForwardIterator last);
13390b57cec5SDimitry Andric
13400b57cec5SDimitry Andrictemplate <class ForwardIterator, class OutputIterator>
1341e8d8bef9SDimitry Andric    constexpr OutputIterator       // constexpr in C++20
13420b57cec5SDimitry Andric    rotate_copy(ForwardIterator first, ForwardIterator middle, ForwardIterator last, OutputIterator result);
13430b57cec5SDimitry Andric
13440b57cec5SDimitry Andrictemplate <class RandomAccessIterator>
13450b57cec5SDimitry Andric    void
13460b57cec5SDimitry Andric    random_shuffle(RandomAccessIterator first, RandomAccessIterator last); // deprecated in C++14, removed in C++17
13470b57cec5SDimitry Andric
13480b57cec5SDimitry Andrictemplate <class RandomAccessIterator, class RandomNumberGenerator>
13490b57cec5SDimitry Andric    void
13500b57cec5SDimitry Andric    random_shuffle(RandomAccessIterator first, RandomAccessIterator last,
13510b57cec5SDimitry Andric                   RandomNumberGenerator& rand);  // deprecated in C++14, removed in C++17
13520b57cec5SDimitry Andric
13530b57cec5SDimitry Andrictemplate<class PopulationIterator, class SampleIterator,
13540b57cec5SDimitry Andric         class Distance, class UniformRandomBitGenerator>
13550b57cec5SDimitry Andric    SampleIterator sample(PopulationIterator first, PopulationIterator last,
13560b57cec5SDimitry Andric                          SampleIterator out, Distance n,
13570b57cec5SDimitry Andric                          UniformRandomBitGenerator&& g); // C++17
13580b57cec5SDimitry Andric
13590b57cec5SDimitry Andrictemplate<class RandomAccessIterator, class UniformRandomNumberGenerator>
13600b57cec5SDimitry Andric    void shuffle(RandomAccessIterator first, RandomAccessIterator last,
13610b57cec5SDimitry Andric                 UniformRandomNumberGenerator&& g);
13620b57cec5SDimitry Andric
1363e8d8bef9SDimitry Andrictemplate<class ForwardIterator>
1364e8d8bef9SDimitry Andric  constexpr ForwardIterator
1365e8d8bef9SDimitry Andric    shift_left(ForwardIterator first, ForwardIterator last,
1366e8d8bef9SDimitry Andric               typename iterator_traits<ForwardIterator>::difference_type n); // C++20
1367e8d8bef9SDimitry Andric
1368e8d8bef9SDimitry Andrictemplate<class ForwardIterator>
1369e8d8bef9SDimitry Andric  constexpr ForwardIterator
1370e8d8bef9SDimitry Andric    shift_right(ForwardIterator first, ForwardIterator last,
1371e8d8bef9SDimitry Andric                typename iterator_traits<ForwardIterator>::difference_type n); // C++20
1372e8d8bef9SDimitry Andric
13730b57cec5SDimitry Andrictemplate <class InputIterator, class Predicate>
13740b57cec5SDimitry Andric    constexpr bool  // constexpr in C++20
13750b57cec5SDimitry Andric    is_partitioned(InputIterator first, InputIterator last, Predicate pred);
13760b57cec5SDimitry Andric
13770b57cec5SDimitry Andrictemplate <class ForwardIterator, class Predicate>
1378e8d8bef9SDimitry Andric    constexpr ForwardIterator  // constexpr in C++20
13790b57cec5SDimitry Andric    partition(ForwardIterator first, ForwardIterator last, Predicate pred);
13800b57cec5SDimitry Andric
13810b57cec5SDimitry Andrictemplate <class InputIterator, class OutputIterator1,
13820b57cec5SDimitry Andric          class OutputIterator2, class Predicate>
13830b57cec5SDimitry Andric    constexpr pair<OutputIterator1, OutputIterator2>   // constexpr in C++20
13840b57cec5SDimitry Andric    partition_copy(InputIterator first, InputIterator last,
13850b57cec5SDimitry Andric                   OutputIterator1 out_true, OutputIterator2 out_false,
13860b57cec5SDimitry Andric                   Predicate pred);
13870b57cec5SDimitry Andric
13880b57cec5SDimitry Andrictemplate <class ForwardIterator, class Predicate>
13890b57cec5SDimitry Andric    ForwardIterator
13900b57cec5SDimitry Andric    stable_partition(ForwardIterator first, ForwardIterator last, Predicate pred);
13910b57cec5SDimitry Andric
13920b57cec5SDimitry Andrictemplate<class ForwardIterator, class Predicate>
13930b57cec5SDimitry Andric    constexpr ForwardIterator  // constexpr in C++20
13940b57cec5SDimitry Andric    partition_point(ForwardIterator first, ForwardIterator last, Predicate pred);
13950b57cec5SDimitry Andric
13960b57cec5SDimitry Andrictemplate <class ForwardIterator>
13970b57cec5SDimitry Andric    constexpr bool  // constexpr in C++20
13980b57cec5SDimitry Andric    is_sorted(ForwardIterator first, ForwardIterator last);
13990b57cec5SDimitry Andric
14000b57cec5SDimitry Andrictemplate <class ForwardIterator, class Compare>
1401e8d8bef9SDimitry Andric    constexpr bool  // constexpr in C++20
14020b57cec5SDimitry Andric    is_sorted(ForwardIterator first, ForwardIterator last, Compare comp);
14030b57cec5SDimitry Andric
14040b57cec5SDimitry Andrictemplate<class ForwardIterator>
14050b57cec5SDimitry Andric    constexpr ForwardIterator    // constexpr in C++20
14060b57cec5SDimitry Andric    is_sorted_until(ForwardIterator first, ForwardIterator last);
14070b57cec5SDimitry Andric
14080b57cec5SDimitry Andrictemplate <class ForwardIterator, class Compare>
14090b57cec5SDimitry Andric    constexpr ForwardIterator    // constexpr in C++20
14100b57cec5SDimitry Andric    is_sorted_until(ForwardIterator first, ForwardIterator last, Compare comp);
14110b57cec5SDimitry Andric
14120b57cec5SDimitry Andrictemplate <class RandomAccessIterator>
1413fe6060f1SDimitry Andric    constexpr void               // constexpr in C++20
14140b57cec5SDimitry Andric    sort(RandomAccessIterator first, RandomAccessIterator last);
14150b57cec5SDimitry Andric
14160b57cec5SDimitry Andrictemplate <class RandomAccessIterator, class Compare>
1417fe6060f1SDimitry Andric    constexpr void               // constexpr in C++20
14180b57cec5SDimitry Andric    sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
14190b57cec5SDimitry Andric
14200b57cec5SDimitry Andrictemplate <class RandomAccessIterator>
14210b57cec5SDimitry Andric    void
14220b57cec5SDimitry Andric    stable_sort(RandomAccessIterator first, RandomAccessIterator last);
14230b57cec5SDimitry Andric
14240b57cec5SDimitry Andrictemplate <class RandomAccessIterator, class Compare>
14250b57cec5SDimitry Andric    void
14260b57cec5SDimitry Andric    stable_sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
14270b57cec5SDimitry Andric
14280b57cec5SDimitry Andrictemplate <class RandomAccessIterator>
1429fe6060f1SDimitry Andric    constexpr void                    // constexpr in C++20
14300b57cec5SDimitry Andric    partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last);
14310b57cec5SDimitry Andric
14320b57cec5SDimitry Andrictemplate <class RandomAccessIterator, class Compare>
1433fe6060f1SDimitry Andric    constexpr void                    // constexpr in C++20
14340b57cec5SDimitry Andric    partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last, Compare comp);
14350b57cec5SDimitry Andric
14360b57cec5SDimitry Andrictemplate <class InputIterator, class RandomAccessIterator>
1437fe6060f1SDimitry Andric    constexpr RandomAccessIterator    // constexpr in C++20
14380b57cec5SDimitry Andric    partial_sort_copy(InputIterator first, InputIterator last,
14390b57cec5SDimitry Andric                      RandomAccessIterator result_first, RandomAccessIterator result_last);
14400b57cec5SDimitry Andric
14410b57cec5SDimitry Andrictemplate <class InputIterator, class RandomAccessIterator, class Compare>
1442fe6060f1SDimitry Andric    constexpr RandomAccessIterator    // constexpr in C++20
14430b57cec5SDimitry Andric    partial_sort_copy(InputIterator first, InputIterator last,
14440b57cec5SDimitry Andric                      RandomAccessIterator result_first, RandomAccessIterator result_last, Compare comp);
14450b57cec5SDimitry Andric
14460b57cec5SDimitry Andrictemplate <class RandomAccessIterator>
1447fe6060f1SDimitry Andric    constexpr void                    // constexpr in C++20
14480b57cec5SDimitry Andric    nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last);
14490b57cec5SDimitry Andric
14500b57cec5SDimitry Andrictemplate <class RandomAccessIterator, class Compare>
1451fe6060f1SDimitry Andric    constexpr void                    // constexpr in C++20
14520b57cec5SDimitry Andric    nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last, Compare comp);
14530b57cec5SDimitry Andric
14540b57cec5SDimitry Andrictemplate <class ForwardIterator, class T>
14550b57cec5SDimitry Andric    constexpr ForwardIterator                         // constexpr in C++20
14560b57cec5SDimitry Andric    lower_bound(ForwardIterator first, ForwardIterator last, const T& value);
14570b57cec5SDimitry Andric
14580b57cec5SDimitry Andrictemplate <class ForwardIterator, class T, class Compare>
14590b57cec5SDimitry Andric    constexpr ForwardIterator                         // constexpr in C++20
14600b57cec5SDimitry Andric    lower_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
14610b57cec5SDimitry Andric
14620b57cec5SDimitry Andrictemplate <class ForwardIterator, class T>
14630b57cec5SDimitry Andric    constexpr ForwardIterator                         // constexpr in C++20
14640b57cec5SDimitry Andric    upper_bound(ForwardIterator first, ForwardIterator last, const T& value);
14650b57cec5SDimitry Andric
14660b57cec5SDimitry Andrictemplate <class ForwardIterator, class T, class Compare>
14670b57cec5SDimitry Andric    constexpr ForwardIterator                         // constexpr in C++20
14680b57cec5SDimitry Andric    upper_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
14690b57cec5SDimitry Andric
14700b57cec5SDimitry Andrictemplate <class ForwardIterator, class T>
14710b57cec5SDimitry Andric    constexpr pair<ForwardIterator, ForwardIterator>  // constexpr in C++20
14720b57cec5SDimitry Andric    equal_range(ForwardIterator first, ForwardIterator last, const T& value);
14730b57cec5SDimitry Andric
14740b57cec5SDimitry Andrictemplate <class ForwardIterator, class T, class Compare>
14750b57cec5SDimitry Andric    constexpr pair<ForwardIterator, ForwardIterator>  // constexpr in C++20
14760b57cec5SDimitry Andric    equal_range(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
14770b57cec5SDimitry Andric
14780b57cec5SDimitry Andrictemplate <class ForwardIterator, class T>
14790b57cec5SDimitry Andric    constexpr bool                                    // constexpr in C++20
14800b57cec5SDimitry Andric    binary_search(ForwardIterator first, ForwardIterator last, const T& value);
14810b57cec5SDimitry Andric
14820b57cec5SDimitry Andrictemplate <class ForwardIterator, class T, class Compare>
14830b57cec5SDimitry Andric    constexpr bool                                    // constexpr in C++20
14840b57cec5SDimitry Andric    binary_search(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
14850b57cec5SDimitry Andric
14860b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2, class OutputIterator>
1487e8d8bef9SDimitry Andric    constexpr OutputIterator                          // constexpr in C++20
14880b57cec5SDimitry Andric    merge(InputIterator1 first1, InputIterator1 last1,
14890b57cec5SDimitry Andric          InputIterator2 first2, InputIterator2 last2, OutputIterator result);
14900b57cec5SDimitry Andric
14910b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
1492e8d8bef9SDimitry Andric    constexpr OutputIterator                          // constexpr in C++20
14930b57cec5SDimitry Andric    merge(InputIterator1 first1, InputIterator1 last1,
14940b57cec5SDimitry Andric          InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
14950b57cec5SDimitry Andric
14960b57cec5SDimitry Andrictemplate <class BidirectionalIterator>
14970b57cec5SDimitry Andric    void
14980b57cec5SDimitry Andric    inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last);
14990b57cec5SDimitry Andric
15000b57cec5SDimitry Andrictemplate <class BidirectionalIterator, class Compare>
15010b57cec5SDimitry Andric    void
15020b57cec5SDimitry Andric    inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last, Compare comp);
15030b57cec5SDimitry Andric
15040b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2>
15050b57cec5SDimitry Andric    constexpr bool                                    // constexpr in C++20
15060b57cec5SDimitry Andric    includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
15070b57cec5SDimitry Andric
15080b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2, class Compare>
15090b57cec5SDimitry Andric    constexpr bool                                    // constexpr in C++20
15100b57cec5SDimitry Andric    includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, Compare comp);
15110b57cec5SDimitry Andric
15120b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2, class OutputIterator>
1513e8d8bef9SDimitry Andric    constexpr OutputIterator                          // constexpr in C++20
15140b57cec5SDimitry Andric    set_union(InputIterator1 first1, InputIterator1 last1,
15150b57cec5SDimitry Andric              InputIterator2 first2, InputIterator2 last2, OutputIterator result);
15160b57cec5SDimitry Andric
15170b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
1518e8d8bef9SDimitry Andric    constexpr OutputIterator                          // constexpr in C++20
15190b57cec5SDimitry Andric    set_union(InputIterator1 first1, InputIterator1 last1,
15200b57cec5SDimitry Andric              InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
15210b57cec5SDimitry Andric
15220b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2, class OutputIterator>
15230b57cec5SDimitry Andric    constexpr OutputIterator                         // constexpr in C++20
15240b57cec5SDimitry Andric    set_intersection(InputIterator1 first1, InputIterator1 last1,
15250b57cec5SDimitry Andric                     InputIterator2 first2, InputIterator2 last2, OutputIterator result);
15260b57cec5SDimitry Andric
15270b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
15280b57cec5SDimitry Andric    constexpr OutputIterator                         // constexpr in C++20
15290b57cec5SDimitry Andric    set_intersection(InputIterator1 first1, InputIterator1 last1,
15300b57cec5SDimitry Andric                     InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
15310b57cec5SDimitry Andric
15320b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2, class OutputIterator>
1533e8d8bef9SDimitry Andric    constexpr OutputIterator                         // constexpr in C++20
15340b57cec5SDimitry Andric    set_difference(InputIterator1 first1, InputIterator1 last1,
15350b57cec5SDimitry Andric                   InputIterator2 first2, InputIterator2 last2, OutputIterator result);
15360b57cec5SDimitry Andric
15370b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
1538e8d8bef9SDimitry Andric    constexpr OutputIterator                         // constexpr in C++20
15390b57cec5SDimitry Andric    set_difference(InputIterator1 first1, InputIterator1 last1,
15400b57cec5SDimitry Andric                   InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
15410b57cec5SDimitry Andric
15420b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2, class OutputIterator>
1543e8d8bef9SDimitry Andric    constexpr OutputIterator                         // constexpr in C++20
15440b57cec5SDimitry Andric    set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
15450b57cec5SDimitry Andric                             InputIterator2 first2, InputIterator2 last2, OutputIterator result);
15460b57cec5SDimitry Andric
15470b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
1548e8d8bef9SDimitry Andric    constexpr OutputIterator                         // constexpr in C++20
15490b57cec5SDimitry Andric    set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
15500b57cec5SDimitry Andric                             InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
15510b57cec5SDimitry Andric
15520b57cec5SDimitry Andrictemplate <class RandomAccessIterator>
1553fe6060f1SDimitry Andric    constexpr void                                   // constexpr in C++20
15540b57cec5SDimitry Andric    push_heap(RandomAccessIterator first, RandomAccessIterator last);
15550b57cec5SDimitry Andric
15560b57cec5SDimitry Andrictemplate <class RandomAccessIterator, class Compare>
1557fe6060f1SDimitry Andric    constexpr void                                   // constexpr in C++20
15580b57cec5SDimitry Andric    push_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
15590b57cec5SDimitry Andric
15600b57cec5SDimitry Andrictemplate <class RandomAccessIterator>
1561fe6060f1SDimitry Andric    constexpr void                                   // constexpr in C++20
15620b57cec5SDimitry Andric    pop_heap(RandomAccessIterator first, RandomAccessIterator last);
15630b57cec5SDimitry Andric
15640b57cec5SDimitry Andrictemplate <class RandomAccessIterator, class Compare>
1565fe6060f1SDimitry Andric    constexpr void                                   // constexpr in C++20
15660b57cec5SDimitry Andric    pop_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
15670b57cec5SDimitry Andric
15680b57cec5SDimitry Andrictemplate <class RandomAccessIterator>
1569fe6060f1SDimitry Andric    constexpr void                                   // constexpr in C++20
15700b57cec5SDimitry Andric    make_heap(RandomAccessIterator first, RandomAccessIterator last);
15710b57cec5SDimitry Andric
15720b57cec5SDimitry Andrictemplate <class RandomAccessIterator, class Compare>
1573fe6060f1SDimitry Andric    constexpr void                                   // constexpr in C++20
15740b57cec5SDimitry Andric    make_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
15750b57cec5SDimitry Andric
15760b57cec5SDimitry Andrictemplate <class RandomAccessIterator>
1577fe6060f1SDimitry Andric    constexpr void                                   // constexpr in C++20
15780b57cec5SDimitry Andric    sort_heap(RandomAccessIterator first, RandomAccessIterator last);
15790b57cec5SDimitry Andric
15800b57cec5SDimitry Andrictemplate <class RandomAccessIterator, class Compare>
1581fe6060f1SDimitry Andric    constexpr void                                   // constexpr in C++20
15820b57cec5SDimitry Andric    sort_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
15830b57cec5SDimitry Andric
15840b57cec5SDimitry Andrictemplate <class RandomAccessIterator>
15850b57cec5SDimitry Andric    constexpr bool   // constexpr in C++20
15860b57cec5SDimitry Andric    is_heap(RandomAccessIterator first, RandomAccessiterator last);
15870b57cec5SDimitry Andric
15880b57cec5SDimitry Andrictemplate <class RandomAccessIterator, class Compare>
15890b57cec5SDimitry Andric    constexpr bool   // constexpr in C++20
15900b57cec5SDimitry Andric    is_heap(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
15910b57cec5SDimitry Andric
15920b57cec5SDimitry Andrictemplate <class RandomAccessIterator>
15930b57cec5SDimitry Andric    constexpr RandomAccessIterator   // constexpr in C++20
15940b57cec5SDimitry Andric    is_heap_until(RandomAccessIterator first, RandomAccessiterator last);
15950b57cec5SDimitry Andric
15960b57cec5SDimitry Andrictemplate <class RandomAccessIterator, class Compare>
15970b57cec5SDimitry Andric    constexpr RandomAccessIterator   // constexpr in C++20
15980b57cec5SDimitry Andric    is_heap_until(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
15990b57cec5SDimitry Andric
16000b57cec5SDimitry Andrictemplate <class ForwardIterator>
1601e8d8bef9SDimitry Andric    constexpr ForwardIterator        // constexpr in C++14
1602e8d8bef9SDimitry Andric    min_element(ForwardIterator first, ForwardIterator last);
16030b57cec5SDimitry Andric
16040b57cec5SDimitry Andrictemplate <class ForwardIterator, class Compare>
1605e8d8bef9SDimitry Andric    constexpr ForwardIterator        // constexpr in C++14
1606e8d8bef9SDimitry Andric    min_element(ForwardIterator first, ForwardIterator last, Compare comp);
16070b57cec5SDimitry Andric
16080b57cec5SDimitry Andrictemplate <class T>
1609e8d8bef9SDimitry Andric    constexpr const T&               // constexpr in C++14
1610e8d8bef9SDimitry Andric    min(const T& a, const T& b);
16110b57cec5SDimitry Andric
16120b57cec5SDimitry Andrictemplate <class T, class Compare>
1613e8d8bef9SDimitry Andric    constexpr const T&               // constexpr in C++14
1614e8d8bef9SDimitry Andric    min(const T& a, const T& b, Compare comp);
16150b57cec5SDimitry Andric
16160b57cec5SDimitry Andrictemplate<class T>
1617e8d8bef9SDimitry Andric    constexpr T                      // constexpr in C++14
1618e8d8bef9SDimitry Andric    min(initializer_list<T> t);
16190b57cec5SDimitry Andric
16200b57cec5SDimitry Andrictemplate<class T, class Compare>
1621e8d8bef9SDimitry Andric    constexpr T                      // constexpr in C++14
1622e8d8bef9SDimitry Andric    min(initializer_list<T> t, Compare comp);
16230b57cec5SDimitry Andric
16240b57cec5SDimitry Andrictemplate<class T>
16250b57cec5SDimitry Andric    constexpr const T& clamp(const T& v, const T& lo, const T& hi);               // C++17
16260b57cec5SDimitry Andric
16270b57cec5SDimitry Andrictemplate<class T, class Compare>
16280b57cec5SDimitry Andric    constexpr const T& clamp(const T& v, const T& lo, const T& hi, Compare comp); // C++17
16290b57cec5SDimitry Andric
16300b57cec5SDimitry Andrictemplate <class ForwardIterator>
1631e8d8bef9SDimitry Andric    constexpr ForwardIterator        // constexpr in C++14
1632e8d8bef9SDimitry Andric    max_element(ForwardIterator first, ForwardIterator last);
16330b57cec5SDimitry Andric
16340b57cec5SDimitry Andrictemplate <class ForwardIterator, class Compare>
1635e8d8bef9SDimitry Andric    constexpr ForwardIterator        // constexpr in C++14
1636e8d8bef9SDimitry Andric    max_element(ForwardIterator first, ForwardIterator last, Compare comp);
16370b57cec5SDimitry Andric
16380b57cec5SDimitry Andrictemplate <class T>
1639e8d8bef9SDimitry Andric    constexpr const T&               // constexpr in C++14
1640e8d8bef9SDimitry Andric    max(const T& a, const T& b);
16410b57cec5SDimitry Andric
16420b57cec5SDimitry Andrictemplate <class T, class Compare>
1643e8d8bef9SDimitry Andric    constexpr const T&               // constexpr in C++14
1644e8d8bef9SDimitry Andric    max(const T& a, const T& b, Compare comp);
16450b57cec5SDimitry Andric
16460b57cec5SDimitry Andrictemplate<class T>
1647e8d8bef9SDimitry Andric    constexpr T                      // constexpr in C++14
1648e8d8bef9SDimitry Andric    max(initializer_list<T> t);
16490b57cec5SDimitry Andric
16500b57cec5SDimitry Andrictemplate<class T, class Compare>
1651e8d8bef9SDimitry Andric    constexpr T                      // constexpr in C++14
1652e8d8bef9SDimitry Andric    max(initializer_list<T> t, Compare comp);
16530b57cec5SDimitry Andric
16540b57cec5SDimitry Andrictemplate<class ForwardIterator>
1655e8d8bef9SDimitry Andric    constexpr pair<ForwardIterator, ForwardIterator>  // constexpr in C++14
1656e8d8bef9SDimitry Andric    minmax_element(ForwardIterator first, ForwardIterator last);
16570b57cec5SDimitry Andric
16580b57cec5SDimitry Andrictemplate<class ForwardIterator, class Compare>
1659e8d8bef9SDimitry Andric    constexpr pair<ForwardIterator, ForwardIterator>  // constexpr in C++14
1660e8d8bef9SDimitry Andric    minmax_element(ForwardIterator first, ForwardIterator last, Compare comp);
16610b57cec5SDimitry Andric
16620b57cec5SDimitry Andrictemplate<class T>
1663e8d8bef9SDimitry Andric    constexpr pair<const T&, const T&>  // constexpr in C++14
1664e8d8bef9SDimitry Andric    minmax(const T& a, const T& b);
16650b57cec5SDimitry Andric
16660b57cec5SDimitry Andrictemplate<class T, class Compare>
1667e8d8bef9SDimitry Andric    constexpr pair<const T&, const T&>  // constexpr in C++14
1668e8d8bef9SDimitry Andric    minmax(const T& a, const T& b, Compare comp);
16690b57cec5SDimitry Andric
16700b57cec5SDimitry Andrictemplate<class T>
1671e8d8bef9SDimitry Andric    constexpr pair<T, T>                // constexpr in C++14
1672e8d8bef9SDimitry Andric    minmax(initializer_list<T> t);
16730b57cec5SDimitry Andric
16740b57cec5SDimitry Andrictemplate<class T, class Compare>
1675e8d8bef9SDimitry Andric    constexpr pair<T, T>                // constexpr in C++14
1676e8d8bef9SDimitry Andric    minmax(initializer_list<T> t, Compare comp);
16770b57cec5SDimitry Andric
16780b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2>
16790b57cec5SDimitry Andric    constexpr bool     // constexpr in C++20
16800b57cec5SDimitry Andric    lexicographical_compare(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
16810b57cec5SDimitry Andric
16820b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2, class Compare>
16830b57cec5SDimitry Andric    constexpr bool     // constexpr in C++20
16840b57cec5SDimitry Andric    lexicographical_compare(InputIterator1 first1, InputIterator1 last1,
16850b57cec5SDimitry Andric                            InputIterator2 first2, InputIterator2 last2, Compare comp);
16860b57cec5SDimitry Andric
16870b57cec5SDimitry Andrictemplate <class BidirectionalIterator>
1688e8d8bef9SDimitry Andric    constexpr bool     // constexpr in C++20
16890b57cec5SDimitry Andric    next_permutation(BidirectionalIterator first, BidirectionalIterator last);
16900b57cec5SDimitry Andric
16910b57cec5SDimitry Andrictemplate <class BidirectionalIterator, class Compare>
1692e8d8bef9SDimitry Andric    constexpr bool     // constexpr in C++20
16930b57cec5SDimitry Andric    next_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
16940b57cec5SDimitry Andric
16950b57cec5SDimitry Andrictemplate <class BidirectionalIterator>
1696e8d8bef9SDimitry Andric    constexpr bool     // constexpr in C++20
16970b57cec5SDimitry Andric    prev_permutation(BidirectionalIterator first, BidirectionalIterator last);
16980b57cec5SDimitry Andric
16990b57cec5SDimitry Andrictemplate <class BidirectionalIterator, class Compare>
1700e8d8bef9SDimitry Andric    constexpr bool     // constexpr in C++20
17010b57cec5SDimitry Andric    prev_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
17020b57cec5SDimitry Andric}  // std
17030b57cec5SDimitry Andric
17040b57cec5SDimitry Andric*/
17050b57cec5SDimitry Andric
170681ad6265SDimitry Andric#include <__assert> // all public C++ headers provide the assertion handler
17070b57cec5SDimitry Andric#include <__config>
1708fe6060f1SDimitry Andric#include <__debug>
1709fe6060f1SDimitry Andric#include <cstddef>
1710fe6060f1SDimitry Andric#include <type_traits>
17110b57cec5SDimitry Andric#include <version>
17120b57cec5SDimitry Andric
1713fe6060f1SDimitry Andric#include <__algorithm/adjacent_find.h>
1714fe6060f1SDimitry Andric#include <__algorithm/all_of.h>
1715fe6060f1SDimitry Andric#include <__algorithm/any_of.h>
1716fe6060f1SDimitry Andric#include <__algorithm/binary_search.h>
1717fe6060f1SDimitry Andric#include <__algorithm/clamp.h>
1718fe6060f1SDimitry Andric#include <__algorithm/comp.h>
1719fe6060f1SDimitry Andric#include <__algorithm/comp_ref_type.h>
1720fe6060f1SDimitry Andric#include <__algorithm/copy.h>
1721fe6060f1SDimitry Andric#include <__algorithm/copy_backward.h>
1722fe6060f1SDimitry Andric#include <__algorithm/copy_if.h>
1723fe6060f1SDimitry Andric#include <__algorithm/copy_n.h>
1724fe6060f1SDimitry Andric#include <__algorithm/count.h>
1725fe6060f1SDimitry Andric#include <__algorithm/count_if.h>
1726fe6060f1SDimitry Andric#include <__algorithm/equal.h>
1727fe6060f1SDimitry Andric#include <__algorithm/equal_range.h>
1728fe6060f1SDimitry Andric#include <__algorithm/fill.h>
172904eeddc0SDimitry Andric#include <__algorithm/fill_n.h>
1730fe6060f1SDimitry Andric#include <__algorithm/find.h>
1731fe6060f1SDimitry Andric#include <__algorithm/find_end.h>
1732fe6060f1SDimitry Andric#include <__algorithm/find_first_of.h>
1733fe6060f1SDimitry Andric#include <__algorithm/find_if.h>
1734fe6060f1SDimitry Andric#include <__algorithm/find_if_not.h>
1735fe6060f1SDimitry Andric#include <__algorithm/for_each.h>
1736fe6060f1SDimitry Andric#include <__algorithm/for_each_n.h>
1737fe6060f1SDimitry Andric#include <__algorithm/generate.h>
173804eeddc0SDimitry Andric#include <__algorithm/generate_n.h>
1739fe6060f1SDimitry Andric#include <__algorithm/half_positive.h>
174081ad6265SDimitry Andric#include <__algorithm/in_found_result.h>
174181ad6265SDimitry Andric#include <__algorithm/in_fun_result.h>
17421fd87a68SDimitry Andric#include <__algorithm/in_in_out_result.h>
174304eeddc0SDimitry Andric#include <__algorithm/in_in_result.h>
174481ad6265SDimitry Andric#include <__algorithm/in_out_out_result.h>
174504eeddc0SDimitry Andric#include <__algorithm/in_out_result.h>
1746fe6060f1SDimitry Andric#include <__algorithm/includes.h>
1747fe6060f1SDimitry Andric#include <__algorithm/inplace_merge.h>
1748fe6060f1SDimitry Andric#include <__algorithm/is_heap.h>
1749fe6060f1SDimitry Andric#include <__algorithm/is_heap_until.h>
1750fe6060f1SDimitry Andric#include <__algorithm/is_partitioned.h>
1751fe6060f1SDimitry Andric#include <__algorithm/is_permutation.h>
1752fe6060f1SDimitry Andric#include <__algorithm/is_sorted.h>
1753fe6060f1SDimitry Andric#include <__algorithm/is_sorted_until.h>
1754fe6060f1SDimitry Andric#include <__algorithm/iter_swap.h>
1755fe6060f1SDimitry Andric#include <__algorithm/lexicographical_compare.h>
1756fe6060f1SDimitry Andric#include <__algorithm/lower_bound.h>
1757fe6060f1SDimitry Andric#include <__algorithm/make_heap.h>
1758fe6060f1SDimitry Andric#include <__algorithm/max.h>
1759fe6060f1SDimitry Andric#include <__algorithm/max_element.h>
1760fe6060f1SDimitry Andric#include <__algorithm/merge.h>
1761fe6060f1SDimitry Andric#include <__algorithm/min.h>
1762fe6060f1SDimitry Andric#include <__algorithm/min_element.h>
176381ad6265SDimitry Andric#include <__algorithm/min_max_result.h>
1764fe6060f1SDimitry Andric#include <__algorithm/minmax.h>
1765fe6060f1SDimitry Andric#include <__algorithm/minmax_element.h>
1766fe6060f1SDimitry Andric#include <__algorithm/mismatch.h>
1767fe6060f1SDimitry Andric#include <__algorithm/move.h>
1768fe6060f1SDimitry Andric#include <__algorithm/move_backward.h>
1769fe6060f1SDimitry Andric#include <__algorithm/next_permutation.h>
1770fe6060f1SDimitry Andric#include <__algorithm/none_of.h>
1771fe6060f1SDimitry Andric#include <__algorithm/nth_element.h>
1772fe6060f1SDimitry Andric#include <__algorithm/partial_sort.h>
1773fe6060f1SDimitry Andric#include <__algorithm/partial_sort_copy.h>
1774fe6060f1SDimitry Andric#include <__algorithm/partition.h>
1775fe6060f1SDimitry Andric#include <__algorithm/partition_copy.h>
1776fe6060f1SDimitry Andric#include <__algorithm/partition_point.h>
1777fe6060f1SDimitry Andric#include <__algorithm/pop_heap.h>
1778fe6060f1SDimitry Andric#include <__algorithm/prev_permutation.h>
1779fe6060f1SDimitry Andric#include <__algorithm/push_heap.h>
178081ad6265SDimitry Andric#include <__algorithm/ranges_adjacent_find.h>
178181ad6265SDimitry Andric#include <__algorithm/ranges_all_of.h>
178281ad6265SDimitry Andric#include <__algorithm/ranges_any_of.h>
178381ad6265SDimitry Andric#include <__algorithm/ranges_binary_search.h>
178461cfbce3SDimitry Andric#include <__algorithm/ranges_clamp.h>
178581ad6265SDimitry Andric#include <__algorithm/ranges_copy.h>
178681ad6265SDimitry Andric#include <__algorithm/ranges_copy_backward.h>
178781ad6265SDimitry Andric#include <__algorithm/ranges_copy_if.h>
178881ad6265SDimitry Andric#include <__algorithm/ranges_copy_n.h>
178981ad6265SDimitry Andric#include <__algorithm/ranges_count.h>
179081ad6265SDimitry Andric#include <__algorithm/ranges_count_if.h>
179181ad6265SDimitry Andric#include <__algorithm/ranges_equal.h>
1792fcaf7f86SDimitry Andric#include <__algorithm/ranges_equal_range.h>
179381ad6265SDimitry Andric#include <__algorithm/ranges_fill.h>
179481ad6265SDimitry Andric#include <__algorithm/ranges_fill_n.h>
179581ad6265SDimitry Andric#include <__algorithm/ranges_find.h>
1796753f127fSDimitry Andric#include <__algorithm/ranges_find_end.h>
179781ad6265SDimitry Andric#include <__algorithm/ranges_find_first_of.h>
179881ad6265SDimitry Andric#include <__algorithm/ranges_find_if.h>
179981ad6265SDimitry Andric#include <__algorithm/ranges_find_if_not.h>
180081ad6265SDimitry Andric#include <__algorithm/ranges_for_each.h>
180181ad6265SDimitry Andric#include <__algorithm/ranges_for_each_n.h>
1802972a253aSDimitry Andric#include <__algorithm/ranges_generate.h>
1803972a253aSDimitry Andric#include <__algorithm/ranges_generate_n.h>
1804fcaf7f86SDimitry Andric#include <__algorithm/ranges_includes.h>
180561cfbce3SDimitry Andric#include <__algorithm/ranges_inplace_merge.h>
1806972a253aSDimitry Andric#include <__algorithm/ranges_is_heap.h>
1807972a253aSDimitry Andric#include <__algorithm/ranges_is_heap_until.h>
180881ad6265SDimitry Andric#include <__algorithm/ranges_is_partitioned.h>
180961cfbce3SDimitry Andric#include <__algorithm/ranges_is_permutation.h>
181081ad6265SDimitry Andric#include <__algorithm/ranges_is_sorted.h>
181181ad6265SDimitry Andric#include <__algorithm/ranges_is_sorted_until.h>
181281ad6265SDimitry Andric#include <__algorithm/ranges_lexicographical_compare.h>
181381ad6265SDimitry Andric#include <__algorithm/ranges_lower_bound.h>
1814753f127fSDimitry Andric#include <__algorithm/ranges_make_heap.h>
181581ad6265SDimitry Andric#include <__algorithm/ranges_max.h>
181681ad6265SDimitry Andric#include <__algorithm/ranges_max_element.h>
1817753f127fSDimitry Andric#include <__algorithm/ranges_merge.h>
181881ad6265SDimitry Andric#include <__algorithm/ranges_min.h>
181981ad6265SDimitry Andric#include <__algorithm/ranges_min_element.h>
182081ad6265SDimitry Andric#include <__algorithm/ranges_minmax.h>
182181ad6265SDimitry Andric#include <__algorithm/ranges_minmax_element.h>
182281ad6265SDimitry Andric#include <__algorithm/ranges_mismatch.h>
182381ad6265SDimitry Andric#include <__algorithm/ranges_move.h>
182481ad6265SDimitry Andric#include <__algorithm/ranges_move_backward.h>
182561cfbce3SDimitry Andric#include <__algorithm/ranges_next_permutation.h>
182681ad6265SDimitry Andric#include <__algorithm/ranges_none_of.h>
1827753f127fSDimitry Andric#include <__algorithm/ranges_nth_element.h>
1828fcaf7f86SDimitry Andric#include <__algorithm/ranges_partial_sort.h>
182961cfbce3SDimitry Andric#include <__algorithm/ranges_partial_sort_copy.h>
1830fcaf7f86SDimitry Andric#include <__algorithm/ranges_partition.h>
1831fcaf7f86SDimitry Andric#include <__algorithm/ranges_partition_copy.h>
1832fcaf7f86SDimitry Andric#include <__algorithm/ranges_partition_point.h>
1833753f127fSDimitry Andric#include <__algorithm/ranges_pop_heap.h>
183461cfbce3SDimitry Andric#include <__algorithm/ranges_prev_permutation.h>
1835753f127fSDimitry Andric#include <__algorithm/ranges_push_heap.h>
1836753f127fSDimitry Andric#include <__algorithm/ranges_remove.h>
183761cfbce3SDimitry Andric#include <__algorithm/ranges_remove_copy.h>
183861cfbce3SDimitry Andric#include <__algorithm/ranges_remove_copy_if.h>
1839753f127fSDimitry Andric#include <__algorithm/ranges_remove_if.h>
184081ad6265SDimitry Andric#include <__algorithm/ranges_replace.h>
184161cfbce3SDimitry Andric#include <__algorithm/ranges_replace_copy.h>
184261cfbce3SDimitry Andric#include <__algorithm/ranges_replace_copy_if.h>
184381ad6265SDimitry Andric#include <__algorithm/ranges_replace_if.h>
184481ad6265SDimitry Andric#include <__algorithm/ranges_reverse.h>
1845753f127fSDimitry Andric#include <__algorithm/ranges_reverse_copy.h>
184661cfbce3SDimitry Andric#include <__algorithm/ranges_rotate.h>
1847753f127fSDimitry Andric#include <__algorithm/ranges_rotate_copy.h>
184861cfbce3SDimitry Andric#include <__algorithm/ranges_sample.h>
1849753f127fSDimitry Andric#include <__algorithm/ranges_search.h>
1850753f127fSDimitry Andric#include <__algorithm/ranges_search_n.h>
1851753f127fSDimitry Andric#include <__algorithm/ranges_set_difference.h>
1852753f127fSDimitry Andric#include <__algorithm/ranges_set_intersection.h>
1853753f127fSDimitry Andric#include <__algorithm/ranges_set_symmetric_difference.h>
1854fcaf7f86SDimitry Andric#include <__algorithm/ranges_set_union.h>
1855fcaf7f86SDimitry Andric#include <__algorithm/ranges_shuffle.h>
185681ad6265SDimitry Andric#include <__algorithm/ranges_sort.h>
1857753f127fSDimitry Andric#include <__algorithm/ranges_sort_heap.h>
1858fcaf7f86SDimitry Andric#include <__algorithm/ranges_stable_partition.h>
185981ad6265SDimitry Andric#include <__algorithm/ranges_stable_sort.h>
186081ad6265SDimitry Andric#include <__algorithm/ranges_swap_ranges.h>
186181ad6265SDimitry Andric#include <__algorithm/ranges_transform.h>
186261cfbce3SDimitry Andric#include <__algorithm/ranges_unique.h>
186361cfbce3SDimitry Andric#include <__algorithm/ranges_unique_copy.h>
186481ad6265SDimitry Andric#include <__algorithm/ranges_upper_bound.h>
1865fe6060f1SDimitry Andric#include <__algorithm/remove.h>
1866fe6060f1SDimitry Andric#include <__algorithm/remove_copy.h>
1867fe6060f1SDimitry Andric#include <__algorithm/remove_copy_if.h>
1868fe6060f1SDimitry Andric#include <__algorithm/remove_if.h>
1869fe6060f1SDimitry Andric#include <__algorithm/replace.h>
1870fe6060f1SDimitry Andric#include <__algorithm/replace_copy.h>
1871fe6060f1SDimitry Andric#include <__algorithm/replace_copy_if.h>
1872fe6060f1SDimitry Andric#include <__algorithm/replace_if.h>
1873fe6060f1SDimitry Andric#include <__algorithm/reverse.h>
1874fe6060f1SDimitry Andric#include <__algorithm/reverse_copy.h>
1875fe6060f1SDimitry Andric#include <__algorithm/rotate.h>
1876fe6060f1SDimitry Andric#include <__algorithm/rotate_copy.h>
1877fe6060f1SDimitry Andric#include <__algorithm/sample.h>
1878fe6060f1SDimitry Andric#include <__algorithm/search.h>
1879fe6060f1SDimitry Andric#include <__algorithm/search_n.h>
1880fe6060f1SDimitry Andric#include <__algorithm/set_difference.h>
1881fe6060f1SDimitry Andric#include <__algorithm/set_intersection.h>
1882fe6060f1SDimitry Andric#include <__algorithm/set_symmetric_difference.h>
1883fe6060f1SDimitry Andric#include <__algorithm/set_union.h>
1884fe6060f1SDimitry Andric#include <__algorithm/shift_left.h>
1885fe6060f1SDimitry Andric#include <__algorithm/shift_right.h>
1886fe6060f1SDimitry Andric#include <__algorithm/shuffle.h>
1887fe6060f1SDimitry Andric#include <__algorithm/sift_down.h>
1888fe6060f1SDimitry Andric#include <__algorithm/sort.h>
1889fe6060f1SDimitry Andric#include <__algorithm/sort_heap.h>
1890fe6060f1SDimitry Andric#include <__algorithm/stable_partition.h>
1891fe6060f1SDimitry Andric#include <__algorithm/stable_sort.h>
1892fe6060f1SDimitry Andric#include <__algorithm/swap_ranges.h>
1893fe6060f1SDimitry Andric#include <__algorithm/transform.h>
1894fe6060f1SDimitry Andric#include <__algorithm/unique.h>
189504eeddc0SDimitry Andric#include <__algorithm/unique_copy.h>
1896fe6060f1SDimitry Andric#include <__algorithm/unwrap_iter.h>
1897fe6060f1SDimitry Andric#include <__algorithm/upper_bound.h>
18980b57cec5SDimitry Andric
189981ad6265SDimitry Andric// standard-mandated includes
1900*bdd1243dSDimitry Andric
1901*bdd1243dSDimitry Andric// [algorithm.syn]
190281ad6265SDimitry Andric#include <initializer_list>
190381ad6265SDimitry Andric
19040b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19050b57cec5SDimitry Andric#  pragma GCC system_header
19060b57cec5SDimitry Andric#endif
19070b57cec5SDimitry Andric
1908e40139ffSDimitry Andric#if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17
1909e40139ffSDimitry Andric#  include <__pstl_algorithm>
1910e40139ffSDimitry Andric#endif
1911e40139ffSDimitry Andric
1912*bdd1243dSDimitry Andric#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17
1913*bdd1243dSDimitry Andric#  include <chrono>
1914*bdd1243dSDimitry Andric#endif
1915*bdd1243dSDimitry Andric
1916*bdd1243dSDimitry Andric#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1917*bdd1243dSDimitry Andric#  include <atomic>
1918*bdd1243dSDimitry Andric#  include <concepts>
1919*bdd1243dSDimitry Andric#  include <cstring>
1920*bdd1243dSDimitry Andric#  include <iterator>
1921*bdd1243dSDimitry Andric#  include <memory>
1922*bdd1243dSDimitry Andric#  include <stdexcept>
1923*bdd1243dSDimitry Andric#  include <utility>
1924*bdd1243dSDimitry Andric#endif
1925*bdd1243dSDimitry Andric
19260b57cec5SDimitry Andric#endif // _LIBCPP_ALGORITHM
1927