xref: /freebsd/contrib/llvm-project/libcxx/include/algorithm (revision 06c3fb2749bda94cb5201f81ffdb8fa6c3161b2e)
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>
67*06c3fb27SDimitry Andric  constexpr mismatch_result<_I1, _I2>                                                                     // since C++20
68*06c3fb27SDimitry Andric  mismatch()(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {})
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>
336*06c3fb27SDimitry 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>
340*06c3fb27SDimitry 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>
344*06c3fb27SDimitry 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>
349*06c3fb27SDimitry 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&>>
402*06c3fb27SDimitry Andric    constexpr O generate(O first, S last, F gen);                                           // since C++20
403*06c3fb27SDimitry Andric
404*06c3fb27SDimitry Andric  template<class ExecutionPolicy, class ForwardIterator, class Generator>
405*06c3fb27SDimitry Andric    void generate(ExecutionPolicy&& exec,
406*06c3fb27SDimitry Andric                  ForwardIterator first, ForwardIterator last,
407*06c3fb27SDimitry Andric                  Generator gen);                                                           // since C++17
408972a253aSDimitry Andric
409972a253aSDimitry Andric  template<class R, copy_constructible F>
410972a253aSDimitry Andric    requires invocable<F&> && output_range<R, invoke_result_t<F&>>
411*06c3fb27SDimitry Andric    constexpr borrowed_iterator_t<R> generate(R&& r, F gen);                                // since C++20
412972a253aSDimitry Andric
413972a253aSDimitry Andric  template<input_or_output_iterator O, copy_constructible F>
414972a253aSDimitry Andric    requires invocable<F&> && indirectly_writable<O, invoke_result_t<F&>>
415*06c3fb27SDimitry Andric    constexpr O generate_n(O first, iter_difference_t<O> n, F gen);                         // since C++20
416*06c3fb27SDimitry Andric
417*06c3fb27SDimitry Andric  template<class ExecutionPolicy, class ForwardIterator, class Size, class Generator>
418*06c3fb27SDimitry Andric    ForwardIterator generate_n(ExecutionPolicy&& exec,
419*06c3fb27SDimitry Andric                               ForwardIterator first, Size n, Generator gen);               // since C++17
420972a253aSDimitry Andric
42181ad6265SDimitry Andric template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
42281ad6265SDimitry Andric          class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
42381ad6265SDimitry Andric   requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
42481ad6265SDimitry Andric   constexpr bool ranges::equal(I1 first1, S1 last1, I2 first2, S2 last2,
42581ad6265SDimitry Andric                                Pred pred = {},
42681ad6265SDimitry Andric                                Proj1 proj1 = {}, Proj2 proj2 = {});                        // since C++20
42781ad6265SDimitry Andric
42881ad6265SDimitry Andric template<input_range R1, input_range R2, class Pred = ranges::equal_to,
42981ad6265SDimitry Andric          class Proj1 = identity, class Proj2 = identity>
43081ad6265SDimitry Andric   requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
43181ad6265SDimitry Andric   constexpr bool ranges::equal(R1&& r1, R2&& r2, Pred pred = {},
43281ad6265SDimitry Andric                                Proj1 proj1 = {}, Proj2 proj2 = {});                        // since C++20
43381ad6265SDimitry Andric
43481ad6265SDimitry Andric  template<input_iterator I, sentinel_for<I> S, class Proj = identity,
43581ad6265SDimitry Andric           indirect_unary_predicate<projected<I, Proj>> Pred>
43681ad6265SDimitry Andric    constexpr bool ranges::all_of(I first, S last, Pred pred, Proj proj = {});              // since C++20
43781ad6265SDimitry Andric
43881ad6265SDimitry Andric  template<input_range R, class Proj = identity,
43981ad6265SDimitry Andric           indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
44081ad6265SDimitry Andric    constexpr bool ranges::all_of(R&& r, Pred pred, Proj proj = {});                        // since C++20
44181ad6265SDimitry Andric
44281ad6265SDimitry Andric  template<input_iterator I, sentinel_for<I> S, class Proj = identity,
44381ad6265SDimitry Andric           indirect_unary_predicate<projected<I, Proj>> Pred>
44481ad6265SDimitry Andric    constexpr bool ranges::any_of(I first, S last, Pred pred, Proj proj = {});              // since C++20
44581ad6265SDimitry Andric
44681ad6265SDimitry Andric  template<input_range R, class Proj = identity,
44781ad6265SDimitry Andric           indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
44881ad6265SDimitry Andric    constexpr bool ranges::any_of(R&& r, Pred pred, Proj proj = {});                        // since C++20
44981ad6265SDimitry Andric
45081ad6265SDimitry Andric  template<input_iterator I, sentinel_for<I> S, class Proj = identity,
45181ad6265SDimitry Andric           indirect_unary_predicate<projected<I, Proj>> Pred>
45281ad6265SDimitry Andric    constexpr bool ranges::none_of(I first, S last, Pred pred, Proj proj = {});             // since C++20
45381ad6265SDimitry Andric
45481ad6265SDimitry Andric  template<input_range R, class Proj = identity,
45581ad6265SDimitry Andric           indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
45681ad6265SDimitry Andric    constexpr bool ranges::none_of(R&& r, Pred pred, Proj proj = {});                       // since C++20
45781ad6265SDimitry Andric
458*06c3fb27SDimitry Andric  template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
459*06c3fb27SDimitry Andric          class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
460*06c3fb27SDimitry Andric    requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
461*06c3fb27SDimitry Andric    constexpr bool ranges::starts_with(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {},
462*06c3fb27SDimitry Andric                                      Proj1 proj1 = {}, Proj2 proj2 = {});                 // since C++23
463*06c3fb27SDimitry Andric
464*06c3fb27SDimitry Andric  template<input_range R1, input_range R2, class Pred = ranges::equal_to, class Proj1 = identity,
465*06c3fb27SDimitry Andric          class Proj2 = identity>
466*06c3fb27SDimitry Andric    requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
467*06c3fb27SDimitry Andric    constexpr bool ranges::starts_with(R1&& r1, R2&& r2, Pred pred = {},
468*06c3fb27SDimitry Andric                                      Proj1 proj1 = {}, Proj2 proj2 = {});                // since C++23
469*06c3fb27SDimitry Andric
47061cfbce3SDimitry Andric  template<input_iterator I1, sentinel_for<I1> S1,
47161cfbce3SDimitry Andric          random_access_iterator I2, sentinel_for<I2> S2,
47261cfbce3SDimitry Andric          class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity>
47361cfbce3SDimitry Andric    requires indirectly_copyable<I1, I2> && sortable<I2, Comp, Proj2> &&
47461cfbce3SDimitry Andric            indirect_strict_weak_order<Comp, projected<I1, Proj1>, projected<I2, Proj2>>
47561cfbce3SDimitry Andric    constexpr partial_sort_copy_result<I1, I2>
47661cfbce3SDimitry Andric      partial_sort_copy(I1 first, S1 last, I2 result_first, S2 result_last,
477*06c3fb27SDimitry Andric                        Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {});                // since C++20
47861cfbce3SDimitry Andric
47961cfbce3SDimitry Andric  template<input_range R1, random_access_range R2, class Comp = ranges::less,
48061cfbce3SDimitry Andric          class Proj1 = identity, class Proj2 = identity>
48161cfbce3SDimitry Andric    requires indirectly_copyable<iterator_t<R1>, iterator_t<R2>> &&
48261cfbce3SDimitry Andric            sortable<iterator_t<R2>, Comp, Proj2> &&
48361cfbce3SDimitry Andric            indirect_strict_weak_order<Comp, projected<iterator_t<R1>, Proj1>,
48461cfbce3SDimitry Andric                                        projected<iterator_t<R2>, Proj2>>
48561cfbce3SDimitry Andric    constexpr partial_sort_copy_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>>
48661cfbce3SDimitry Andric      partial_sort_copy(R1&& r, R2&& result_r, Comp comp = {},
487*06c3fb27SDimitry Andric                        Proj1 proj1 = {}, Proj2 proj2 = {});                                // since C++20
48861cfbce3SDimitry Andric
48981ad6265SDimitry Andric  template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
49081ad6265SDimitry Andric           indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
49181ad6265SDimitry Andric    constexpr bool ranges::is_sorted(I first, S last, Comp comp = {}, Proj proj = {});      // since C++20
49281ad6265SDimitry Andric
49381ad6265SDimitry Andric  template<forward_range R, class Proj = identity,
49481ad6265SDimitry Andric           indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
49581ad6265SDimitry Andric    constexpr bool ranges::is_sorted(R&& r, Comp comp = {}, Proj proj = {});                // since C++20
49681ad6265SDimitry Andric
49781ad6265SDimitry Andric  template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
49881ad6265SDimitry Andric           indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
49981ad6265SDimitry Andric    constexpr I ranges::is_sorted_until(I first, S last, Comp comp = {}, Proj proj = {});   // since C++20
50081ad6265SDimitry Andric
50181ad6265SDimitry Andric  template<forward_range R, class Proj = identity,
50281ad6265SDimitry Andric           indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
50381ad6265SDimitry Andric    constexpr borrowed_iterator_t<R>
50481ad6265SDimitry Andric      ranges::is_sorted_until(R&& r, Comp comp = {}, Proj proj = {});                       // since C++20
50581ad6265SDimitry Andric
506753f127fSDimitry Andric  template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less,
507753f127fSDimitry Andric          class Proj = identity>
508753f127fSDimitry Andric    requires sortable<I, Comp, Proj>
509753f127fSDimitry Andric    constexpr I
510753f127fSDimitry Andric      ranges::nth_element(I first, I nth, S last, Comp comp = {}, Proj proj = {});          // since C++20
511753f127fSDimitry Andric
512753f127fSDimitry Andric  template<random_access_range R, class Comp = ranges::less, class Proj = identity>
513753f127fSDimitry Andric    requires sortable<iterator_t<R>, Comp, Proj>
514753f127fSDimitry Andric    constexpr borrowed_iterator_t<R>
515753f127fSDimitry Andric      ranges::nth_element(R&& r, iterator_t<R> nth, Comp comp = {}, Proj proj = {});        // since C++20
516753f127fSDimitry Andric
51781ad6265SDimitry Andric  template<forward_iterator I, sentinel_for<I> S, class T, class Proj = identity,
518*06c3fb27SDimitry Andric           indirect_strict_weak_order<const T*, projected<I, Proj>> Comp = ranges::less>    // since C++20
519*06c3fb27SDimitry Andric    constexpr I upper_bound(I first, S last, const T& value, Comp comp = {}, Proj proj = {});
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 borrowed_iterator_t<R>
52581ad6265SDimitry Andric      upper_bound(R&& r, const T& value, Comp comp = {}, Proj proj = {});                   // since C++20
52681ad6265SDimitry Andric
52781ad6265SDimitry Andric  template<forward_iterator I, sentinel_for<I> S, class T, class Proj = identity,
52881ad6265SDimitry Andric           indirect_strict_weak_order<const T*, projected<I, Proj>> Comp = ranges::less>
52981ad6265SDimitry Andric    constexpr I lower_bound(I first, S last, const T& value, Comp comp = {},
53081ad6265SDimitry Andric                                    Proj proj = {});                                        // since C++20
53181ad6265SDimitry Andric  template<forward_range R, class T, class Proj = identity,
53281ad6265SDimitry Andric           indirect_strict_weak_order<const T*, projected<iterator_t<R>, Proj>> Comp =
53381ad6265SDimitry Andric             ranges::less>
53481ad6265SDimitry Andric    constexpr borrowed_iterator_t<R>
53581ad6265SDimitry Andric      lower_bound(R&& r, const T& value, Comp comp = {}, Proj proj = {});                   // since C++20
53681ad6265SDimitry Andric
53781ad6265SDimitry Andric  template<forward_iterator I, sentinel_for<I> S, class T, class Proj = identity,
53881ad6265SDimitry Andric           indirect_strict_weak_order<const T*, projected<I, Proj>> Comp = ranges::less>
53981ad6265SDimitry Andric    constexpr bool binary_search(I first, S last, const T& value, Comp comp = {},
54081ad6265SDimitry Andric                                         Proj proj = {});                                   // since C++20
54181ad6265SDimitry Andric
54281ad6265SDimitry Andric  template<forward_range R, class T, class Proj = identity,
54381ad6265SDimitry Andric           indirect_strict_weak_order<const T*, projected<iterator_t<R>, Proj>> Comp =
54481ad6265SDimitry Andric             ranges::less>
54581ad6265SDimitry Andric    constexpr bool binary_search(R&& r, const T& value, Comp comp = {},
54681ad6265SDimitry Andric                                         Proj proj = {});                                   // since C++20
547fcaf7f86SDimitry Andric
548fcaf7f86SDimitry Andric  template<permutable I, sentinel_for<I> S, class Proj = identity,
549fcaf7f86SDimitry Andric           indirect_unary_predicate<projected<I, Proj>> Pred>
550fcaf7f86SDimitry Andric    constexpr subrange<I>
551*06c3fb27SDimitry Andric      partition(I first, S last, Pred pred, Proj proj = {});                                // since C++20
552fcaf7f86SDimitry Andric
553fcaf7f86SDimitry Andric  template<forward_range R, class Proj = identity,
554fcaf7f86SDimitry Andric           indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
555fcaf7f86SDimitry Andric    requires permutable<iterator_t<R>>
556fcaf7f86SDimitry Andric    constexpr borrowed_subrange_t<R>
557*06c3fb27SDimitry Andric      partition(R&& r, Pred pred, Proj proj = {});                                          // since C++20
558fcaf7f86SDimitry Andric
559fcaf7f86SDimitry Andric  template<bidirectional_iterator I, sentinel_for<I> S, class Proj = identity,
560fcaf7f86SDimitry Andric           indirect_unary_predicate<projected<I, Proj>> Pred>
561fcaf7f86SDimitry Andric    requires permutable<I>
562*06c3fb27SDimitry Andric    subrange<I> stable_partition(I first, S last, Pred pred, Proj proj = {});               // since C++20
563fcaf7f86SDimitry Andric
564fcaf7f86SDimitry Andric  template<bidirectional_range R, class Proj = identity,
565fcaf7f86SDimitry Andric           indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
566fcaf7f86SDimitry Andric    requires permutable<iterator_t<R>>
567*06c3fb27SDimitry Andric    borrowed_subrange_t<R> stable_partition(R&& r, Pred pred, Proj proj = {});              // since C++20
568fcaf7f86SDimitry Andric
56981ad6265SDimitry Andric  template<input_iterator I1, sentinel_for<I1> S1, forward_iterator I2, sentinel_for<I2> S2,
57081ad6265SDimitry Andric           class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
57181ad6265SDimitry Andric    requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
57281ad6265SDimitry Andric    constexpr I1 ranges::find_first_of(I1 first1, S1 last1, I2 first2, S2 last2,
57381ad6265SDimitry Andric                                       Pred pred = {},
57481ad6265SDimitry Andric                                       Proj1 proj1 = {}, Proj2 proj2 = {});                 // since C++20
57581ad6265SDimitry Andric
57681ad6265SDimitry Andric  template<input_range R1, forward_range R2,
57781ad6265SDimitry Andric           class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
57881ad6265SDimitry Andric    requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
57981ad6265SDimitry Andric    constexpr borrowed_iterator_t<R1>
58081ad6265SDimitry Andric      ranges::find_first_of(R1&& r1, R2&& r2,
58181ad6265SDimitry Andric                            Pred pred = {},
58281ad6265SDimitry Andric                            Proj1 proj1 = {}, Proj2 proj2 = {});                            // since C++20
58381ad6265SDimitry Andric
58481ad6265SDimitry Andric  template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
58581ad6265SDimitry Andric           indirect_binary_predicate<projected<I, Proj>,
58681ad6265SDimitry Andric                                     projected<I, Proj>> Pred = ranges::equal_to>
587*06c3fb27SDimitry Andric    constexpr I ranges::adjacent_find(I first, S last, Pred pred = {}, Proj proj = {});     // since C++20
58881ad6265SDimitry Andric
58981ad6265SDimitry Andric  template<forward_range R, class Proj = identity,
59081ad6265SDimitry Andric           indirect_binary_predicate<projected<iterator_t<R>, Proj>,
59181ad6265SDimitry Andric                                     projected<iterator_t<R>, Proj>> Pred = ranges::equal_to>
59281ad6265SDimitry Andric    constexpr borrowed_iterator_t<R> ranges::adjacent_find(R&& r, Pred pred = {}, Proj proj = {});  // since C++20
59381ad6265SDimitry Andric
59481ad6265SDimitry Andric  template<input_iterator I, sentinel_for<I> S, class T1, class T2, class Proj = identity>
59581ad6265SDimitry Andric    requires indirectly_writable<I, const T2&> &&
59681ad6265SDimitry Andric             indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T1*>
59781ad6265SDimitry Andric    constexpr I
59881ad6265SDimitry Andric      ranges::replace(I first, S last, const T1& old_value, const T2& new_value, Proj proj = {});   // since C++20
59981ad6265SDimitry Andric
60081ad6265SDimitry Andric  template<input_range R, class T1, class T2, class Proj = identity>
60181ad6265SDimitry Andric    requires indirectly_writable<iterator_t<R>, const T2&> &&
60281ad6265SDimitry Andric             indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T1*>
60381ad6265SDimitry Andric    constexpr borrowed_iterator_t<R>
60481ad6265SDimitry Andric      ranges::replace(R&& r, const T1& old_value, const T2& new_value, Proj proj = {});             // since C++20
60581ad6265SDimitry Andric
60681ad6265SDimitry Andric  template<input_iterator I, sentinel_for<I> S, class T, class Proj = identity,
60781ad6265SDimitry Andric           indirect_unary_predicate<projected<I, Proj>> Pred>
60881ad6265SDimitry Andric    requires indirectly_writable<I, const T&>
60981ad6265SDimitry Andric    constexpr I ranges::replace_if(I first, S last, Pred pred, const T& new_value, Proj proj = {}); // since C++20
61081ad6265SDimitry Andric
61181ad6265SDimitry Andric  template<input_range R, class T, class Proj = identity,
61281ad6265SDimitry Andric           indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
61381ad6265SDimitry Andric    requires indirectly_writable<iterator_t<R>, const T&>
61481ad6265SDimitry Andric    constexpr borrowed_iterator_t<R>
61581ad6265SDimitry Andric      ranges::replace_if(R&& r, Pred pred, const T& new_value, Proj proj = {});                     // since C++20
61681ad6265SDimitry Andric
61761cfbce3SDimitry Andric  template<class T, class Proj = identity,
61861cfbce3SDimitry Andric           indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
61961cfbce3SDimitry Andric    constexpr const T&
62061cfbce3SDimitry Andric      ranges::clamp(const T& v, const T& lo, const T& hi, Comp comp = {}, Proj proj = {});          // since C++20
62161cfbce3SDimitry Andric
62281ad6265SDimitry Andric  template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
62381ad6265SDimitry Andric           class Proj1 = identity, class Proj2 = identity,
62481ad6265SDimitry Andric           indirect_strict_weak_order<projected<I1, Proj1>,
62581ad6265SDimitry Andric                                      projected<I2, Proj2>> Comp = ranges::less>
62681ad6265SDimitry Andric    constexpr bool
62781ad6265SDimitry Andric      ranges::lexicographical_compare(I1 first1, S1 last1, I2 first2, S2 last2,
62881ad6265SDimitry Andric                                      Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {});          // since C++20
62981ad6265SDimitry Andric
63081ad6265SDimitry Andric  template<input_range R1, input_range R2, class Proj1 = identity,
63181ad6265SDimitry Andric           class Proj2 = identity,
63281ad6265SDimitry Andric           indirect_strict_weak_order<projected<iterator_t<R1>, Proj1>,
63381ad6265SDimitry Andric                                      projected<iterator_t<R2>, Proj2>> Comp = ranges::less>
63481ad6265SDimitry Andric    constexpr bool
63581ad6265SDimitry Andric      ranges::lexicographical_compare(R1&& r1, R2&& r2, Comp comp = {},
63681ad6265SDimitry Andric                                      Proj1 proj1 = {}, Proj2 proj2 = {});                          // since C++20
63781ad6265SDimitry Andric
63881ad6265SDimitry Andric  template<bidirectional_iterator I1, sentinel_for<I1> S1, bidirectional_iterator I2>
63981ad6265SDimitry Andric    requires indirectly_movable<I1, I2>
64081ad6265SDimitry Andric    constexpr ranges::move_backward_result<I1, I2>
64181ad6265SDimitry Andric      ranges::move_backward(I1 first, S1 last, I2 result);                                          // since C++20
64281ad6265SDimitry Andric
64381ad6265SDimitry Andric  template<bidirectional_range R, bidirectional_iterator I>
64481ad6265SDimitry Andric    requires indirectly_movable<iterator_t<R>, I>
64581ad6265SDimitry Andric    constexpr ranges::move_backward_result<borrowed_iterator_t<R>, I>
64681ad6265SDimitry Andric      ranges::move_backward(R&& r, I result);                                                       // since C++20
64781ad6265SDimitry Andric
64881ad6265SDimitry Andric  template<input_iterator I, sentinel_for<I> S, weakly_incrementable O>
64981ad6265SDimitry Andric    requires indirectly_movable<I, O>
65081ad6265SDimitry Andric    constexpr ranges::move_result<I, O>
65181ad6265SDimitry Andric      ranges::move(I first, S last, O result);                                                      // since C++20
65281ad6265SDimitry Andric
65381ad6265SDimitry Andric  template<input_range R, weakly_incrementable O>
65481ad6265SDimitry Andric    requires indirectly_movable<iterator_t<R>, O>
65581ad6265SDimitry Andric    constexpr ranges::move_result<borrowed_iterator_t<R>, O>
65681ad6265SDimitry Andric      ranges::move(R&& r, O result);                                                                // since C++20
65781ad6265SDimitry Andric
658fcaf7f86SDimitry Andric  template<class I, class O1, class O2>
659fcaf7f86SDimitry Andric      using partition_copy_result = in_out_out_result<I, O1, O2>;                                   // since C++20
660fcaf7f86SDimitry Andric
661fcaf7f86SDimitry Andric  template<input_iterator I, sentinel_for<I> S,
662fcaf7f86SDimitry Andric          weakly_incrementable O1, weakly_incrementable O2,
663fcaf7f86SDimitry Andric          class Proj = identity, indirect_unary_predicate<projected<I, Proj>> Pred>
664fcaf7f86SDimitry Andric    requires indirectly_copyable<I, O1> && indirectly_copyable<I, O2>
665fcaf7f86SDimitry Andric    constexpr partition_copy_result<I, O1, O2>
666fcaf7f86SDimitry Andric      partition_copy(I first, S last, O1 out_true, O2 out_false, Pred pred,
667*06c3fb27SDimitry Andric                    Proj proj = {});                                                                // since C++20
668fcaf7f86SDimitry Andric
669fcaf7f86SDimitry Andric  template<input_range R, weakly_incrementable O1, weakly_incrementable O2,
670fcaf7f86SDimitry Andric          class Proj = identity,
671fcaf7f86SDimitry Andric          indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
672fcaf7f86SDimitry Andric    requires indirectly_copyable<iterator_t<R>, O1> &&
673fcaf7f86SDimitry Andric            indirectly_copyable<iterator_t<R>, O2>
674fcaf7f86SDimitry Andric    constexpr partition_copy_result<borrowed_iterator_t<R>, O1, O2>
675*06c3fb27SDimitry Andric      partition_copy(R&& r, O1 out_true, O2 out_false, Pred pred, Proj proj = {});                  // since C++20
676fcaf7f86SDimitry Andric
677fcaf7f86SDimitry Andric  template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
678fcaf7f86SDimitry Andric           indirect_unary_predicate<projected<I, Proj>> Pred>
679*06c3fb27SDimitry Andric    constexpr I partition_point(I first, S last, Pred pred, Proj proj = {});                        // since C++20
680fcaf7f86SDimitry Andric
681fcaf7f86SDimitry Andric  template<forward_range R, class Proj = identity,
682fcaf7f86SDimitry Andric           indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
683fcaf7f86SDimitry Andric    constexpr borrowed_iterator_t<R>
684*06c3fb27SDimitry Andric      partition_point(R&& r, Pred pred, Proj proj = {});                                            // since C++20
685fcaf7f86SDimitry Andric
686753f127fSDimitry Andric  template<class I1, class I2, class O>
687753f127fSDimitry Andric    using merge_result = in_in_out_result<I1, I2, O>;                                               // since C++20
688753f127fSDimitry Andric
689753f127fSDimitry Andric  template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
690753f127fSDimitry Andric           weakly_incrementable O, class Comp = ranges::less, class Proj1 = identity,
691753f127fSDimitry Andric           class Proj2 = identity>
692753f127fSDimitry Andric    requires mergeable<I1, I2, O, Comp, Proj1, Proj2>
693753f127fSDimitry Andric    constexpr merge_result<I1, I2, O>
694753f127fSDimitry Andric      merge(I1 first1, S1 last1, I2 first2, S2 last2, O result,
695753f127fSDimitry Andric            Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {});                                    // since C++20
696753f127fSDimitry Andric
697753f127fSDimitry Andric  template<input_range R1, input_range R2, weakly_incrementable O, class Comp = ranges::less,
698753f127fSDimitry Andric           class Proj1 = identity, class Proj2 = identity>
699753f127fSDimitry Andric    requires mergeable<iterator_t<R1>, iterator_t<R2>, O, Comp, Proj1, Proj2>
700753f127fSDimitry Andric    constexpr merge_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>, O>
701753f127fSDimitry Andric      merge(R1&& r1, R2&& r2, O result,
702753f127fSDimitry Andric            Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {});                                    // since C++20
703753f127fSDimitry Andric
704753f127fSDimitry Andric  template<permutable I, sentinel_for<I> S, class T, class Proj = identity>
705753f127fSDimitry Andric    requires indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
706753f127fSDimitry Andric    constexpr subrange<I> ranges::remove(I first, S last, const T& value, Proj proj = {});          // since C++20
707753f127fSDimitry Andric
708753f127fSDimitry Andric  template<forward_range R, class T, class Proj = identity>
709753f127fSDimitry Andric    requires permutable<iterator_t<R>> &&
710753f127fSDimitry Andric             indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*>
711753f127fSDimitry Andric    constexpr borrowed_subrange_t<R>
712753f127fSDimitry Andric      ranges::remove(R&& r, const T& value, Proj proj = {});                                        // since C++20
713753f127fSDimitry Andric
714753f127fSDimitry Andric  template<permutable I, sentinel_for<I> S, class Proj = identity,
715753f127fSDimitry Andric           indirect_unary_predicate<projected<I, Proj>> Pred>
716753f127fSDimitry Andric    constexpr subrange<I> ranges::remove_if(I first, S last, Pred pred, Proj proj = {});            // since C++20
717753f127fSDimitry Andric
718753f127fSDimitry Andric  template<forward_range R, class Proj = identity,
719753f127fSDimitry Andric           indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
720753f127fSDimitry Andric    requires permutable<iterator_t<R>>
721753f127fSDimitry Andric    constexpr borrowed_subrange_t<R>
722753f127fSDimitry Andric      ranges::remove_if(R&& r, Pred pred, Proj proj = {});                                          // since C++20
723753f127fSDimitry Andric
724753f127fSDimitry Andric  template<class I, class O>
725753f127fSDimitry Andric    using set_difference_result = in_out_result<I, O>;                                              // since C++20
726753f127fSDimitry Andric
727753f127fSDimitry Andric  template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
728753f127fSDimitry Andric           weakly_incrementable O, class Comp = ranges::less,
729753f127fSDimitry Andric           class Proj1 = identity, class Proj2 = identity>
730753f127fSDimitry Andric    requires mergeable<I1, I2, O, Comp, Proj1, Proj2>
731753f127fSDimitry Andric    constexpr set_difference_result<I1, O>
732753f127fSDimitry Andric      set_difference(I1 first1, S1 last1, I2 first2, S2 last2, O result,
733753f127fSDimitry Andric                     Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {});                           // since C++20
734753f127fSDimitry Andric
735753f127fSDimitry Andric  template<input_range R1, input_range R2, weakly_incrementable O,
736753f127fSDimitry Andric           class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity>
737753f127fSDimitry Andric    requires mergeable<iterator_t<R1>, iterator_t<R2>, O, Comp, Proj1, Proj2>
738753f127fSDimitry Andric    constexpr set_difference_result<borrowed_iterator_t<R1>, O>
739753f127fSDimitry Andric      set_difference(R1&& r1, R2&& r2, O result,
740753f127fSDimitry Andric                     Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {});                           // since C++20
741753f127fSDimitry Andric
742753f127fSDimitry Andric  template<class I1, class I2, class O>
743753f127fSDimitry Andric    using set_intersection_result = in_in_out_result<I1, I2, O>;                                    // since C++20
744753f127fSDimitry Andric
745753f127fSDimitry Andric  template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
746753f127fSDimitry Andric           weakly_incrementable O, class Comp = ranges::less,
747753f127fSDimitry Andric           class Proj1 = identity, class Proj2 = identity>
748753f127fSDimitry Andric    requires mergeable<I1, I2, O, Comp, Proj1, Proj2>
749753f127fSDimitry Andric    constexpr set_intersection_result<I1, I2, O>
750753f127fSDimitry Andric      set_intersection(I1 first1, S1 last1, I2 first2, S2 last2, O result,
751753f127fSDimitry Andric                       Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {});                         // since C++20
752753f127fSDimitry Andric
753753f127fSDimitry Andric  template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
754753f127fSDimitry Andric           weakly_incrementable O, class Comp = ranges::less,
755753f127fSDimitry Andric           class Proj1 = identity, class Proj2 = identity>
756753f127fSDimitry Andric    requires mergeable<I1, I2, O, Comp, Proj1, Proj2>
757753f127fSDimitry Andric    constexpr set_intersection_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>, O>
758753f127fSDimitry Andric      set_intersection(R1&& r1, R2&& r2, O result,
759753f127fSDimitry Andric                       Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {});                         // since C++20
760753f127fSDimitry Andric
761753f127fSDimitry Andric  template <class _InIter, class _OutIter>
762753f127fSDimitry Andric  using reverse_copy_result = in_out_result<_InIter, _OutIter>;                                     // since C++20
763753f127fSDimitry Andric
764753f127fSDimitry Andric  template<bidirectional_iterator I, sentinel_for<I> S, weakly_incrementable O>
765753f127fSDimitry Andric    requires indirectly_copyable<I, O>
766753f127fSDimitry Andric    constexpr ranges::reverse_copy_result<I, O>
767753f127fSDimitry Andric      ranges::reverse_copy(I first, S last, O result);                                              // since C++20
768753f127fSDimitry Andric
769753f127fSDimitry Andric  template<bidirectional_range R, weakly_incrementable O>
770753f127fSDimitry Andric    requires indirectly_copyable<iterator_t<R>, O>
771753f127fSDimitry Andric    constexpr ranges::reverse_copy_result<borrowed_iterator_t<R>, O>
772753f127fSDimitry Andric      ranges::reverse_copy(R&& r, O result);                                                        // since C++20
773753f127fSDimitry Andric
77461cfbce3SDimitry Andric  template<permutable I, sentinel_for<I> S>
77561cfbce3SDimitry Andric    constexpr subrange<I> rotate(I first, I middle, S last);                                        // since C++20
77661cfbce3SDimitry Andric
77761cfbce3SDimitry Andric  template<forward_range R>
77861cfbce3SDimitry Andric    requires permutable<iterator_t<R>>
779*06c3fb27SDimitry Andric    constexpr borrowed_subrange_t<R> rotate(R&& r, iterator_t<R> middle);                           // since C++20
78061cfbce3SDimitry Andric
781753f127fSDimitry Andric  template <class _InIter, class _OutIter>
782753f127fSDimitry Andric  using rotate_copy_result = in_out_result<_InIter, _OutIter>;                                      // since C++20
783753f127fSDimitry Andric
784753f127fSDimitry Andric  template<forward_iterator I, sentinel_for<I> S, weakly_incrementable O>
785753f127fSDimitry Andric    requires indirectly_copyable<I, O>
786753f127fSDimitry Andric    constexpr ranges::rotate_copy_result<I, O>
787753f127fSDimitry Andric      ranges::rotate_copy(I first, I middle, S last, O result);                                     // since C++20
788753f127fSDimitry Andric
789753f127fSDimitry Andric  template<forward_range R, weakly_incrementable O>
790753f127fSDimitry Andric    requires indirectly_copyable<iterator_t<R>, O>
791753f127fSDimitry Andric    constexpr ranges::rotate_copy_result<borrowed_iterator_t<R>, O>
792753f127fSDimitry Andric      ranges::rotate_copy(R&& r, iterator_t<R> middle, O result);                                   // since C++20
793753f127fSDimitry Andric
79461cfbce3SDimitry Andric  template<input_iterator I, sentinel_for<I> S, weakly_incrementable O, class Gen>
79561cfbce3SDimitry Andric    requires (forward_iterator<I> || random_access_iterator<O>) &&
79661cfbce3SDimitry Andric            indirectly_copyable<I, O> &&
79761cfbce3SDimitry Andric            uniform_random_bit_generator<remove_reference_t<Gen>>
798*06c3fb27SDimitry Andric    O sample(I first, S last, O out, iter_difference_t<I> n, Gen&& g);                              // since C++20
79961cfbce3SDimitry Andric
80061cfbce3SDimitry Andric  template<input_range R, weakly_incrementable O, class Gen>
80161cfbce3SDimitry Andric    requires (forward_range<R> || random_access_iterator<O>) &&
80261cfbce3SDimitry Andric            indirectly_copyable<iterator_t<R>, O> &&
80361cfbce3SDimitry Andric            uniform_random_bit_generator<remove_reference_t<Gen>>
804*06c3fb27SDimitry Andric    O sample(R&& r, O out, range_difference_t<R> n, Gen&& g);                                       // since C++20
80561cfbce3SDimitry Andric
806fcaf7f86SDimitry Andric  template<random_access_iterator I, sentinel_for<I> S, class Gen>
807fcaf7f86SDimitry Andric    requires permutable<I> &&
808fcaf7f86SDimitry Andric            uniform_random_bit_generator<remove_reference_t<Gen>>
809*06c3fb27SDimitry Andric    I shuffle(I first, S last, Gen&& g);                                                            // since C++20
810fcaf7f86SDimitry Andric
811fcaf7f86SDimitry Andric  template<random_access_range R, class Gen>
812fcaf7f86SDimitry Andric    requires permutable<iterator_t<R>> &&
813fcaf7f86SDimitry Andric            uniform_random_bit_generator<remove_reference_t<Gen>>
814*06c3fb27SDimitry Andric    borrowed_iterator_t<R> shuffle(R&& r, Gen&& g);                                                 // since C++20
815fcaf7f86SDimitry Andric
816753f127fSDimitry Andric  template<forward_iterator I1, sentinel_for<I1> S1, forward_iterator I2,
81761cfbce3SDimitry Andric         sentinel_for<I2> S2, class Proj1 = identity, class Proj2 = identity,
81861cfbce3SDimitry Andric         indirect_equivalence_relation<projected<I1, Proj1>,
81961cfbce3SDimitry Andric                                       projected<I2, Proj2>> Pred = ranges::equal_to>
82061cfbce3SDimitry Andric  constexpr bool ranges::is_permutation(I1 first1, S1 last1, I2 first2, S2 last2,
82161cfbce3SDimitry Andric                                        Pred pred = {},
822*06c3fb27SDimitry Andric                                        Proj1 proj1 = {}, Proj2 proj2 = {});                       // since C++20
82361cfbce3SDimitry Andric
82461cfbce3SDimitry Andric  template<forward_range R1, forward_range R2,
82561cfbce3SDimitry Andric         class Proj1 = identity, class Proj2 = identity,
82661cfbce3SDimitry Andric         indirect_equivalence_relation<projected<iterator_t<R1>, Proj1>,
82761cfbce3SDimitry Andric                                       projected<iterator_t<R2>, Proj2>> Pred = ranges::equal_to>
82861cfbce3SDimitry Andric  constexpr bool ranges::is_permutation(R1&& r1, R2&& r2, Pred pred = {},
829*06c3fb27SDimitry Andric                                        Proj1 proj1 = {}, Proj2 proj2 = {});                       // since C++20
83061cfbce3SDimitry Andric
83161cfbce3SDimitry Andric  template<forward_iterator I1, sentinel_for<I1> S1, forward_iterator I2,
832753f127fSDimitry Andric           sentinel_for<I2> S2, class Pred = ranges::equal_to,
833753f127fSDimitry Andric           class Proj1 = identity, class Proj2 = identity>
834753f127fSDimitry Andric    requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
835753f127fSDimitry Andric    constexpr subrange<I1>
836753f127fSDimitry Andric      ranges::search(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {},
837753f127fSDimitry Andric                     Proj1 proj1 = {}, Proj2 proj2 = {});                                           // since C++20
838753f127fSDimitry Andric
839753f127fSDimitry Andric  template<forward_range R1, forward_range R2, class Pred = ranges::equal_to,
840753f127fSDimitry Andric           class Proj1 = identity, class Proj2 = identity>
841753f127fSDimitry Andric    requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
842753f127fSDimitry Andric    constexpr borrowed_subrange_t<R1>
843753f127fSDimitry Andric      ranges::search(R1&& r1, R2&& r2, Pred pred = {},
844753f127fSDimitry Andric                     Proj1 proj1 = {}, Proj2 proj2 = {});                                           // since C++20
845753f127fSDimitry Andric
846753f127fSDimitry Andric  template<forward_iterator I, sentinel_for<I> S, class T,
847753f127fSDimitry Andric           class Pred = ranges::equal_to, class Proj = identity>
848753f127fSDimitry Andric    requires indirectly_comparable<I, const T*, Pred, Proj>
849753f127fSDimitry Andric    constexpr subrange<I>
850753f127fSDimitry Andric      ranges::search_n(I first, S last, iter_difference_t<I> count,
851753f127fSDimitry Andric                       const T& value, Pred pred = {}, Proj proj = {});                             // since C++20
852753f127fSDimitry Andric
853753f127fSDimitry Andric  template<forward_range R, class T, class Pred = ranges::equal_to,
854753f127fSDimitry Andric           class Proj = identity>
855753f127fSDimitry Andric    requires indirectly_comparable<iterator_t<R>, const T*, Pred, Proj>
856753f127fSDimitry Andric    constexpr borrowed_subrange_t<R>
857753f127fSDimitry Andric      ranges::search_n(R&& r, range_difference_t<R> count,
858753f127fSDimitry Andric                       const T& value, Pred pred = {}, Proj proj = {});                             // since C++20
859753f127fSDimitry Andric
860753f127fSDimitry Andric  template<forward_iterator I1, sentinel_for<I1> S1, forward_iterator I2, sentinel_for<I2> S2,
861753f127fSDimitry Andric           class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
862753f127fSDimitry Andric    requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
863753f127fSDimitry Andric    constexpr subrange<I1>
864753f127fSDimitry Andric      ranges::find_end(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {},
865753f127fSDimitry Andric                       Proj1 proj1 = {}, Proj2 proj2 = {});                                         // since C++20
866753f127fSDimitry Andric
867753f127fSDimitry Andric  template<forward_range R1, forward_range R2,
868753f127fSDimitry Andric           class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
869753f127fSDimitry Andric    requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
870753f127fSDimitry Andric    constexpr borrowed_subrange_t<R1>
871753f127fSDimitry Andric      ranges::find_end(R1&& r1, R2&& r2, Pred pred = {},
872753f127fSDimitry Andric                       Proj1 proj1 = {}, Proj2 proj2 = {});                                         // since C++20
873753f127fSDimitry Andric
874753f127fSDimitry Andric  template<class I1, class I2, class O>
875753f127fSDimitry Andric    using set_symmetric_difference_result = in_in_out_result<I1, I2, O>;                            // since C++20
876753f127fSDimitry Andric
877753f127fSDimitry Andric  template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
878753f127fSDimitry Andric           weakly_incrementable O, class Comp = ranges::less,
879753f127fSDimitry Andric           class Proj1 = identity, class Proj2 = identity>
880753f127fSDimitry Andric    requires mergeable<I1, I2, O, Comp, Proj1, Proj2>
881753f127fSDimitry Andric    constexpr set_symmetric_difference_result<I1, I2, O>
882753f127fSDimitry Andric      set_symmetric_difference(I1 first1, S1 last1, I2 first2, S2 last2, O result,
883753f127fSDimitry Andric                               Comp comp = {}, Proj1 proj1 = {},
884753f127fSDimitry Andric                               Proj2 proj2 = {});                                                   // since C++20
885753f127fSDimitry Andric
886753f127fSDimitry Andric  template<input_range R1, input_range R2, weakly_incrementable O,
887753f127fSDimitry Andric           class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity>
888753f127fSDimitry Andric    requires mergeable<iterator_t<R1>, iterator_t<R2>, O, Comp, Proj1, Proj2>
889753f127fSDimitry Andric    constexpr set_symmetric_difference_result<borrowed_iterator_t<R1>,
890753f127fSDimitry Andric                                                      borrowed_iterator_t<R2>, O>
891753f127fSDimitry Andric      set_symmetric_difference(R1&& r1, R2&& r2, O result, Comp comp = {},
892753f127fSDimitry Andric                               Proj1 proj1 = {}, Proj2 proj2 = {});                                 // since C++20
89381ad6265SDimitry Andric
894fcaf7f86SDimitry Andric  template<forward_iterator I, sentinel_for<I> S, class T, class Proj = identity,
895fcaf7f86SDimitry Andric           indirect_strict_weak_order<const T*, projected<I, Proj>> Comp = ranges::less>
896fcaf7f86SDimitry Andric    constexpr subrange<I>
897fcaf7f86SDimitry Andric      equal_range(I first, S last, const T& value, Comp comp = {}, Proj proj = {});                 // since C++20
898fcaf7f86SDimitry Andric
899fcaf7f86SDimitry Andric  template<forward_range R, class T, class Proj = identity,
900fcaf7f86SDimitry Andric           indirect_strict_weak_order<const T*, projected<iterator_t<R>, Proj>> Comp =
901fcaf7f86SDimitry Andric             ranges::less>
902fcaf7f86SDimitry Andric    constexpr borrowed_subrange_t<R>
903fcaf7f86SDimitry Andric      equal_range(R&& r, const T& value, Comp comp = {}, Proj proj = {});                           // since C++20
904fcaf7f86SDimitry Andric
905fcaf7f86SDimitry Andric  template<class I1, class I2, class O>
906fcaf7f86SDimitry Andric    using set_union_result = in_in_out_result<I1, I2, O>;                                           // since C++20
907fcaf7f86SDimitry Andric
908fcaf7f86SDimitry Andric  template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
909fcaf7f86SDimitry Andric           weakly_incrementable O, class Comp = ranges::less,
910fcaf7f86SDimitry Andric           class Proj1 = identity, class Proj2 = identity>
911fcaf7f86SDimitry Andric    requires mergeable<I1, I2, O, Comp, Proj1, Proj2>
912fcaf7f86SDimitry Andric    constexpr set_union_result<I1, I2, O>
913fcaf7f86SDimitry Andric      set_union(I1 first1, S1 last1, I2 first2, S2 last2, O result, Comp comp = {},
914fcaf7f86SDimitry Andric                Proj1 proj1 = {}, Proj2 proj2 = {});                                                // since C++20
915fcaf7f86SDimitry Andric
916fcaf7f86SDimitry Andric  template<input_range R1, input_range R2, weakly_incrementable O,
917fcaf7f86SDimitry Andric           class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity>
918fcaf7f86SDimitry Andric    requires mergeable<iterator_t<R1>, iterator_t<R2>, O, Comp, Proj1, Proj2>
919fcaf7f86SDimitry Andric    constexpr set_union_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>, O>
920fcaf7f86SDimitry Andric      set_union(R1&& r1, R2&& r2, O result, Comp comp = {},
921fcaf7f86SDimitry Andric                Proj1 proj1 = {}, Proj2 proj2 = {});                                                // since C++20
922fcaf7f86SDimitry Andric
923fcaf7f86SDimitry Andric  template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
924fcaf7f86SDimitry Andric           class Proj1 = identity, class Proj2 = identity,
925fcaf7f86SDimitry Andric           indirect_strict_weak_order<projected<I1, Proj1>, projected<I2, Proj2>> Comp =
926fcaf7f86SDimitry Andric             ranges::less>
927fcaf7f86SDimitry Andric    constexpr bool includes(I1 first1, S1 last1, I2 first2, S2 last2, Comp comp = {},
928*06c3fb27SDimitry Andric                            Proj1 proj1 = {}, Proj2 proj2 = {});                                   // since C++20
929fcaf7f86SDimitry Andric
930fcaf7f86SDimitry Andric  template<input_range R1, input_range R2, class Proj1 = identity,
931fcaf7f86SDimitry Andric           class Proj2 = identity,
932fcaf7f86SDimitry Andric           indirect_strict_weak_order<projected<iterator_t<R1>, Proj1>,
933fcaf7f86SDimitry Andric                                      projected<iterator_t<R2>, Proj2>> Comp = ranges::less>
934fcaf7f86SDimitry Andric    constexpr bool includes(R1&& r1, R2&& r2, Comp comp = {},
935*06c3fb27SDimitry Andric                            Proj1 proj1 = {}, Proj2 proj2 = {});                                   // since C++20
93661cfbce3SDimitry Andric
93761cfbce3SDimitry Andric  template<bidirectional_iterator I, sentinel_for<I> S, class Comp = ranges::less,
93861cfbce3SDimitry Andric           class Proj = identity>
93961cfbce3SDimitry Andric    requires sortable<I, Comp, Proj>
940*06c3fb27SDimitry Andric    I inplace_merge(I first, I middle, S last, Comp comp = {}, Proj proj = {});                    // since C++20
94161cfbce3SDimitry Andric
94261cfbce3SDimitry Andric  template<bidirectional_range R, class Comp = ranges::less, class Proj = identity>
94361cfbce3SDimitry Andric    requires sortable<iterator_t<R>, Comp, Proj>
94461cfbce3SDimitry Andric    borrowed_iterator_t<R>
94561cfbce3SDimitry Andric      inplace_merge(R&& r, iterator_t<R> middle, Comp comp = {},
946*06c3fb27SDimitry Andric                    Proj proj = {});                                                               // since C++20
94761cfbce3SDimitry Andric
94861cfbce3SDimitry Andric  template<permutable I, sentinel_for<I> S, class Proj = identity,
94961cfbce3SDimitry Andric           indirect_equivalence_relation<projected<I, Proj>> C = ranges::equal_to>
950*06c3fb27SDimitry Andric    constexpr subrange<I> unique(I first, S last, C comp = {}, Proj proj = {});                    // since C++20
95161cfbce3SDimitry Andric
95261cfbce3SDimitry Andric  template<forward_range R, class Proj = identity,
95361cfbce3SDimitry Andric           indirect_equivalence_relation<projected<iterator_t<R>, Proj>> C = ranges::equal_to>
95461cfbce3SDimitry Andric    requires permutable<iterator_t<R>>
95561cfbce3SDimitry Andric    constexpr borrowed_subrange_t<R>
956*06c3fb27SDimitry Andric      unique(R&& r, C comp = {}, Proj proj = {});                                                  // since C++20
95761cfbce3SDimitry Andric
95861cfbce3SDimitry Andric  template<input_iterator I, sentinel_for<I> S, weakly_incrementable O, class Proj = identity,
95961cfbce3SDimitry Andric           indirect_equivalence_relation<projected<I, Proj>> C = ranges::equal_to>
96061cfbce3SDimitry Andric    requires indirectly_copyable<I, O> &&
96161cfbce3SDimitry Andric             (forward_iterator<I> ||
96261cfbce3SDimitry Andric              (input_iterator<O> && same_as<iter_value_t<I>, iter_value_t<O>>) ||
96361cfbce3SDimitry Andric              indirectly_copyable_storable<I, O>)
96461cfbce3SDimitry Andric    constexpr unique_copy_result<I, O>
965*06c3fb27SDimitry Andric      unique_copy(I first, S last, O result, C comp = {}, Proj proj = {});                         // since C++20
96661cfbce3SDimitry Andric
96761cfbce3SDimitry Andric  template<input_range R, weakly_incrementable O, class Proj = identity,
96861cfbce3SDimitry Andric           indirect_equivalence_relation<projected<iterator_t<R>, Proj>> C = ranges::equal_to>
96961cfbce3SDimitry Andric    requires indirectly_copyable<iterator_t<R>, O> &&
97061cfbce3SDimitry Andric             (forward_iterator<iterator_t<R>> ||
97161cfbce3SDimitry Andric              (input_iterator<O> && same_as<range_value_t<R>, iter_value_t<O>>) ||
97261cfbce3SDimitry Andric              indirectly_copyable_storable<iterator_t<R>, O>)
97361cfbce3SDimitry Andric    constexpr unique_copy_result<borrowed_iterator_t<R>, O>
974*06c3fb27SDimitry Andric      unique_copy(R&& r, O result, C comp = {}, Proj proj = {});                                   // since C++20
97561cfbce3SDimitry Andric
97661cfbce3SDimitry Andric  template<class I, class O>
977*06c3fb27SDimitry Andric      using remove_copy_result = in_out_result<I, O>;                                              // since C++20
97861cfbce3SDimitry Andric
97961cfbce3SDimitry Andric  template<input_iterator I, sentinel_for<I> S, weakly_incrementable O, class T,
98061cfbce3SDimitry Andric           class Proj = identity>
98161cfbce3SDimitry Andric             indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
98261cfbce3SDimitry Andric    constexpr remove_copy_result<I, O>
983*06c3fb27SDimitry Andric      remove_copy(I first, S last, O result, const T& value, Proj proj = {});                      // since C++20
98461cfbce3SDimitry Andric
98561cfbce3SDimitry Andric  template<input_range R, weakly_incrementable O, class T, class Proj = identity>
98661cfbce3SDimitry Andric    requires indirectly_copyable<iterator_t<R>, O> &&
98761cfbce3SDimitry Andric             indirect_binary_predicate<ranges::equal_to,
98861cfbce3SDimitry Andric                                       projected<iterator_t<R>, Proj>, const T*>
98961cfbce3SDimitry Andric    constexpr remove_copy_result<borrowed_iterator_t<R>, O>
990*06c3fb27SDimitry Andric      remove_copy(R&& r, O result, const T& value, Proj proj = {});                                // since C++20
99161cfbce3SDimitry Andric
99261cfbce3SDimitry Andric  template<class I, class O>
993*06c3fb27SDimitry Andric      using remove_copy_if_result = in_out_result<I, O>;                                           // since C++20
99461cfbce3SDimitry Andric
99561cfbce3SDimitry Andric  template<input_iterator I, sentinel_for<I> S, weakly_incrementable O,
99661cfbce3SDimitry Andric           class Proj = identity, indirect_unary_predicate<projected<I, Proj>> Pred>
99761cfbce3SDimitry Andric    requires indirectly_copyable<I, O>
99861cfbce3SDimitry Andric    constexpr remove_copy_if_result<I, O>
999*06c3fb27SDimitry Andric      remove_copy_if(I first, S last, O result, Pred pred, Proj proj = {});                        // since C++20
100061cfbce3SDimitry Andric
100161cfbce3SDimitry Andric  template<input_range R, weakly_incrementable O, class Proj = identity,
100261cfbce3SDimitry Andric           indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
100361cfbce3SDimitry Andric    requires indirectly_copyable<iterator_t<R>, O>
100461cfbce3SDimitry Andric    constexpr remove_copy_if_result<borrowed_iterator_t<R>, O>
1005*06c3fb27SDimitry Andric      remove_copy_if(R&& r, O result, Pred pred, Proj proj = {});                                  // since C++20
100661cfbce3SDimitry Andric
100761cfbce3SDimitry Andric  template<class I, class O>
1008*06c3fb27SDimitry Andric      using replace_copy_result = in_out_result<I, O>;                                             // since C++20
100961cfbce3SDimitry Andric
101061cfbce3SDimitry Andric  template<input_iterator I, sentinel_for<I> S, class T1, class T2,
101161cfbce3SDimitry Andric           output_iterator<const T2&> O, class Proj = identity>
101261cfbce3SDimitry Andric    requires indirectly_copyable<I, O> &&
101361cfbce3SDimitry Andric             indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T1*>
101461cfbce3SDimitry Andric    constexpr replace_copy_result<I, O>
101561cfbce3SDimitry Andric      replace_copy(I first, S last, O result, const T1& old_value, const T2& new_value,
1016*06c3fb27SDimitry Andric                   Proj proj = {});                                                                // since C++20
101761cfbce3SDimitry Andric
101861cfbce3SDimitry Andric  template<input_range R, class T1, class T2, output_iterator<const T2&> O,
101961cfbce3SDimitry Andric           class Proj = identity>
102061cfbce3SDimitry Andric    requires indirectly_copyable<iterator_t<R>, O> &&
102161cfbce3SDimitry Andric             indirect_binary_predicate<ranges::equal_to,
102261cfbce3SDimitry Andric                                       projected<iterator_t<R>, Proj>, const T1*>
102361cfbce3SDimitry Andric    constexpr replace_copy_result<borrowed_iterator_t<R>, O>
102461cfbce3SDimitry Andric      replace_copy(R&& r, O result, const T1& old_value, const T2& new_value,
1025*06c3fb27SDimitry Andric                   Proj proj = {});                                                                // since C++20
102661cfbce3SDimitry Andric
102761cfbce3SDimitry Andric  template<class I, class O>
1028*06c3fb27SDimitry Andric      using replace_copy_if_result = in_out_result<I, O>;                                          // since C++20
102961cfbce3SDimitry Andric
103061cfbce3SDimitry Andric  template<input_iterator I, sentinel_for<I> S, class T, output_iterator<const T&> O,
103161cfbce3SDimitry Andric           class Proj = identity, indirect_unary_predicate<projected<I, Proj>> Pred>
103261cfbce3SDimitry Andric    requires indirectly_copyable<I, O>
103361cfbce3SDimitry Andric    constexpr replace_copy_if_result<I, O>
103461cfbce3SDimitry Andric      replace_copy_if(I first, S last, O result, Pred pred, const T& new_value,
1035*06c3fb27SDimitry Andric                      Proj proj = {});                                                             // since C++20
103661cfbce3SDimitry Andric
103761cfbce3SDimitry Andric  template<input_range R, class T, output_iterator<const T&> O, class Proj = identity,
103861cfbce3SDimitry Andric           indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
103961cfbce3SDimitry Andric    requires indirectly_copyable<iterator_t<R>, O>
104061cfbce3SDimitry Andric    constexpr replace_copy_if_result<borrowed_iterator_t<R>, O>
104161cfbce3SDimitry Andric      replace_copy_if(R&& r, O result, Pred pred, const T& new_value,
1042*06c3fb27SDimitry Andric                      Proj proj = {});                                                             // since C++20
104361cfbce3SDimitry Andric
104461cfbce3SDimitry Andric  template<class I>
1045*06c3fb27SDimitry Andric    using prev_permutation_result = in_found_result<I>;                                            // since C++20
104661cfbce3SDimitry Andric
104761cfbce3SDimitry Andric  template<bidirectional_iterator I, sentinel_for<I> S, class Comp = ranges::less,
104861cfbce3SDimitry Andric           class Proj = identity>
104961cfbce3SDimitry Andric    requires sortable<I, Comp, Proj>
105061cfbce3SDimitry Andric    constexpr ranges::prev_permutation_result<I>
1051*06c3fb27SDimitry Andric      ranges::prev_permutation(I first, S last, Comp comp = {}, Proj proj = {});                   // since C++20
105261cfbce3SDimitry Andric
105361cfbce3SDimitry Andric  template<bidirectional_range R, class Comp = ranges::less,
105461cfbce3SDimitry Andric           class Proj = identity>
105561cfbce3SDimitry Andric    requires sortable<iterator_t<R>, Comp, Proj>
105661cfbce3SDimitry Andric    constexpr ranges::prev_permutation_result<borrowed_iterator_t<R>>
1057*06c3fb27SDimitry Andric      ranges::prev_permutation(R&& r, Comp comp = {}, Proj proj = {});                             // since C++20
105861cfbce3SDimitry Andric
105961cfbce3SDimitry Andric  template<class I>
1060*06c3fb27SDimitry Andric    using next_permutation_result = in_found_result<I>;                                            // since C++20
106161cfbce3SDimitry Andric
106261cfbce3SDimitry Andric  template<bidirectional_iterator I, sentinel_for<I> S, class Comp = ranges::less,
106361cfbce3SDimitry Andric           class Proj = identity>
106461cfbce3SDimitry Andric    requires sortable<I, Comp, Proj>
106561cfbce3SDimitry Andric    constexpr ranges::next_permutation_result<I>
1066*06c3fb27SDimitry Andric      ranges::next_permutation(I first, S last, Comp comp = {}, Proj proj = {});                   // since C++20
106761cfbce3SDimitry Andric
106861cfbce3SDimitry Andric  template<bidirectional_range R, class Comp = ranges::less,
106961cfbce3SDimitry Andric           class Proj = identity>
107061cfbce3SDimitry Andric    requires sortable<iterator_t<R>, Comp, Proj>
107161cfbce3SDimitry Andric    constexpr ranges::next_permutation_result<borrowed_iterator_t<R>>
1072*06c3fb27SDimitry Andric      ranges::next_permutation(R&& r, Comp comp = {}, Proj proj = {});                             // since C++20
107361cfbce3SDimitry Andric
107404eeddc0SDimitry Andric}
107504eeddc0SDimitry Andric
107661cfbce3SDimitry Andrictemplate <class InputIterator, class Predicate>
10770b57cec5SDimitry Andric    constexpr bool     // constexpr in C++20
10780b57cec5SDimitry Andric    all_of(InputIterator first, InputIterator last, Predicate pred);
10790b57cec5SDimitry Andric
10800b57cec5SDimitry Andrictemplate <class InputIterator, class Predicate>
10810b57cec5SDimitry Andric    constexpr bool     // constexpr in C++20
10820b57cec5SDimitry Andric    any_of(InputIterator first, InputIterator last, Predicate pred);
10830b57cec5SDimitry Andric
10840b57cec5SDimitry Andrictemplate <class InputIterator, class Predicate>
10850b57cec5SDimitry Andric    constexpr bool     // constexpr in C++20
10860b57cec5SDimitry Andric    none_of(InputIterator first, InputIterator last, Predicate pred);
10870b57cec5SDimitry Andric
10880b57cec5SDimitry Andrictemplate <class InputIterator, class Function>
10890b57cec5SDimitry Andric    constexpr Function          // constexpr in C++20
10900b57cec5SDimitry Andric    for_each(InputIterator first, InputIterator last, Function f);
10910b57cec5SDimitry Andric
10920b57cec5SDimitry Andrictemplate<class InputIterator, class Size, class Function>
10930b57cec5SDimitry Andric    constexpr InputIterator     // constexpr in C++20
10940b57cec5SDimitry Andric    for_each_n(InputIterator first, Size n, Function f); // C++17
10950b57cec5SDimitry Andric
10960b57cec5SDimitry Andrictemplate <class InputIterator, class T>
10970b57cec5SDimitry Andric    constexpr InputIterator     // constexpr in C++20
10980b57cec5SDimitry Andric    find(InputIterator first, InputIterator last, const T& value);
10990b57cec5SDimitry Andric
11000b57cec5SDimitry Andrictemplate <class InputIterator, class Predicate>
11010b57cec5SDimitry Andric    constexpr InputIterator     // constexpr in C++20
11020b57cec5SDimitry Andric    find_if(InputIterator first, InputIterator last, Predicate pred);
11030b57cec5SDimitry Andric
11040b57cec5SDimitry Andrictemplate<class InputIterator, class Predicate>
1105e8d8bef9SDimitry Andric    constexpr InputIterator     // constexpr in C++20
11060b57cec5SDimitry Andric    find_if_not(InputIterator first, InputIterator last, Predicate pred);
11070b57cec5SDimitry Andric
11080b57cec5SDimitry Andrictemplate <class ForwardIterator1, class ForwardIterator2>
1109e8d8bef9SDimitry Andric    constexpr ForwardIterator1  // constexpr in C++20
11100b57cec5SDimitry Andric    find_end(ForwardIterator1 first1, ForwardIterator1 last1,
11110b57cec5SDimitry Andric             ForwardIterator2 first2, ForwardIterator2 last2);
11120b57cec5SDimitry Andric
11130b57cec5SDimitry Andrictemplate <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
1114e8d8bef9SDimitry Andric    constexpr ForwardIterator1  // constexpr in C++20
11150b57cec5SDimitry Andric    find_end(ForwardIterator1 first1, ForwardIterator1 last1,
11160b57cec5SDimitry Andric             ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
11170b57cec5SDimitry Andric
11180b57cec5SDimitry Andrictemplate <class ForwardIterator1, class ForwardIterator2>
11190b57cec5SDimitry Andric    constexpr ForwardIterator1  // constexpr in C++20
11200b57cec5SDimitry Andric    find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
11210b57cec5SDimitry Andric                  ForwardIterator2 first2, ForwardIterator2 last2);
11220b57cec5SDimitry Andric
11230b57cec5SDimitry Andrictemplate <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
11240b57cec5SDimitry Andric    constexpr ForwardIterator1  // constexpr in C++20
11250b57cec5SDimitry Andric    find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
11260b57cec5SDimitry Andric                  ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
11270b57cec5SDimitry Andric
11280b57cec5SDimitry Andrictemplate <class ForwardIterator>
11290b57cec5SDimitry Andric    constexpr ForwardIterator   // constexpr in C++20
11300b57cec5SDimitry Andric    adjacent_find(ForwardIterator first, ForwardIterator last);
11310b57cec5SDimitry Andric
11320b57cec5SDimitry Andrictemplate <class ForwardIterator, class BinaryPredicate>
11330b57cec5SDimitry Andric    constexpr ForwardIterator   // constexpr in C++20
11340b57cec5SDimitry Andric    adjacent_find(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
11350b57cec5SDimitry Andric
11360b57cec5SDimitry Andrictemplate <class InputIterator, class T>
11370b57cec5SDimitry Andric    constexpr typename iterator_traits<InputIterator>::difference_type  // constexpr in C++20
11380b57cec5SDimitry Andric    count(InputIterator first, InputIterator last, const T& value);
11390b57cec5SDimitry Andric
11400b57cec5SDimitry Andrictemplate <class InputIterator, class Predicate>
11410b57cec5SDimitry Andric    constexpr typename iterator_traits<InputIterator>::difference_type // constexpr in C++20
11420b57cec5SDimitry Andric    count_if(InputIterator first, InputIterator last, Predicate pred);
11430b57cec5SDimitry Andric
11440b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2>
11450b57cec5SDimitry Andric    constexpr pair<InputIterator1, InputIterator2>   // constexpr in C++20
11460b57cec5SDimitry Andric    mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
11470b57cec5SDimitry Andric
11480b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2>
11490b57cec5SDimitry Andric    constexpr pair<InputIterator1, InputIterator2>   // constexpr in C++20
11500b57cec5SDimitry Andric    mismatch(InputIterator1 first1, InputIterator1 last1,
11510b57cec5SDimitry Andric             InputIterator2 first2, InputIterator2 last2); // **C++14**
11520b57cec5SDimitry Andric
11530b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2, class BinaryPredicate>
11540b57cec5SDimitry Andric    constexpr pair<InputIterator1, InputIterator2>   // constexpr in C++20
11550b57cec5SDimitry Andric    mismatch(InputIterator1 first1, InputIterator1 last1,
11560b57cec5SDimitry Andric             InputIterator2 first2, BinaryPredicate pred);
11570b57cec5SDimitry Andric
11580b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2, class BinaryPredicate>
11590b57cec5SDimitry Andric    constexpr pair<InputIterator1, InputIterator2>   // constexpr in C++20
11600b57cec5SDimitry Andric    mismatch(InputIterator1 first1, InputIterator1 last1,
11610b57cec5SDimitry Andric             InputIterator2 first2, InputIterator2 last2,
11620b57cec5SDimitry Andric             BinaryPredicate pred); // **C++14**
11630b57cec5SDimitry Andric
11640b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2>
11650b57cec5SDimitry Andric    constexpr bool      // constexpr in C++20
11660b57cec5SDimitry Andric    equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
11670b57cec5SDimitry Andric
11680b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2>
11690b57cec5SDimitry Andric    constexpr bool      // constexpr in C++20
11700b57cec5SDimitry Andric    equal(InputIterator1 first1, InputIterator1 last1,
11710b57cec5SDimitry Andric          InputIterator2 first2, InputIterator2 last2); // **C++14**
11720b57cec5SDimitry Andric
11730b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2, class BinaryPredicate>
11740b57cec5SDimitry Andric    constexpr bool      // constexpr in C++20
11750b57cec5SDimitry Andric    equal(InputIterator1 first1, InputIterator1 last1,
11760b57cec5SDimitry Andric          InputIterator2 first2, BinaryPredicate pred);
11770b57cec5SDimitry Andric
11780b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2, class BinaryPredicate>
11790b57cec5SDimitry Andric    constexpr bool      // constexpr in C++20
11800b57cec5SDimitry Andric    equal(InputIterator1 first1, InputIterator1 last1,
11810b57cec5SDimitry Andric          InputIterator2 first2, InputIterator2 last2,
11820b57cec5SDimitry Andric          BinaryPredicate pred); // **C++14**
11830b57cec5SDimitry Andric
11840b57cec5SDimitry Andrictemplate<class ForwardIterator1, class ForwardIterator2>
11850b57cec5SDimitry Andric    constexpr bool      // constexpr in C++20
11860b57cec5SDimitry Andric    is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
11870b57cec5SDimitry Andric                   ForwardIterator2 first2);
11880b57cec5SDimitry Andric
11890b57cec5SDimitry Andrictemplate<class ForwardIterator1, class ForwardIterator2>
11900b57cec5SDimitry Andric    constexpr bool      // constexpr in C++20
11910b57cec5SDimitry Andric    is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
11920b57cec5SDimitry Andric                   ForwardIterator2 first2, ForwardIterator2 last2); // **C++14**
11930b57cec5SDimitry Andric
11940b57cec5SDimitry Andrictemplate<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
11950b57cec5SDimitry Andric    constexpr bool      // constexpr in C++20
11960b57cec5SDimitry Andric    is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
11970b57cec5SDimitry Andric                   ForwardIterator2 first2, BinaryPredicate pred);
11980b57cec5SDimitry Andric
11990b57cec5SDimitry Andrictemplate<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
12000b57cec5SDimitry Andric    constexpr bool      // constexpr in C++20
12010b57cec5SDimitry Andric    is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
12020b57cec5SDimitry Andric                   ForwardIterator2 first2, ForwardIterator2 last2,
12030b57cec5SDimitry Andric                   BinaryPredicate pred);  // **C++14**
12040b57cec5SDimitry Andric
12050b57cec5SDimitry Andrictemplate <class ForwardIterator1, class ForwardIterator2>
12060b57cec5SDimitry Andric    constexpr ForwardIterator1      // constexpr in C++20
12070b57cec5SDimitry Andric    search(ForwardIterator1 first1, ForwardIterator1 last1,
12080b57cec5SDimitry Andric           ForwardIterator2 first2, ForwardIterator2 last2);
12090b57cec5SDimitry Andric
12100b57cec5SDimitry Andrictemplate <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
12110b57cec5SDimitry Andric    constexpr ForwardIterator1      // constexpr in C++20
12120b57cec5SDimitry Andric    search(ForwardIterator1 first1, ForwardIterator1 last1,
12130b57cec5SDimitry Andric           ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
12140b57cec5SDimitry Andric
12150b57cec5SDimitry Andrictemplate <class ForwardIterator, class Size, class T>
12160b57cec5SDimitry Andric    constexpr ForwardIterator       // constexpr in C++20
12170b57cec5SDimitry Andric    search_n(ForwardIterator first, ForwardIterator last, Size count, const T& value);
12180b57cec5SDimitry Andric
12190b57cec5SDimitry Andrictemplate <class ForwardIterator, class Size, class T, class BinaryPredicate>
12200b57cec5SDimitry Andric    constexpr ForwardIterator       // constexpr in C++20
12210b57cec5SDimitry Andric    search_n(ForwardIterator first, ForwardIterator last,
12220b57cec5SDimitry Andric             Size count, const T& value, BinaryPredicate pred);
12230b57cec5SDimitry Andric
12240b57cec5SDimitry Andrictemplate <class InputIterator, class OutputIterator>
1225480093f4SDimitry Andric    constexpr OutputIterator      // constexpr in C++20
12260b57cec5SDimitry Andric    copy(InputIterator first, InputIterator last, OutputIterator result);
12270b57cec5SDimitry Andric
12280b57cec5SDimitry Andrictemplate<class InputIterator, class OutputIterator, class Predicate>
1229480093f4SDimitry Andric    constexpr OutputIterator      // constexpr in C++20
12300b57cec5SDimitry Andric    copy_if(InputIterator first, InputIterator last,
12310b57cec5SDimitry Andric            OutputIterator result, Predicate pred);
12320b57cec5SDimitry Andric
12330b57cec5SDimitry Andrictemplate<class InputIterator, class Size, class OutputIterator>
1234480093f4SDimitry Andric    constexpr OutputIterator      // constexpr in C++20
12350b57cec5SDimitry Andric    copy_n(InputIterator first, Size n, OutputIterator result);
12360b57cec5SDimitry Andric
12370b57cec5SDimitry Andrictemplate <class BidirectionalIterator1, class BidirectionalIterator2>
1238480093f4SDimitry Andric    constexpr BidirectionalIterator2      // constexpr in C++20
12390b57cec5SDimitry Andric    copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last,
12400b57cec5SDimitry Andric                  BidirectionalIterator2 result);
12410b57cec5SDimitry Andric
124281ad6265SDimitry Andric// [alg.move], move
124381ad6265SDimitry Andrictemplate<class InputIterator, class OutputIterator>
124481ad6265SDimitry Andric    constexpr OutputIterator move(InputIterator first, InputIterator last,
124581ad6265SDimitry Andric                                OutputIterator result);
124681ad6265SDimitry Andric
124781ad6265SDimitry Andrictemplate<class BidirectionalIterator1, class BidirectionalIterator2>
124881ad6265SDimitry Andric    constexpr BidirectionalIterator2
124981ad6265SDimitry Andric    move_backward(BidirectionalIterator1 first, BidirectionalIterator1 last,
125081ad6265SDimitry Andric                  BidirectionalIterator2 result);
125181ad6265SDimitry Andric
12520b57cec5SDimitry Andrictemplate <class ForwardIterator1, class ForwardIterator2>
1253e8d8bef9SDimitry Andric    constexpr ForwardIterator2    // constexpr in C++20
12540b57cec5SDimitry Andric    swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2);
12550b57cec5SDimitry Andric
125681ad6265SDimitry Andricnamespace ranges {
125781ad6265SDimitry Andric    template<class I1, class I2>
125881ad6265SDimitry Andric    using swap_ranges_result = in_in_result<I1, I2>;
125981ad6265SDimitry Andric
126081ad6265SDimitry Andrictemplate<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2>
126181ad6265SDimitry Andric        requires indirectly_swappable<I1, I2>
126281ad6265SDimitry Andric    constexpr ranges::swap_ranges_result<I1, I2>
126381ad6265SDimitry Andric        swap_ranges(I1 first1, S1 last1, I2 first2, S2 last2);
126481ad6265SDimitry Andric
126581ad6265SDimitry Andrictemplate<input_range R1, input_range R2>
126681ad6265SDimitry Andric        requires indirectly_swappable<iterator_t<R1>, iterator_t<R2>>
126781ad6265SDimitry Andric    constexpr ranges::swap_ranges_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>>
126881ad6265SDimitry Andric        swap_ranges(R1&& r1, R2&& r2);
126981ad6265SDimitry Andric}
127081ad6265SDimitry Andric
12710b57cec5SDimitry Andrictemplate <class ForwardIterator1, class ForwardIterator2>
1272e8d8bef9SDimitry Andric    constexpr void                // constexpr in C++20
12730b57cec5SDimitry Andric    iter_swap(ForwardIterator1 a, ForwardIterator2 b);
12740b57cec5SDimitry Andric
12750b57cec5SDimitry Andrictemplate <class InputIterator, class OutputIterator, class UnaryOperation>
12760b57cec5SDimitry Andric    constexpr OutputIterator      // constexpr in C++20
12770b57cec5SDimitry Andric    transform(InputIterator first, InputIterator last, OutputIterator result, UnaryOperation op);
12780b57cec5SDimitry Andric
12790b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2, class OutputIterator, class BinaryOperation>
12800b57cec5SDimitry Andric    constexpr OutputIterator      // constexpr in C++20
12810b57cec5SDimitry Andric    transform(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2,
12820b57cec5SDimitry Andric              OutputIterator result, BinaryOperation binary_op);
12830b57cec5SDimitry Andric
12840b57cec5SDimitry Andrictemplate <class ForwardIterator, class T>
12850b57cec5SDimitry Andric    constexpr void      // constexpr in C++20
12860b57cec5SDimitry Andric    replace(ForwardIterator first, ForwardIterator last, const T& old_value, const T& new_value);
12870b57cec5SDimitry Andric
12880b57cec5SDimitry Andrictemplate <class ForwardIterator, class Predicate, class T>
12890b57cec5SDimitry Andric    constexpr void      // constexpr in C++20
12900b57cec5SDimitry Andric    replace_if(ForwardIterator first, ForwardIterator last, Predicate pred, const T& new_value);
12910b57cec5SDimitry Andric
12920b57cec5SDimitry Andrictemplate <class InputIterator, class OutputIterator, class T>
12930b57cec5SDimitry Andric    constexpr OutputIterator      // constexpr in C++20
12940b57cec5SDimitry Andric    replace_copy(InputIterator first, InputIterator last, OutputIterator result,
12950b57cec5SDimitry Andric                 const T& old_value, const T& new_value);
12960b57cec5SDimitry Andric
12970b57cec5SDimitry Andrictemplate <class InputIterator, class OutputIterator, class Predicate, class T>
12980b57cec5SDimitry Andric    constexpr OutputIterator      // constexpr in C++20
12990b57cec5SDimitry Andric    replace_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred, const T& new_value);
13000b57cec5SDimitry Andric
13010b57cec5SDimitry Andrictemplate <class ForwardIterator, class T>
13020b57cec5SDimitry Andric    constexpr void      // constexpr in C++20
13030b57cec5SDimitry Andric    fill(ForwardIterator first, ForwardIterator last, const T& value);
13040b57cec5SDimitry Andric
13050b57cec5SDimitry Andrictemplate <class OutputIterator, class Size, class T>
13060b57cec5SDimitry Andric    constexpr OutputIterator      // constexpr in C++20
13070b57cec5SDimitry Andric    fill_n(OutputIterator first, Size n, const T& value);
13080b57cec5SDimitry Andric
13090b57cec5SDimitry Andrictemplate <class ForwardIterator, class Generator>
13100b57cec5SDimitry Andric    constexpr void      // constexpr in C++20
13110b57cec5SDimitry Andric    generate(ForwardIterator first, ForwardIterator last, Generator gen);
13120b57cec5SDimitry Andric
13130b57cec5SDimitry Andrictemplate <class OutputIterator, class Size, class Generator>
13140b57cec5SDimitry Andric    constexpr OutputIterator      // constexpr in C++20
13150b57cec5SDimitry Andric    generate_n(OutputIterator first, Size n, Generator gen);
13160b57cec5SDimitry Andric
13170b57cec5SDimitry Andrictemplate <class ForwardIterator, class T>
13180b57cec5SDimitry Andric    constexpr ForwardIterator     // constexpr in C++20
13190b57cec5SDimitry Andric    remove(ForwardIterator first, ForwardIterator last, const T& value);
13200b57cec5SDimitry Andric
13210b57cec5SDimitry Andrictemplate <class ForwardIterator, class Predicate>
13220b57cec5SDimitry Andric    constexpr ForwardIterator     // constexpr in C++20
13230b57cec5SDimitry Andric    remove_if(ForwardIterator first, ForwardIterator last, Predicate pred);
13240b57cec5SDimitry Andric
13250b57cec5SDimitry Andrictemplate <class InputIterator, class OutputIterator, class T>
13260b57cec5SDimitry Andric    constexpr OutputIterator     // constexpr in C++20
13270b57cec5SDimitry Andric    remove_copy(InputIterator first, InputIterator last, OutputIterator result, const T& value);
13280b57cec5SDimitry Andric
13290b57cec5SDimitry Andrictemplate <class InputIterator, class OutputIterator, class Predicate>
13300b57cec5SDimitry Andric    constexpr OutputIterator     // constexpr in C++20
13310b57cec5SDimitry Andric    remove_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred);
13320b57cec5SDimitry Andric
13330b57cec5SDimitry Andrictemplate <class ForwardIterator>
1334e8d8bef9SDimitry Andric    constexpr ForwardIterator    // constexpr in C++20
13350b57cec5SDimitry Andric    unique(ForwardIterator first, ForwardIterator last);
13360b57cec5SDimitry Andric
13370b57cec5SDimitry Andrictemplate <class ForwardIterator, class BinaryPredicate>
1338e8d8bef9SDimitry Andric    constexpr ForwardIterator    // constexpr in C++20
13390b57cec5SDimitry Andric    unique(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
13400b57cec5SDimitry Andric
13410b57cec5SDimitry Andrictemplate <class InputIterator, class OutputIterator>
1342e8d8bef9SDimitry Andric    constexpr OutputIterator     // constexpr in C++20
13430b57cec5SDimitry Andric    unique_copy(InputIterator first, InputIterator last, OutputIterator result);
13440b57cec5SDimitry Andric
13450b57cec5SDimitry Andrictemplate <class InputIterator, class OutputIterator, class BinaryPredicate>
1346e8d8bef9SDimitry Andric    constexpr OutputIterator     // constexpr in C++20
13470b57cec5SDimitry Andric    unique_copy(InputIterator first, InputIterator last, OutputIterator result, BinaryPredicate pred);
13480b57cec5SDimitry Andric
13490b57cec5SDimitry Andrictemplate <class BidirectionalIterator>
1350e8d8bef9SDimitry Andric    constexpr void               // constexpr in C++20
13510b57cec5SDimitry Andric    reverse(BidirectionalIterator first, BidirectionalIterator last);
13520b57cec5SDimitry Andric
13530b57cec5SDimitry Andrictemplate <class BidirectionalIterator, class OutputIterator>
13540b57cec5SDimitry Andric    constexpr OutputIterator       // constexpr in C++20
13550b57cec5SDimitry Andric    reverse_copy(BidirectionalIterator first, BidirectionalIterator last, OutputIterator result);
13560b57cec5SDimitry Andric
13570b57cec5SDimitry Andrictemplate <class ForwardIterator>
1358e8d8bef9SDimitry Andric    constexpr ForwardIterator      // constexpr in C++20
13590b57cec5SDimitry Andric    rotate(ForwardIterator first, ForwardIterator middle, ForwardIterator last);
13600b57cec5SDimitry Andric
13610b57cec5SDimitry Andrictemplate <class ForwardIterator, class OutputIterator>
1362e8d8bef9SDimitry Andric    constexpr OutputIterator       // constexpr in C++20
13630b57cec5SDimitry Andric    rotate_copy(ForwardIterator first, ForwardIterator middle, ForwardIterator last, OutputIterator result);
13640b57cec5SDimitry Andric
13650b57cec5SDimitry Andrictemplate <class RandomAccessIterator>
13660b57cec5SDimitry Andric    void
13670b57cec5SDimitry Andric    random_shuffle(RandomAccessIterator first, RandomAccessIterator last); // deprecated in C++14, removed in C++17
13680b57cec5SDimitry Andric
13690b57cec5SDimitry Andrictemplate <class RandomAccessIterator, class RandomNumberGenerator>
13700b57cec5SDimitry Andric    void
13710b57cec5SDimitry Andric    random_shuffle(RandomAccessIterator first, RandomAccessIterator last,
13720b57cec5SDimitry Andric                   RandomNumberGenerator& rand);  // deprecated in C++14, removed in C++17
13730b57cec5SDimitry Andric
13740b57cec5SDimitry Andrictemplate<class PopulationIterator, class SampleIterator,
13750b57cec5SDimitry Andric         class Distance, class UniformRandomBitGenerator>
13760b57cec5SDimitry Andric    SampleIterator sample(PopulationIterator first, PopulationIterator last,
13770b57cec5SDimitry Andric                          SampleIterator out, Distance n,
13780b57cec5SDimitry Andric                          UniformRandomBitGenerator&& g); // C++17
13790b57cec5SDimitry Andric
13800b57cec5SDimitry Andrictemplate<class RandomAccessIterator, class UniformRandomNumberGenerator>
13810b57cec5SDimitry Andric    void shuffle(RandomAccessIterator first, RandomAccessIterator last,
13820b57cec5SDimitry Andric                 UniformRandomNumberGenerator&& g);
13830b57cec5SDimitry Andric
1384e8d8bef9SDimitry Andrictemplate<class ForwardIterator>
1385e8d8bef9SDimitry Andric  constexpr ForwardIterator
1386e8d8bef9SDimitry Andric    shift_left(ForwardIterator first, ForwardIterator last,
1387e8d8bef9SDimitry Andric               typename iterator_traits<ForwardIterator>::difference_type n); // C++20
1388e8d8bef9SDimitry Andric
1389e8d8bef9SDimitry Andrictemplate<class ForwardIterator>
1390e8d8bef9SDimitry Andric  constexpr ForwardIterator
1391e8d8bef9SDimitry Andric    shift_right(ForwardIterator first, ForwardIterator last,
1392e8d8bef9SDimitry Andric                typename iterator_traits<ForwardIterator>::difference_type n); // C++20
1393e8d8bef9SDimitry Andric
13940b57cec5SDimitry Andrictemplate <class InputIterator, class Predicate>
13950b57cec5SDimitry Andric    constexpr bool  // constexpr in C++20
13960b57cec5SDimitry Andric    is_partitioned(InputIterator first, InputIterator last, Predicate pred);
13970b57cec5SDimitry Andric
13980b57cec5SDimitry Andrictemplate <class ForwardIterator, class Predicate>
1399e8d8bef9SDimitry Andric    constexpr ForwardIterator  // constexpr in C++20
14000b57cec5SDimitry Andric    partition(ForwardIterator first, ForwardIterator last, Predicate pred);
14010b57cec5SDimitry Andric
14020b57cec5SDimitry Andrictemplate <class InputIterator, class OutputIterator1,
14030b57cec5SDimitry Andric          class OutputIterator2, class Predicate>
14040b57cec5SDimitry Andric    constexpr pair<OutputIterator1, OutputIterator2>   // constexpr in C++20
14050b57cec5SDimitry Andric    partition_copy(InputIterator first, InputIterator last,
14060b57cec5SDimitry Andric                   OutputIterator1 out_true, OutputIterator2 out_false,
14070b57cec5SDimitry Andric                   Predicate pred);
14080b57cec5SDimitry Andric
14090b57cec5SDimitry Andrictemplate <class ForwardIterator, class Predicate>
14100b57cec5SDimitry Andric    ForwardIterator
14110b57cec5SDimitry Andric    stable_partition(ForwardIterator first, ForwardIterator last, Predicate pred);
14120b57cec5SDimitry Andric
14130b57cec5SDimitry Andrictemplate<class ForwardIterator, class Predicate>
14140b57cec5SDimitry Andric    constexpr ForwardIterator  // constexpr in C++20
14150b57cec5SDimitry Andric    partition_point(ForwardIterator first, ForwardIterator last, Predicate pred);
14160b57cec5SDimitry Andric
14170b57cec5SDimitry Andrictemplate <class ForwardIterator>
14180b57cec5SDimitry Andric    constexpr bool  // constexpr in C++20
14190b57cec5SDimitry Andric    is_sorted(ForwardIterator first, ForwardIterator last);
14200b57cec5SDimitry Andric
14210b57cec5SDimitry Andrictemplate <class ForwardIterator, class Compare>
1422e8d8bef9SDimitry Andric    constexpr bool  // constexpr in C++20
14230b57cec5SDimitry Andric    is_sorted(ForwardIterator first, ForwardIterator last, Compare comp);
14240b57cec5SDimitry Andric
14250b57cec5SDimitry Andrictemplate<class ForwardIterator>
14260b57cec5SDimitry Andric    constexpr ForwardIterator    // constexpr in C++20
14270b57cec5SDimitry Andric    is_sorted_until(ForwardIterator first, ForwardIterator last);
14280b57cec5SDimitry Andric
14290b57cec5SDimitry Andrictemplate <class ForwardIterator, class Compare>
14300b57cec5SDimitry Andric    constexpr ForwardIterator    // constexpr in C++20
14310b57cec5SDimitry Andric    is_sorted_until(ForwardIterator first, ForwardIterator last, Compare comp);
14320b57cec5SDimitry Andric
14330b57cec5SDimitry Andrictemplate <class RandomAccessIterator>
1434fe6060f1SDimitry Andric    constexpr void               // constexpr in C++20
14350b57cec5SDimitry Andric    sort(RandomAccessIterator first, RandomAccessIterator last);
14360b57cec5SDimitry Andric
14370b57cec5SDimitry Andrictemplate <class RandomAccessIterator, class Compare>
1438fe6060f1SDimitry Andric    constexpr void               // constexpr in C++20
14390b57cec5SDimitry Andric    sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
14400b57cec5SDimitry Andric
14410b57cec5SDimitry Andrictemplate <class RandomAccessIterator>
14420b57cec5SDimitry Andric    void
14430b57cec5SDimitry Andric    stable_sort(RandomAccessIterator first, RandomAccessIterator last);
14440b57cec5SDimitry Andric
14450b57cec5SDimitry Andrictemplate <class RandomAccessIterator, class Compare>
14460b57cec5SDimitry Andric    void
14470b57cec5SDimitry Andric    stable_sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
14480b57cec5SDimitry Andric
14490b57cec5SDimitry Andrictemplate <class RandomAccessIterator>
1450fe6060f1SDimitry Andric    constexpr void                    // constexpr in C++20
14510b57cec5SDimitry Andric    partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last);
14520b57cec5SDimitry Andric
14530b57cec5SDimitry Andrictemplate <class RandomAccessIterator, class Compare>
1454fe6060f1SDimitry Andric    constexpr void                    // constexpr in C++20
14550b57cec5SDimitry Andric    partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last, Compare comp);
14560b57cec5SDimitry Andric
14570b57cec5SDimitry Andrictemplate <class InputIterator, class RandomAccessIterator>
1458fe6060f1SDimitry Andric    constexpr RandomAccessIterator    // constexpr in C++20
14590b57cec5SDimitry Andric    partial_sort_copy(InputIterator first, InputIterator last,
14600b57cec5SDimitry Andric                      RandomAccessIterator result_first, RandomAccessIterator result_last);
14610b57cec5SDimitry Andric
14620b57cec5SDimitry Andrictemplate <class InputIterator, class RandomAccessIterator, class Compare>
1463fe6060f1SDimitry Andric    constexpr RandomAccessIterator    // constexpr in C++20
14640b57cec5SDimitry Andric    partial_sort_copy(InputIterator first, InputIterator last,
14650b57cec5SDimitry Andric                      RandomAccessIterator result_first, RandomAccessIterator result_last, Compare comp);
14660b57cec5SDimitry Andric
14670b57cec5SDimitry Andrictemplate <class RandomAccessIterator>
1468fe6060f1SDimitry Andric    constexpr void                    // constexpr in C++20
14690b57cec5SDimitry Andric    nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last);
14700b57cec5SDimitry Andric
14710b57cec5SDimitry Andrictemplate <class RandomAccessIterator, class Compare>
1472fe6060f1SDimitry Andric    constexpr void                    // constexpr in C++20
14730b57cec5SDimitry Andric    nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last, Compare comp);
14740b57cec5SDimitry Andric
14750b57cec5SDimitry Andrictemplate <class ForwardIterator, class T>
14760b57cec5SDimitry Andric    constexpr ForwardIterator                         // constexpr in C++20
14770b57cec5SDimitry Andric    lower_bound(ForwardIterator first, ForwardIterator last, const T& value);
14780b57cec5SDimitry Andric
14790b57cec5SDimitry Andrictemplate <class ForwardIterator, class T, class Compare>
14800b57cec5SDimitry Andric    constexpr ForwardIterator                         // constexpr in C++20
14810b57cec5SDimitry Andric    lower_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
14820b57cec5SDimitry Andric
14830b57cec5SDimitry Andrictemplate <class ForwardIterator, class T>
14840b57cec5SDimitry Andric    constexpr ForwardIterator                         // constexpr in C++20
14850b57cec5SDimitry Andric    upper_bound(ForwardIterator first, ForwardIterator last, const T& value);
14860b57cec5SDimitry Andric
14870b57cec5SDimitry Andrictemplate <class ForwardIterator, class T, class Compare>
14880b57cec5SDimitry Andric    constexpr ForwardIterator                         // constexpr in C++20
14890b57cec5SDimitry Andric    upper_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
14900b57cec5SDimitry Andric
14910b57cec5SDimitry Andrictemplate <class ForwardIterator, class T>
14920b57cec5SDimitry Andric    constexpr pair<ForwardIterator, ForwardIterator>  // constexpr in C++20
14930b57cec5SDimitry Andric    equal_range(ForwardIterator first, ForwardIterator last, const T& value);
14940b57cec5SDimitry Andric
14950b57cec5SDimitry Andrictemplate <class ForwardIterator, class T, class Compare>
14960b57cec5SDimitry Andric    constexpr pair<ForwardIterator, ForwardIterator>  // constexpr in C++20
14970b57cec5SDimitry Andric    equal_range(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
14980b57cec5SDimitry Andric
14990b57cec5SDimitry Andrictemplate <class ForwardIterator, class T>
15000b57cec5SDimitry Andric    constexpr bool                                    // constexpr in C++20
15010b57cec5SDimitry Andric    binary_search(ForwardIterator first, ForwardIterator last, const T& value);
15020b57cec5SDimitry Andric
15030b57cec5SDimitry Andrictemplate <class ForwardIterator, class T, class Compare>
15040b57cec5SDimitry Andric    constexpr bool                                    // constexpr in C++20
15050b57cec5SDimitry Andric    binary_search(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
15060b57cec5SDimitry Andric
15070b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2, class OutputIterator>
1508e8d8bef9SDimitry Andric    constexpr OutputIterator                          // constexpr in C++20
15090b57cec5SDimitry Andric    merge(InputIterator1 first1, InputIterator1 last1,
15100b57cec5SDimitry Andric          InputIterator2 first2, InputIterator2 last2, OutputIterator result);
15110b57cec5SDimitry Andric
15120b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
1513e8d8bef9SDimitry Andric    constexpr OutputIterator                          // constexpr in C++20
15140b57cec5SDimitry Andric    merge(InputIterator1 first1, InputIterator1 last1,
15150b57cec5SDimitry Andric          InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
15160b57cec5SDimitry Andric
15170b57cec5SDimitry Andrictemplate <class BidirectionalIterator>
15180b57cec5SDimitry Andric    void
15190b57cec5SDimitry Andric    inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last);
15200b57cec5SDimitry Andric
15210b57cec5SDimitry Andrictemplate <class BidirectionalIterator, class Compare>
15220b57cec5SDimitry Andric    void
15230b57cec5SDimitry Andric    inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last, Compare comp);
15240b57cec5SDimitry Andric
15250b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2>
15260b57cec5SDimitry Andric    constexpr bool                                    // constexpr in C++20
15270b57cec5SDimitry Andric    includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
15280b57cec5SDimitry Andric
15290b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2, class Compare>
15300b57cec5SDimitry Andric    constexpr bool                                    // constexpr in C++20
15310b57cec5SDimitry Andric    includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, Compare comp);
15320b57cec5SDimitry Andric
15330b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2, class OutputIterator>
1534e8d8bef9SDimitry Andric    constexpr OutputIterator                          // constexpr in C++20
15350b57cec5SDimitry Andric    set_union(InputIterator1 first1, InputIterator1 last1,
15360b57cec5SDimitry Andric              InputIterator2 first2, InputIterator2 last2, OutputIterator result);
15370b57cec5SDimitry Andric
15380b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
1539e8d8bef9SDimitry Andric    constexpr OutputIterator                          // constexpr in C++20
15400b57cec5SDimitry Andric    set_union(InputIterator1 first1, InputIterator1 last1,
15410b57cec5SDimitry Andric              InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
15420b57cec5SDimitry Andric
15430b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2, class OutputIterator>
15440b57cec5SDimitry Andric    constexpr OutputIterator                         // constexpr in C++20
15450b57cec5SDimitry Andric    set_intersection(InputIterator1 first1, InputIterator1 last1,
15460b57cec5SDimitry Andric                     InputIterator2 first2, InputIterator2 last2, OutputIterator result);
15470b57cec5SDimitry Andric
15480b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
15490b57cec5SDimitry Andric    constexpr OutputIterator                         // constexpr in C++20
15500b57cec5SDimitry Andric    set_intersection(InputIterator1 first1, InputIterator1 last1,
15510b57cec5SDimitry Andric                     InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
15520b57cec5SDimitry Andric
15530b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2, class OutputIterator>
1554e8d8bef9SDimitry Andric    constexpr OutputIterator                         // constexpr in C++20
15550b57cec5SDimitry Andric    set_difference(InputIterator1 first1, InputIterator1 last1,
15560b57cec5SDimitry Andric                   InputIterator2 first2, InputIterator2 last2, OutputIterator result);
15570b57cec5SDimitry Andric
15580b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
1559e8d8bef9SDimitry Andric    constexpr OutputIterator                         // constexpr in C++20
15600b57cec5SDimitry Andric    set_difference(InputIterator1 first1, InputIterator1 last1,
15610b57cec5SDimitry Andric                   InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
15620b57cec5SDimitry Andric
15630b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2, class OutputIterator>
1564e8d8bef9SDimitry Andric    constexpr OutputIterator                         // constexpr in C++20
15650b57cec5SDimitry Andric    set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
15660b57cec5SDimitry Andric                             InputIterator2 first2, InputIterator2 last2, OutputIterator result);
15670b57cec5SDimitry Andric
15680b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
1569e8d8bef9SDimitry Andric    constexpr OutputIterator                         // constexpr in C++20
15700b57cec5SDimitry Andric    set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
15710b57cec5SDimitry Andric                             InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
15720b57cec5SDimitry Andric
15730b57cec5SDimitry Andrictemplate <class RandomAccessIterator>
1574fe6060f1SDimitry Andric    constexpr void                                   // constexpr in C++20
15750b57cec5SDimitry Andric    push_heap(RandomAccessIterator first, RandomAccessIterator last);
15760b57cec5SDimitry Andric
15770b57cec5SDimitry Andrictemplate <class RandomAccessIterator, class Compare>
1578fe6060f1SDimitry Andric    constexpr void                                   // constexpr in C++20
15790b57cec5SDimitry Andric    push_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
15800b57cec5SDimitry Andric
15810b57cec5SDimitry Andrictemplate <class RandomAccessIterator>
1582fe6060f1SDimitry Andric    constexpr void                                   // constexpr in C++20
15830b57cec5SDimitry Andric    pop_heap(RandomAccessIterator first, RandomAccessIterator last);
15840b57cec5SDimitry Andric
15850b57cec5SDimitry Andrictemplate <class RandomAccessIterator, class Compare>
1586fe6060f1SDimitry Andric    constexpr void                                   // constexpr in C++20
15870b57cec5SDimitry Andric    pop_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
15880b57cec5SDimitry Andric
15890b57cec5SDimitry Andrictemplate <class RandomAccessIterator>
1590fe6060f1SDimitry Andric    constexpr void                                   // constexpr in C++20
15910b57cec5SDimitry Andric    make_heap(RandomAccessIterator first, RandomAccessIterator last);
15920b57cec5SDimitry Andric
15930b57cec5SDimitry Andrictemplate <class RandomAccessIterator, class Compare>
1594fe6060f1SDimitry Andric    constexpr void                                   // constexpr in C++20
15950b57cec5SDimitry Andric    make_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
15960b57cec5SDimitry Andric
15970b57cec5SDimitry Andrictemplate <class RandomAccessIterator>
1598fe6060f1SDimitry Andric    constexpr void                                   // constexpr in C++20
15990b57cec5SDimitry Andric    sort_heap(RandomAccessIterator first, RandomAccessIterator last);
16000b57cec5SDimitry Andric
16010b57cec5SDimitry Andrictemplate <class RandomAccessIterator, class Compare>
1602fe6060f1SDimitry Andric    constexpr void                                   // constexpr in C++20
16030b57cec5SDimitry Andric    sort_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
16040b57cec5SDimitry Andric
16050b57cec5SDimitry Andrictemplate <class RandomAccessIterator>
16060b57cec5SDimitry Andric    constexpr bool   // constexpr in C++20
16070b57cec5SDimitry Andric    is_heap(RandomAccessIterator first, RandomAccessiterator last);
16080b57cec5SDimitry Andric
16090b57cec5SDimitry Andrictemplate <class RandomAccessIterator, class Compare>
16100b57cec5SDimitry Andric    constexpr bool   // constexpr in C++20
16110b57cec5SDimitry Andric    is_heap(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
16120b57cec5SDimitry Andric
16130b57cec5SDimitry Andrictemplate <class RandomAccessIterator>
16140b57cec5SDimitry Andric    constexpr RandomAccessIterator   // constexpr in C++20
16150b57cec5SDimitry Andric    is_heap_until(RandomAccessIterator first, RandomAccessiterator last);
16160b57cec5SDimitry Andric
16170b57cec5SDimitry Andrictemplate <class RandomAccessIterator, class Compare>
16180b57cec5SDimitry Andric    constexpr RandomAccessIterator   // constexpr in C++20
16190b57cec5SDimitry Andric    is_heap_until(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
16200b57cec5SDimitry Andric
16210b57cec5SDimitry Andrictemplate <class ForwardIterator>
1622e8d8bef9SDimitry Andric    constexpr ForwardIterator        // constexpr in C++14
1623e8d8bef9SDimitry Andric    min_element(ForwardIterator first, ForwardIterator last);
16240b57cec5SDimitry Andric
16250b57cec5SDimitry Andrictemplate <class ForwardIterator, class Compare>
1626e8d8bef9SDimitry Andric    constexpr ForwardIterator        // constexpr in C++14
1627e8d8bef9SDimitry Andric    min_element(ForwardIterator first, ForwardIterator last, Compare comp);
16280b57cec5SDimitry Andric
16290b57cec5SDimitry Andrictemplate <class T>
1630e8d8bef9SDimitry Andric    constexpr const T&               // constexpr in C++14
1631e8d8bef9SDimitry Andric    min(const T& a, const T& b);
16320b57cec5SDimitry Andric
16330b57cec5SDimitry Andrictemplate <class T, class Compare>
1634e8d8bef9SDimitry Andric    constexpr const T&               // constexpr in C++14
1635e8d8bef9SDimitry Andric    min(const T& a, const T& b, Compare comp);
16360b57cec5SDimitry Andric
16370b57cec5SDimitry Andrictemplate<class T>
1638e8d8bef9SDimitry Andric    constexpr T                      // constexpr in C++14
1639e8d8bef9SDimitry Andric    min(initializer_list<T> t);
16400b57cec5SDimitry Andric
16410b57cec5SDimitry Andrictemplate<class T, class Compare>
1642e8d8bef9SDimitry Andric    constexpr T                      // constexpr in C++14
1643e8d8bef9SDimitry Andric    min(initializer_list<T> t, Compare comp);
16440b57cec5SDimitry Andric
16450b57cec5SDimitry Andrictemplate<class T>
16460b57cec5SDimitry Andric    constexpr const T& clamp(const T& v, const T& lo, const T& hi);               // C++17
16470b57cec5SDimitry Andric
16480b57cec5SDimitry Andrictemplate<class T, class Compare>
16490b57cec5SDimitry Andric    constexpr const T& clamp(const T& v, const T& lo, const T& hi, Compare comp); // C++17
16500b57cec5SDimitry Andric
16510b57cec5SDimitry Andrictemplate <class ForwardIterator>
1652e8d8bef9SDimitry Andric    constexpr ForwardIterator        // constexpr in C++14
1653e8d8bef9SDimitry Andric    max_element(ForwardIterator first, ForwardIterator last);
16540b57cec5SDimitry Andric
16550b57cec5SDimitry Andrictemplate <class ForwardIterator, class Compare>
1656e8d8bef9SDimitry Andric    constexpr ForwardIterator        // constexpr in C++14
1657e8d8bef9SDimitry Andric    max_element(ForwardIterator first, ForwardIterator last, Compare comp);
16580b57cec5SDimitry Andric
16590b57cec5SDimitry Andrictemplate <class T>
1660e8d8bef9SDimitry Andric    constexpr const T&               // constexpr in C++14
1661e8d8bef9SDimitry Andric    max(const T& a, const T& b);
16620b57cec5SDimitry Andric
16630b57cec5SDimitry Andrictemplate <class T, class Compare>
1664e8d8bef9SDimitry Andric    constexpr const T&               // constexpr in C++14
1665e8d8bef9SDimitry Andric    max(const T& a, const T& b, Compare comp);
16660b57cec5SDimitry Andric
16670b57cec5SDimitry Andrictemplate<class T>
1668e8d8bef9SDimitry Andric    constexpr T                      // constexpr in C++14
1669e8d8bef9SDimitry Andric    max(initializer_list<T> t);
16700b57cec5SDimitry Andric
16710b57cec5SDimitry Andrictemplate<class T, class Compare>
1672e8d8bef9SDimitry Andric    constexpr T                      // constexpr in C++14
1673e8d8bef9SDimitry Andric    max(initializer_list<T> t, Compare comp);
16740b57cec5SDimitry Andric
16750b57cec5SDimitry Andrictemplate<class ForwardIterator>
1676e8d8bef9SDimitry Andric    constexpr pair<ForwardIterator, ForwardIterator>  // constexpr in C++14
1677e8d8bef9SDimitry Andric    minmax_element(ForwardIterator first, ForwardIterator last);
16780b57cec5SDimitry Andric
16790b57cec5SDimitry Andrictemplate<class ForwardIterator, class Compare>
1680e8d8bef9SDimitry Andric    constexpr pair<ForwardIterator, ForwardIterator>  // constexpr in C++14
1681e8d8bef9SDimitry Andric    minmax_element(ForwardIterator first, ForwardIterator last, Compare comp);
16820b57cec5SDimitry Andric
16830b57cec5SDimitry Andrictemplate<class T>
1684e8d8bef9SDimitry Andric    constexpr pair<const T&, const T&>  // constexpr in C++14
1685e8d8bef9SDimitry Andric    minmax(const T& a, const T& b);
16860b57cec5SDimitry Andric
16870b57cec5SDimitry Andrictemplate<class T, class Compare>
1688e8d8bef9SDimitry Andric    constexpr pair<const T&, const T&>  // constexpr in C++14
1689e8d8bef9SDimitry Andric    minmax(const T& a, const T& b, Compare comp);
16900b57cec5SDimitry Andric
16910b57cec5SDimitry Andrictemplate<class T>
1692e8d8bef9SDimitry Andric    constexpr pair<T, T>                // constexpr in C++14
1693e8d8bef9SDimitry Andric    minmax(initializer_list<T> t);
16940b57cec5SDimitry Andric
16950b57cec5SDimitry Andrictemplate<class T, class Compare>
1696e8d8bef9SDimitry Andric    constexpr pair<T, T>                // constexpr in C++14
1697e8d8bef9SDimitry Andric    minmax(initializer_list<T> t, Compare comp);
16980b57cec5SDimitry Andric
16990b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2>
17000b57cec5SDimitry Andric    constexpr bool     // constexpr in C++20
17010b57cec5SDimitry Andric    lexicographical_compare(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
17020b57cec5SDimitry Andric
17030b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2, class Compare>
17040b57cec5SDimitry Andric    constexpr bool     // constexpr in C++20
17050b57cec5SDimitry Andric    lexicographical_compare(InputIterator1 first1, InputIterator1 last1,
17060b57cec5SDimitry Andric                            InputIterator2 first2, InputIterator2 last2, Compare comp);
17070b57cec5SDimitry Andric
1708*06c3fb27SDimitry Andrictemplate<class InputIterator1, class InputIterator2, class Cmp>
1709*06c3fb27SDimitry Andric    constexpr auto
1710*06c3fb27SDimitry Andric    lexicographical_compare_three_way(InputIterator1 first1, InputIterator1 last1,
1711*06c3fb27SDimitry Andric                                      InputIterator2 first2, InputIterator2 last2,
1712*06c3fb27SDimitry Andric                                      Cmp comp)
1713*06c3fb27SDimitry Andric      -> decltype(comp(*b1, *b2));                                                        // since C++20
1714*06c3fb27SDimitry Andric
1715*06c3fb27SDimitry Andrictemplate<class InputIterator1, class InputIterator2>
1716*06c3fb27SDimitry Andric    constexpr auto
1717*06c3fb27SDimitry Andric    lexicographical_compare_three_way(InputIterator1 first1, InputIterator1 last1,
1718*06c3fb27SDimitry Andric                                      InputIterator2 first2, InputIterator2 last2);      // since C++20
1719*06c3fb27SDimitry Andric
17200b57cec5SDimitry Andrictemplate <class BidirectionalIterator>
1721e8d8bef9SDimitry Andric    constexpr bool     // constexpr in C++20
17220b57cec5SDimitry Andric    next_permutation(BidirectionalIterator first, BidirectionalIterator last);
17230b57cec5SDimitry Andric
17240b57cec5SDimitry Andrictemplate <class BidirectionalIterator, class Compare>
1725e8d8bef9SDimitry Andric    constexpr bool     // constexpr in C++20
17260b57cec5SDimitry Andric    next_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
17270b57cec5SDimitry Andric
17280b57cec5SDimitry Andrictemplate <class BidirectionalIterator>
1729e8d8bef9SDimitry Andric    constexpr bool     // constexpr in C++20
17300b57cec5SDimitry Andric    prev_permutation(BidirectionalIterator first, BidirectionalIterator last);
17310b57cec5SDimitry Andric
17320b57cec5SDimitry Andrictemplate <class BidirectionalIterator, class Compare>
1733e8d8bef9SDimitry Andric    constexpr bool     // constexpr in C++20
17340b57cec5SDimitry Andric    prev_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
17350b57cec5SDimitry Andric}  // std
17360b57cec5SDimitry Andric
17370b57cec5SDimitry Andric*/
17380b57cec5SDimitry Andric
173981ad6265SDimitry Andric#include <__assert> // all public C++ headers provide the assertion handler
17400b57cec5SDimitry Andric#include <__config>
1741fe6060f1SDimitry Andric#include <cstddef>
17420b57cec5SDimitry Andric#include <version>
17430b57cec5SDimitry Andric
1744fe6060f1SDimitry Andric#include <__algorithm/adjacent_find.h>
1745fe6060f1SDimitry Andric#include <__algorithm/all_of.h>
1746fe6060f1SDimitry Andric#include <__algorithm/any_of.h>
1747fe6060f1SDimitry Andric#include <__algorithm/binary_search.h>
1748fe6060f1SDimitry Andric#include <__algorithm/clamp.h>
1749fe6060f1SDimitry Andric#include <__algorithm/comp.h>
1750fe6060f1SDimitry Andric#include <__algorithm/comp_ref_type.h>
1751fe6060f1SDimitry Andric#include <__algorithm/copy.h>
1752fe6060f1SDimitry Andric#include <__algorithm/copy_backward.h>
1753fe6060f1SDimitry Andric#include <__algorithm/copy_if.h>
1754fe6060f1SDimitry Andric#include <__algorithm/copy_n.h>
1755fe6060f1SDimitry Andric#include <__algorithm/count.h>
1756fe6060f1SDimitry Andric#include <__algorithm/count_if.h>
1757fe6060f1SDimitry Andric#include <__algorithm/equal.h>
1758fe6060f1SDimitry Andric#include <__algorithm/equal_range.h>
1759fe6060f1SDimitry Andric#include <__algorithm/fill.h>
176004eeddc0SDimitry Andric#include <__algorithm/fill_n.h>
1761fe6060f1SDimitry Andric#include <__algorithm/find.h>
1762fe6060f1SDimitry Andric#include <__algorithm/find_end.h>
1763fe6060f1SDimitry Andric#include <__algorithm/find_first_of.h>
1764fe6060f1SDimitry Andric#include <__algorithm/find_if.h>
1765fe6060f1SDimitry Andric#include <__algorithm/find_if_not.h>
1766fe6060f1SDimitry Andric#include <__algorithm/for_each.h>
1767fe6060f1SDimitry Andric#include <__algorithm/for_each_n.h>
1768fe6060f1SDimitry Andric#include <__algorithm/generate.h>
176904eeddc0SDimitry Andric#include <__algorithm/generate_n.h>
1770fe6060f1SDimitry Andric#include <__algorithm/half_positive.h>
177181ad6265SDimitry Andric#include <__algorithm/in_found_result.h>
177281ad6265SDimitry Andric#include <__algorithm/in_fun_result.h>
17731fd87a68SDimitry Andric#include <__algorithm/in_in_out_result.h>
177404eeddc0SDimitry Andric#include <__algorithm/in_in_result.h>
177581ad6265SDimitry Andric#include <__algorithm/in_out_out_result.h>
177604eeddc0SDimitry Andric#include <__algorithm/in_out_result.h>
1777fe6060f1SDimitry Andric#include <__algorithm/includes.h>
1778fe6060f1SDimitry Andric#include <__algorithm/inplace_merge.h>
1779fe6060f1SDimitry Andric#include <__algorithm/is_heap.h>
1780fe6060f1SDimitry Andric#include <__algorithm/is_heap_until.h>
1781fe6060f1SDimitry Andric#include <__algorithm/is_partitioned.h>
1782fe6060f1SDimitry Andric#include <__algorithm/is_permutation.h>
1783fe6060f1SDimitry Andric#include <__algorithm/is_sorted.h>
1784fe6060f1SDimitry Andric#include <__algorithm/is_sorted_until.h>
1785fe6060f1SDimitry Andric#include <__algorithm/iter_swap.h>
1786fe6060f1SDimitry Andric#include <__algorithm/lexicographical_compare.h>
1787*06c3fb27SDimitry Andric#include <__algorithm/lexicographical_compare_three_way.h>
1788fe6060f1SDimitry Andric#include <__algorithm/lower_bound.h>
1789fe6060f1SDimitry Andric#include <__algorithm/make_heap.h>
1790fe6060f1SDimitry Andric#include <__algorithm/max.h>
1791fe6060f1SDimitry Andric#include <__algorithm/max_element.h>
1792fe6060f1SDimitry Andric#include <__algorithm/merge.h>
1793fe6060f1SDimitry Andric#include <__algorithm/min.h>
1794fe6060f1SDimitry Andric#include <__algorithm/min_element.h>
179581ad6265SDimitry Andric#include <__algorithm/min_max_result.h>
1796fe6060f1SDimitry Andric#include <__algorithm/minmax.h>
1797fe6060f1SDimitry Andric#include <__algorithm/minmax_element.h>
1798fe6060f1SDimitry Andric#include <__algorithm/mismatch.h>
1799fe6060f1SDimitry Andric#include <__algorithm/move.h>
1800fe6060f1SDimitry Andric#include <__algorithm/move_backward.h>
1801fe6060f1SDimitry Andric#include <__algorithm/next_permutation.h>
1802fe6060f1SDimitry Andric#include <__algorithm/none_of.h>
1803fe6060f1SDimitry Andric#include <__algorithm/nth_element.h>
1804fe6060f1SDimitry Andric#include <__algorithm/partial_sort.h>
1805fe6060f1SDimitry Andric#include <__algorithm/partial_sort_copy.h>
1806fe6060f1SDimitry Andric#include <__algorithm/partition.h>
1807fe6060f1SDimitry Andric#include <__algorithm/partition_copy.h>
1808fe6060f1SDimitry Andric#include <__algorithm/partition_point.h>
1809fe6060f1SDimitry Andric#include <__algorithm/pop_heap.h>
1810fe6060f1SDimitry Andric#include <__algorithm/prev_permutation.h>
1811*06c3fb27SDimitry Andric#include <__algorithm/pstl_any_all_none_of.h>
1812*06c3fb27SDimitry Andric#include <__algorithm/pstl_copy.h>
1813*06c3fb27SDimitry Andric#include <__algorithm/pstl_count.h>
1814*06c3fb27SDimitry Andric#include <__algorithm/pstl_fill.h>
1815*06c3fb27SDimitry Andric#include <__algorithm/pstl_find.h>
1816*06c3fb27SDimitry Andric#include <__algorithm/pstl_for_each.h>
1817*06c3fb27SDimitry Andric#include <__algorithm/pstl_generate.h>
1818*06c3fb27SDimitry Andric#include <__algorithm/pstl_is_partitioned.h>
1819*06c3fb27SDimitry Andric#include <__algorithm/pstl_merge.h>
1820*06c3fb27SDimitry Andric#include <__algorithm/pstl_replace.h>
1821*06c3fb27SDimitry Andric#include <__algorithm/pstl_sort.h>
1822*06c3fb27SDimitry Andric#include <__algorithm/pstl_stable_sort.h>
1823*06c3fb27SDimitry Andric#include <__algorithm/pstl_transform.h>
1824fe6060f1SDimitry Andric#include <__algorithm/push_heap.h>
182581ad6265SDimitry Andric#include <__algorithm/ranges_adjacent_find.h>
182681ad6265SDimitry Andric#include <__algorithm/ranges_all_of.h>
182781ad6265SDimitry Andric#include <__algorithm/ranges_any_of.h>
182881ad6265SDimitry Andric#include <__algorithm/ranges_binary_search.h>
182961cfbce3SDimitry Andric#include <__algorithm/ranges_clamp.h>
183081ad6265SDimitry Andric#include <__algorithm/ranges_copy.h>
183181ad6265SDimitry Andric#include <__algorithm/ranges_copy_backward.h>
183281ad6265SDimitry Andric#include <__algorithm/ranges_copy_if.h>
183381ad6265SDimitry Andric#include <__algorithm/ranges_copy_n.h>
183481ad6265SDimitry Andric#include <__algorithm/ranges_count.h>
183581ad6265SDimitry Andric#include <__algorithm/ranges_count_if.h>
183681ad6265SDimitry Andric#include <__algorithm/ranges_equal.h>
1837fcaf7f86SDimitry Andric#include <__algorithm/ranges_equal_range.h>
183881ad6265SDimitry Andric#include <__algorithm/ranges_fill.h>
183981ad6265SDimitry Andric#include <__algorithm/ranges_fill_n.h>
184081ad6265SDimitry Andric#include <__algorithm/ranges_find.h>
1841753f127fSDimitry Andric#include <__algorithm/ranges_find_end.h>
184281ad6265SDimitry Andric#include <__algorithm/ranges_find_first_of.h>
184381ad6265SDimitry Andric#include <__algorithm/ranges_find_if.h>
184481ad6265SDimitry Andric#include <__algorithm/ranges_find_if_not.h>
184581ad6265SDimitry Andric#include <__algorithm/ranges_for_each.h>
184681ad6265SDimitry Andric#include <__algorithm/ranges_for_each_n.h>
1847972a253aSDimitry Andric#include <__algorithm/ranges_generate.h>
1848972a253aSDimitry Andric#include <__algorithm/ranges_generate_n.h>
1849fcaf7f86SDimitry Andric#include <__algorithm/ranges_includes.h>
185061cfbce3SDimitry Andric#include <__algorithm/ranges_inplace_merge.h>
1851972a253aSDimitry Andric#include <__algorithm/ranges_is_heap.h>
1852972a253aSDimitry Andric#include <__algorithm/ranges_is_heap_until.h>
185381ad6265SDimitry Andric#include <__algorithm/ranges_is_partitioned.h>
185461cfbce3SDimitry Andric#include <__algorithm/ranges_is_permutation.h>
185581ad6265SDimitry Andric#include <__algorithm/ranges_is_sorted.h>
185681ad6265SDimitry Andric#include <__algorithm/ranges_is_sorted_until.h>
185781ad6265SDimitry Andric#include <__algorithm/ranges_lexicographical_compare.h>
185881ad6265SDimitry Andric#include <__algorithm/ranges_lower_bound.h>
1859753f127fSDimitry Andric#include <__algorithm/ranges_make_heap.h>
186081ad6265SDimitry Andric#include <__algorithm/ranges_max.h>
186181ad6265SDimitry Andric#include <__algorithm/ranges_max_element.h>
1862753f127fSDimitry Andric#include <__algorithm/ranges_merge.h>
186381ad6265SDimitry Andric#include <__algorithm/ranges_min.h>
186481ad6265SDimitry Andric#include <__algorithm/ranges_min_element.h>
186581ad6265SDimitry Andric#include <__algorithm/ranges_minmax.h>
186681ad6265SDimitry Andric#include <__algorithm/ranges_minmax_element.h>
186781ad6265SDimitry Andric#include <__algorithm/ranges_mismatch.h>
186881ad6265SDimitry Andric#include <__algorithm/ranges_move.h>
186981ad6265SDimitry Andric#include <__algorithm/ranges_move_backward.h>
187061cfbce3SDimitry Andric#include <__algorithm/ranges_next_permutation.h>
187181ad6265SDimitry Andric#include <__algorithm/ranges_none_of.h>
1872753f127fSDimitry Andric#include <__algorithm/ranges_nth_element.h>
1873fcaf7f86SDimitry Andric#include <__algorithm/ranges_partial_sort.h>
187461cfbce3SDimitry Andric#include <__algorithm/ranges_partial_sort_copy.h>
1875fcaf7f86SDimitry Andric#include <__algorithm/ranges_partition.h>
1876fcaf7f86SDimitry Andric#include <__algorithm/ranges_partition_copy.h>
1877fcaf7f86SDimitry Andric#include <__algorithm/ranges_partition_point.h>
1878753f127fSDimitry Andric#include <__algorithm/ranges_pop_heap.h>
187961cfbce3SDimitry Andric#include <__algorithm/ranges_prev_permutation.h>
1880753f127fSDimitry Andric#include <__algorithm/ranges_push_heap.h>
1881753f127fSDimitry Andric#include <__algorithm/ranges_remove.h>
188261cfbce3SDimitry Andric#include <__algorithm/ranges_remove_copy.h>
188361cfbce3SDimitry Andric#include <__algorithm/ranges_remove_copy_if.h>
1884753f127fSDimitry Andric#include <__algorithm/ranges_remove_if.h>
188581ad6265SDimitry Andric#include <__algorithm/ranges_replace.h>
188661cfbce3SDimitry Andric#include <__algorithm/ranges_replace_copy.h>
188761cfbce3SDimitry Andric#include <__algorithm/ranges_replace_copy_if.h>
188881ad6265SDimitry Andric#include <__algorithm/ranges_replace_if.h>
188981ad6265SDimitry Andric#include <__algorithm/ranges_reverse.h>
1890753f127fSDimitry Andric#include <__algorithm/ranges_reverse_copy.h>
189161cfbce3SDimitry Andric#include <__algorithm/ranges_rotate.h>
1892753f127fSDimitry Andric#include <__algorithm/ranges_rotate_copy.h>
189361cfbce3SDimitry Andric#include <__algorithm/ranges_sample.h>
1894753f127fSDimitry Andric#include <__algorithm/ranges_search.h>
1895753f127fSDimitry Andric#include <__algorithm/ranges_search_n.h>
1896753f127fSDimitry Andric#include <__algorithm/ranges_set_difference.h>
1897753f127fSDimitry Andric#include <__algorithm/ranges_set_intersection.h>
1898753f127fSDimitry Andric#include <__algorithm/ranges_set_symmetric_difference.h>
1899fcaf7f86SDimitry Andric#include <__algorithm/ranges_set_union.h>
1900fcaf7f86SDimitry Andric#include <__algorithm/ranges_shuffle.h>
190181ad6265SDimitry Andric#include <__algorithm/ranges_sort.h>
1902753f127fSDimitry Andric#include <__algorithm/ranges_sort_heap.h>
1903fcaf7f86SDimitry Andric#include <__algorithm/ranges_stable_partition.h>
190481ad6265SDimitry Andric#include <__algorithm/ranges_stable_sort.h>
1905*06c3fb27SDimitry Andric#include <__algorithm/ranges_starts_with.h>
190681ad6265SDimitry Andric#include <__algorithm/ranges_swap_ranges.h>
190781ad6265SDimitry Andric#include <__algorithm/ranges_transform.h>
190861cfbce3SDimitry Andric#include <__algorithm/ranges_unique.h>
190961cfbce3SDimitry Andric#include <__algorithm/ranges_unique_copy.h>
191081ad6265SDimitry Andric#include <__algorithm/ranges_upper_bound.h>
1911fe6060f1SDimitry Andric#include <__algorithm/remove.h>
1912fe6060f1SDimitry Andric#include <__algorithm/remove_copy.h>
1913fe6060f1SDimitry Andric#include <__algorithm/remove_copy_if.h>
1914fe6060f1SDimitry Andric#include <__algorithm/remove_if.h>
1915fe6060f1SDimitry Andric#include <__algorithm/replace.h>
1916fe6060f1SDimitry Andric#include <__algorithm/replace_copy.h>
1917fe6060f1SDimitry Andric#include <__algorithm/replace_copy_if.h>
1918fe6060f1SDimitry Andric#include <__algorithm/replace_if.h>
1919fe6060f1SDimitry Andric#include <__algorithm/reverse.h>
1920fe6060f1SDimitry Andric#include <__algorithm/reverse_copy.h>
1921fe6060f1SDimitry Andric#include <__algorithm/rotate.h>
1922fe6060f1SDimitry Andric#include <__algorithm/rotate_copy.h>
1923fe6060f1SDimitry Andric#include <__algorithm/sample.h>
1924fe6060f1SDimitry Andric#include <__algorithm/search.h>
1925fe6060f1SDimitry Andric#include <__algorithm/search_n.h>
1926fe6060f1SDimitry Andric#include <__algorithm/set_difference.h>
1927fe6060f1SDimitry Andric#include <__algorithm/set_intersection.h>
1928fe6060f1SDimitry Andric#include <__algorithm/set_symmetric_difference.h>
1929fe6060f1SDimitry Andric#include <__algorithm/set_union.h>
1930fe6060f1SDimitry Andric#include <__algorithm/shift_left.h>
1931fe6060f1SDimitry Andric#include <__algorithm/shift_right.h>
1932fe6060f1SDimitry Andric#include <__algorithm/shuffle.h>
1933fe6060f1SDimitry Andric#include <__algorithm/sift_down.h>
1934fe6060f1SDimitry Andric#include <__algorithm/sort.h>
1935fe6060f1SDimitry Andric#include <__algorithm/sort_heap.h>
1936fe6060f1SDimitry Andric#include <__algorithm/stable_partition.h>
1937fe6060f1SDimitry Andric#include <__algorithm/stable_sort.h>
1938fe6060f1SDimitry Andric#include <__algorithm/swap_ranges.h>
1939fe6060f1SDimitry Andric#include <__algorithm/transform.h>
1940fe6060f1SDimitry Andric#include <__algorithm/unique.h>
194104eeddc0SDimitry Andric#include <__algorithm/unique_copy.h>
1942fe6060f1SDimitry Andric#include <__algorithm/unwrap_iter.h>
1943fe6060f1SDimitry Andric#include <__algorithm/upper_bound.h>
19440b57cec5SDimitry Andric
194581ad6265SDimitry Andric// standard-mandated includes
1946bdd1243dSDimitry Andric
1947bdd1243dSDimitry Andric// [algorithm.syn]
194881ad6265SDimitry Andric#include <initializer_list>
194981ad6265SDimitry Andric
19500b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19510b57cec5SDimitry Andric#  pragma GCC system_header
19520b57cec5SDimitry Andric#endif
19530b57cec5SDimitry Andric
1954bdd1243dSDimitry Andric#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1955bdd1243dSDimitry Andric#  include <atomic>
1956*06c3fb27SDimitry Andric#  include <bit>
1957bdd1243dSDimitry Andric#  include <concepts>
1958*06c3fb27SDimitry Andric#  include <cstdlib>
1959bdd1243dSDimitry Andric#  include <cstring>
1960bdd1243dSDimitry Andric#  include <iterator>
1961bdd1243dSDimitry Andric#  include <memory>
1962bdd1243dSDimitry Andric#  include <stdexcept>
1963*06c3fb27SDimitry Andric#  include <type_traits>
1964bdd1243dSDimitry Andric#  include <utility>
1965bdd1243dSDimitry Andric#endif
1966bdd1243dSDimitry Andric
19670b57cec5SDimitry Andric#endif // _LIBCPP_ALGORITHM
1968