Standard library header <algorithm>

This header is part of the algorithm library.

Functions

Non-modifying sequence operations
(C++11)(C++11)(C++11)
checks if a predicate is true for all, any or none of the elements in a range
(function template)
applies a function to a range of elements
(function template)
(C++17)
applies a function object to the first n elements of a sequence
(function template)
returns the number of elements satisfying specific criteria
(function template)
finds the first position where two ranges differ
(function template)
(C++11)
finds the first element satisfying specific criteria
(function template)
finds the last sequence of elements in a certain range
(function template)
searches for any one of a set of elements
(function template)
finds the first two adjacent items that are equal (or satisfy a given predicate)
(function template)
searches for a range of elements
(function template)
searches a range for a number of consecutive copies of an element
(function template)
Modifying sequence operations
(C++11)
copies a range of elements to a new location
(function template)
(C++11)
copies a number of elements to a new location
(function template)
copies a range of elements in backwards order
(function template)
(C++11)
moves a range of elements to a new location
(function template)
(C++11)
moves a range of elements to a new location in backwards order
(function template)
copy-assigns the given value to every element in a range
(function template)
copy-assigns the given value to N elements in a range
(function template)
applies a function to a range of elements
(function template)
assigns the results of successive function calls to every element in a range
(function template)
assigns the results of successive function calls to N elements in a range
(function template)
removes elements satisfying specific criteria
(function template)
copies a range of elements omitting those that satisfy specific criteria
(function template)
replaces all values satisfying specific criteria with another value
(function template)
copies a range, replacing elements satisfying specific criteria with another value
(function template)
swaps the values of two objects
(function template)
swaps two ranges of elements
(function template)
swaps the elements pointed to by two iterators
(function template)
reverses the order of elements in a range
(function template)
creates a copy of a range that is reversed
(function template)
rotates the order of elements in a range
(function template)
copies and rotate a range of elements
(function template)
(C++20)
shifts elements in a range
(function template)
(until C++17)(C++11)
randomly re-orders elements in a range
(function template)
(C++17)
selects n random elements from a sequence
(function template)
removes consecutive duplicate elements in a range
(function template)
creates a copy of some range of elements that contains no consecutive duplicates
(function template)
Partitioning operations
(C++11)
determines if the range is partitioned by the given predicate
(function template)
divides a range of elements into two groups
(function template)
(C++11)
copies a range dividing the elements into two groups
(function template)
divides elements into two groups while preserving their relative order
(function template)
(C++11)
locates the partition point of a partitioned range
(function template)
Sorting operations
(C++11)
checks whether a range is sorted into ascending order
(function template)
(C++11)
finds the largest sorted subrange
(function template)
sorts a range into ascending order
(function template)
sorts the first N elements of a range
(function template)
copies and partially sorts a range of elements
(function template)
sorts a range of elements while preserving order between equal elements
(function template)
partially sorts the given range making sure that it is partitioned by the given element
(function template)
Binary search operations (on sorted ranges)
returns an iterator to the first element not less than the given value
(function template)
returns an iterator to the first element greater than a certain value
(function template)
determines if an element exists in a certain range
(function template)
returns range of elements matching a specific key
(function template)
Other operations on sorted ranges
merges two sorted ranges
(function template)
merges two ordered ranges in-place
(function template)
Set operations (on sorted ranges)
returns true if one set is a subset of another
(function template)
computes the difference between two sets
(function template)
computes the intersection of two sets
(function template)
computes the symmetric difference between two sets
(function template)
computes the union of two sets
(function template)
Heap operations
(C++11)
checks if the given range is a max heap
(function template)
(C++11)
finds the largest subrange that is a max heap
(function template)
creates a max heap out of a range of elements
(function template)
adds an element to a max heap
(function template)
removes the largest element from a max heap
(function template)
turns a max heap into a range of elements sorted in ascending order
(function template)
Minimum/maximum operations
returns the greater of the given values
(function template)
returns the largest element in a range
(function template)
returns the smaller of the given values
(function template)
returns the smallest element in a range
(function template)
(C++11)
returns the smaller and larger of two elements
(function template)
(C++11)
returns the smallest and the largest elements in a range
(function template)
(C++17)
clamps a value between a pair of boundary values
(function template)
Comparison operations
determines if two sets of elements are the same
(function template)
returns true if one range is lexicographically less than another
(function template)
(C++20)
compares two values using three-way comparison
(function template)
(C++20)
compares two ranges using three-way comparison
(function template)
Permutation operations
(C++11)
determines if a sequence is a permutation of another sequence
(function template)
generates the next greater lexicographic permutation of a range of elements
(function template)
generates the next smaller lexicographic permutation of a range of elements
(function template)

Niebloids

Defined in namespace std::ranges
Non-modifying sequence operations
checks if a predicate is true for all, any or none of the elements in a range
(niebloid)
applies a function to a range of elements
(niebloid)
returns the number of elements satisfying specific criteria
(niebloid)
finds the first position where two ranges differ
(niebloid)
finds the first element satisfying specific criteria
(niebloid)
finds the last sequence of elements in a certain range
(niebloid)
searches for any one of a set of elements
(niebloid)
finds the first two adjacent items that are equal (or satisfy a given predicate)
(niebloid)
searches for a range of elements
(niebloid)
searches for a number consecutive copies of an element in a range
(niebloid)
Modifying sequence operations
copies a range of elements to a new location
(niebloid)
copies a number of elements to a new location
(niebloid)
copies a range of elements in backwards order
(niebloid)
moves a range of elements to a new location
(niebloid)
moves a range of elements to a new location in backwards order
(niebloid)
assigns a range of elements a certain value
(niebloid)
assigns a value to a number of elements
(niebloid)
applies a function to a range of elements
(niebloid)
saves the result of a function in a range
(niebloid)
saves the result of N applications of a function
(niebloid)
removes elements satisfying specific criteria
(niebloid)
copies a range of elements omitting those that satisfy specific criteria
(niebloid)
replaces all values satisfying specific criteria with another value
(niebloid)
copies a range, replacing elements satisfying specific criteria with another value
(niebloid)
swaps two ranges of elements
(niebloid)
reverses the order of elements in a range
(niebloid)
creates a copy of a range that is reversed
(niebloid)
rotates the order of elements in a range
(niebloid)
copies and rotate a range of elements
(niebloid)
randomly re-orders elements in a range
(niebloid)
removes consecutive duplicate elements in a range
(niebloid)
creates a copy of some range of elements that contains no consecutive duplicates
(niebloid)
Partitioning operations
determines if the range is partitioned by the given predicate
(niebloid)
divides a range of elements into two groups
(niebloid)
copies a range dividing the elements into two groups
(niebloid)
divides elements into two groups while preserving their relative order
(niebloid)
locates the partition point of a partitioned range
(niebloid)
Sorting operations
checks whether a range is sorted into ascending order
(niebloid)
finds the largest sorted subrange
(niebloid)
sorts a range into ascending order
(niebloid)
sorts the first N elements of a range
(niebloid)
copies and partially sorts a range of elements
(niebloid)
sorts a range of elements while preserving order between equal elements
(niebloid)
partially sorts the given range making sure that it is partitioned by the given element
(niebloid)
Binary search operations (on sorted ranges)
returns an iterator to the first element not less than the given value
(niebloid)
returns an iterator to the first element greater than a certain value
(niebloid)
determines if an element exists in a certain range
(niebloid)
returns range of elements matching a specific key
(niebloid)
Other operations on sorted ranges
merges two sorted ranges
(niebloid)
merges two ordered ranges in-place
(niebloid)
Set operations (on sorted ranges)
returns true if one set is a subset of another
(niebloid)
computes the difference between two sets
(niebloid)
computes the intersection of two sets
(niebloid)
computes the symmetric difference between two sets
(niebloid)
computes the union of two sets
(niebloid)
Heap operations
checks if the given range is a max heap
(niebloid)
finds the largest subrange that is a max heap
(niebloid)
creates a max heap out of a range of elements
(niebloid)
adds an element to a max heap
(niebloid)
removes the largest element from a max heap
(niebloid)
turns a max heap into a range of elements sorted in ascending order
(niebloid)
Minimum/maximum operations
returns the greater of the given values
(niebloid)
returns the largest element in a range
(niebloid)
returns the smaller of the given values
(niebloid)
returns the smallest element in a range
(niebloid)
returns the smaller and larger of two elements
(niebloid)
returns the smallest and the largest elements in a range
(niebloid)
Comparison operations
determines if two sets of elements are the same
(niebloid)
returns true if one range is lexicographically less than another
(niebloid)
Permutation operations
determines if a sequence is a permutation of another sequence
(niebloid)
generates the next greater lexicographic permutation of a range of elements
(niebloid)
generates the next smaller lexicographic permutation of a range of elements
(niebloid)

Synopsis

#include <initializer_list>
 
namespace std {
  // non-modifying sequence operations:
  // all of:
  template<class InputIt, class Pred>
    constexpr bool all_of(InputIt first, InputIt last, Pred pred);
  template<class ExecutionPolicy, class ForwardIt, class Pred>
    bool all_of(ExecutionPolicy&& exec,
                ForwardIt first, ForwardIt last, Pred pred);
 
  namespace ranges {
    template<InputIterator I, Sentinel<I> S, class Proj = identity,
             IndirectUnaryPredicate<projected<I, Proj>> Pred>
      constexpr bool all_of(I first, S last, Pred pred, Proj proj = {});
    template<InputRange R, class Proj = identity,
             IndirectUnaryPredicate<projected<iterator_t<R>, Proj>> Pred>
      constexpr bool all_of(R&& r, Pred pred, Proj proj = {});
  }
 
  // any of:
  template<class InputIt, class Pred>
    constexpr bool any_of(InputIt first, InputIt last, Pred pred);
  template<class ExecutionPolicy, class ForwardIt, class Pred>
    bool any_of(ExecutionPolicy&& exec,
                ForwardIt first, ForwardIt last, Pred pred);
 
  namespace ranges {
    template<InputIterator I, Sentinel<I> S, class Proj = identity,
             IndirectUnaryPredicate<projected<I, Proj>> Pred>
      constexpr bool any_of(I first, S last, Pred pred, Proj proj = {});
    template<InputRange R, class Proj = identity,
             IndirectUnaryPredicate<projected<iterator_t<R>, Proj>> Pred>
      constexpr bool any_of(R&& r, Pred pred, Proj proj = {});
  }
 
  // none of:
  template<class InputIt, class Pred>
    constexpr bool none_of(InputIt first, InputIt last, Pred pred);
  template<class ExecutionPolicy, class ForwardIt, class Pred>
    bool none_of(ExecutionPolicy&& exec,
                 ForwardIt first, ForwardIt last, Pred pred);
 
  namespace ranges {
    template<InputIterator I, Sentinel<I> S, class Proj = identity,
             IndirectUnaryPredicate<projected<I, Proj>> Pred>
      constexpr bool none_of(I first, S last, Pred pred, Proj proj = {});
    template<InputRange R, class Proj = identity,
             IndirectUnaryPredicate<projected<iterator_t<R>, Proj>> Pred>
      constexpr bool none_of(R&& r, Pred pred, Proj proj = {});
  }
 
  // for each:
  template<class InputIt, class Function>
    constexpr Function for_each(InputIt first, InputIt last, Function f);
  template<class ExecutionPolicy, class ForwardIt, class Function>
    void for_each(ExecutionPolicy&& exec,
                  ForwardIt first, ForwardIt last, Function f);
 
  namespace ranges {
    template<class I, class F>
    struct for_each_result {
      [[no_unique_address]] I in;
      [[no_unique_address]] F fun;
 
      template<class I2, class F2>
        requires ConvertibleTo<const I&, I2> && ConvertibleTo<const F&, F2>
        operator for_each_result<I2, F2>() const & {
          return {in, fun};
        }
 
      template<class I2, class F2>
        requires ConvertibleTo<I, I2> && ConvertibleTo<F, F2>
        operator for_each_result<I2, F2>() && {
          return {std::move(in), std::move(fun)};
        }
    };
 
    template<InputIterator I, Sentinel<I> S, class Proj = identity,
             IndirectUnaryInvocable<projected<I, Proj>> Fun>
      constexpr for_each_result<I, Fun>
        for_each(I first, S last, Fun f, Proj proj = {});
    template<InputRange R, class Proj = identity,
             IndirectUnaryInvocable<projected<iterator_t<R>, Proj>> Fun>
      constexpr for_each_result<safe_iterator_t<R>, Fun>
        for_each(R&& r, Fun f, Proj proj = {});
  }
 
  template<class InputIt, class Size, class Function>
    constexpr InputIt for_each_n(InputIt first, Size n, Function f);
  template<class ExecutionPolicy, class ForwardIt, class Size, class Function>
    ForwardIt for_each_n(ExecutionPolicy&& exec,
                         ForwardIt first, Size n, Function f);
 
  // find:
  template<class InputIt, class T>
    constexpr InputIt find(InputIt first, InputIt last,
                           const T& value);
  template<class ExecutionPolicy, class ForwardIt, class T>
    ForwardIt find(ExecutionPolicy&& exec,
                   ForwardIt first, ForwardIt last, const T& value);
  template<class InputIt, class Pred>
    constexpr InputIt find_if(InputIt first, InputIt last, Pred pred);
  template<class ExecutionPolicy, class ForwardIt, class Pred>
    ForwardIt find_if(ExecutionPolicy&& exec,
                      ForwardIt first, ForwardIt last, Pred pred);
  template<class InputIt, class Pred>
    constexpr InputIt find_if_not(InputIt first, InputIt last, Pred pred);
  template<class ExecutionPolicy, class ForwardIt, class Pred>
    ForwardIt find_if_not(ExecutionPolicy&& exec,
                          ForwardIt first, ForwardIt last, Pred pred);
 
  namespace ranges {
    template<InputIterator I, Sentinel<I> S, class T, class Proj = identity>
      requires IndirectRelation<ranges::equal_to, projected<I, Proj>, const T*>
      constexpr I find(I first, S last, const T& value, Proj proj = {});
    template<InputRange R, class T, class Proj = identity>
      requires IndirectRelation<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*>
      constexpr safe_iterator_t<R>
        find(R&& r, const T& value, Proj proj = {});
    template<InputIterator I, Sentinel<I> S, class Proj = identity,
             IndirectUnaryPredicate<projected<I, Proj>> Pred>
      constexpr I find_if(I first, S last, Pred pred, Proj proj = {});
    template<InputRange R, class Proj = identity,
             IndirectUnaryPredicate<projected<iterator_t<R>, Proj>> Pred>
      constexpr safe_iterator_t<R>
        find_if(R&& r, Pred pred, Proj proj = {});
    template<InputIterator I, Sentinel<I> S, class Proj = identity,
             IndirectUnaryPredicate<projected<I, Proj>> Pred>
      constexpr I find_if_not(I first, S last, Pred pred, Proj proj = {});
    template<InputRange R, class Proj = identity,
             IndirectUnaryPredicate<projected<iterator_t<R>, Proj>> Pred>
      constexpr safe_iterator_t<R>
        find_if_not(R&& r, Pred pred, Proj proj = {});
  }
 
  // find end:
  template<class ForwardIt1, class ForwardIt2>
    constexpr ForwardIt1
      find_end(ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2, ForwardIt2 last2);
  template<class ForwardIt1, class ForwardIt2, class BinaryPred>
    constexpr ForwardIt1
      find_end(ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2, ForwardIt2 last2,
               BinaryPred pred);
  template<class ExecutionPolicy, class ForwardIt1, class ForwardIt2>
    ForwardIt1
      find_end(ExecutionPolicy&& exec,
               ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2, ForwardIt2 last2);
  template<class ExecutionPolicy, class ForwardIt1,
           class ForwardIt2, class BinaryPred>
    ForwardIt1
      find_end(ExecutionPolicy&& exec,
               ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2, ForwardIt2 last2,
               BinaryPred pred);
 
  namespace ranges {
    template<ForwardIterator I1, Sentinel<I1> S1, ForwardIterator I2, Sentinel<I2> S2,
             class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
      requires IndirectlyComparable<I1, I2, Pred, Proj1, Proj2>
      constexpr subrange<I1>
        find_end(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {},
                 Proj1 proj1 = {}, Proj2 proj2 = {});
    template<ForwardRange R1, ForwardRange R2,
             class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
      requires IndirectlyComparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
      constexpr safe_subrange_t<R1>
        find_end(R1&& r1, R2&& r2, Pred pred = {},
                 Proj1 proj1 = {}, Proj2 proj2 = {});
  }
 
  // find first:
  template<class InputIt, class ForwardIt>
    constexpr InputIt
      find_first_of(InputIt first1, InputIt last1, ForwardIt first2, ForwardIt last2);
  template<class InputIt, class ForwardIt, class BinaryPred>
    constexpr InputIt
      find_first_of(InputIt first1, InputIt last1, ForwardIt first2, ForwardIt last2,
                    BinaryPred pred);
  template<class ExecutionPolicy, class ForwardIt1, class ForwardIt2>
    ForwardIt1
      find_first_of(ExecutionPolicy&& exec,
                    ForwardIt1 first1, ForwardIt1 last1,
                    ForwardIt2 first2, ForwardIt2 last2);
  template<class ExecutionPolicy, class ForwardIt1, class ForwardIt2, class BinaryPred>
    ForwardIt1
      find_first_of(ExecutionPolicy&& exec,
                    ForwardIt1 first1, ForwardIt1 last1,
                    ForwardIt2 first2, ForwardIt2 last2,
                    BinaryPred pred);
 
  namespace ranges {
    template<InputIterator I1, Sentinel<I1> S1, ForwardIterator I2, Sentinel<I2> S2,
             class Proj1 = identity, class Proj2 = identity,
             IndirectRelation<projected<I1, Proj1>,
                              projected<I2, Proj2>> Pred = ranges::equal_to>
      constexpr I1 find_first_of(I1 first1, S1 last1, I2 first2, S2 last2,
                                 Pred pred = {},
                                 Proj1 proj1 = {}, Proj2 proj2 = {});
    template<InputRange R1, ForwardRange R2,
             class Proj1 = identity, class Proj2 = identity,
             IndirectRelation<projected<iterator_t<R1>, Proj1>,
                              projected<iterator_t<R2>, Proj2>> Pred = ranges::equal_to>
      constexpr safe_iterator_t<R1>
        find_first_of(R1&& r1, R2&& r2,
                      Pred pred = {},
                      Proj1 proj1 = {}, Proj2 proj2 = {});
  }
 
  // adjacent find:
  template<class ForwardIt>
    constexpr ForwardIt
      adjacent_find(ForwardIt first, ForwardIt last);
  template<class ForwardIt, class BinaryPred>
    constexpr ForwardIt
      adjacent_find(ForwardIt first, ForwardIt last, BinaryPred pred);
  template<class ExecutionPolicy, class ForwardIt>
    ForwardIt
      adjacent_find(ExecutionPolicy&& exec,
                    ForwardIt first, ForwardIt last);
  template<class ExecutionPolicy, class ForwardIt, class BinaryPred>
    ForwardIt
      adjacent_find(ExecutionPolicy&& exec,
                    ForwardIt first, ForwardIt last, BinaryPred pred);
 
  namespace ranges {
    template<ForwardIterator I, Sentinel<I> S, class Proj = identity,
             IndirectRelation<projected<I, Proj>> Pred = ranges::equal_to>
      constexpr I adjacent_find(I first, S last, Pred pred = {},
                                Proj proj = {});
    template<ForwardRange R, class Proj = identity,
             IndirectRelation<projected<iterator_t<R>, Proj>> Pred = ranges::equal_to>
      constexpr safe_iterator_t<R>
        adjacent_find(R&& r, Pred pred = {}, Proj proj = {});
  }
 
  // count:
  template<class InputIt, class T>
    constexpr typename iterator_traits<InputIt>::difference_type
      count(InputIt first, InputIt last, const T& value);
  template<class ExecutionPolicy, class ForwardIt, class T>
    typename iterator_traits<ForwardIt>::difference_type
      count(ExecutionPolicy&& exec,
            ForwardIt first, ForwardIt last, const T& value);
  template<class InputIt, class Pred>
    constexpr typename iterator_traits<InputIt>::difference_type
      count_if(InputIt first, InputIt last, Pred pred);
  template<class ExecutionPolicy, class ForwardIt, class Pred>
    typename iterator_traits<ForwardIt>::difference_type
      count_if(ExecutionPolicy&& exec,
               ForwardIt first, ForwardIt last, Pred pred);
 
  namespace ranges {
    template<InputIterator I, Sentinel<I> S, class T, class Proj = identity>
      requires IndirectRelation<ranges::equal_to, projected<I, Proj>, const T*>
      constexpr iter_difference_t<I>
        count(I first, S last, const T& value, Proj proj = {});
    template<InputRange R, class T, class Proj = identity>
      requires IndirectRelation<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*>
      constexpr iter_difference_t<iterator_t<R>>
        count(R&& r, const T& value, Proj proj = {});
    template<InputIterator I, Sentinel<I> S, class Proj = identity,
             IndirectUnaryPredicate<projected<I, Proj>> Pred>
      constexpr iter_difference_t<I>
        count_if(I first, S last, Pred pred, Proj proj = {});
    template<InputRange R, class Proj = identity,
             IndirectUnaryPredicate<projected<iterator_t<R>, Proj>> Pred>
      constexpr iter_difference_t<iterator_t<R>>
        count_if(R&& r, Pred pred, Proj proj = {});
  }
 
  // mismatch:
  template<class InputIt1, class InputIt2>
    constexpr pair<InputIt1, InputIt2>
      mismatch(InputIt1 first1, InputIt1 last1, InputIt2 first2);
  template<class InputIt1, class InputIt2, class BinaryPred>
    constexpr pair<InputIt1, InputIt2>
      mismatch(InputIt1 first1, InputIt1 last1, InputIt2 first2, BinaryPred pred);
  template<class InputIt1, class InputIt2>
    constexpr pair<InputIt1, InputIt2>
      mismatch(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2);
  template<class InputIt1, class InputIt2, class BinaryPred>
    constexpr pair<InputIt1, InputIt2>
      mismatch(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2,
               BinaryPred pred);
  template<class ExecutionPolicy, class ForwardIt1, class ForwardIt2>
    pair<ForwardIt1, ForwardIt2>
      mismatch(ExecutionPolicy&& exec,
               ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2);
  template<class ExecutionPolicy, class ForwardIt1, class ForwardIt2,
           class BinaryPred>
    pair<ForwardIt1, ForwardIt2>
      mismatch(ExecutionPolicy&& exec,
               ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2, BinaryPred pred);
  template<class ExecutionPolicy, class ForwardIt1, class ForwardIt2>
    pair<ForwardIt1, ForwardIt2>
      mismatch(ExecutionPolicy&& exec,
               ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2, ForwardIt2 last2);
  template<class ExecutionPolicy, class ForwardIt1, class ForwardIt2, class BinaryPred>
    pair<ForwardIt1, ForwardIt2>
      mismatch(ExecutionPolicy&& exec,
               ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2, ForwardIt2 last2,
               BinaryPred pred);
 
  namespace ranges {
    template<class I1, class I2>
    struct mismatch_result {
      [[no_unique_address]] I1 in1;
      [[no_unique_address]] I2 in2;
 
      template<class II1, class II2>
        requires ConvertibleTo<const I1&, II1> && ConvertibleTo<const I2&, II2>
        operator mismatch_result<II1, II2>() const & {
          return {in1, in2};
        }
 
      template<class II1, class II2>
        requires ConvertibleTo<I1, II1> && ConvertibleTo<I2, II2>
        operator mismatch_result<II1, II2>() && {
          return {std::move(in1), std::move(in2)};
        }
    };
 
    template<InputIterator I1, Sentinel<I1> S1, InputIterator I2, Sentinel<I2> S2,
             class Proj1 = identity, class Proj2 = identity,
             IndirectRelation<projected<I1, Proj1>,
                              projected<I2, Proj2>> Pred = ranges::equal_to>
      constexpr mismatch_result<I1, I2>
        mismatch(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {},
                 Proj1 proj1 = {}, Proj2 proj2 = {});
    template<InputRange R1, InputRange R2,
             class Proj1 = identity, class Proj2 = identity,
             IndirectRelation<projected<iterator_t<R1>, Proj1>,
                              projected<iterator_t<R2>, Proj2>> Pred = ranges::equal_to>
      constexpr mismatch_result<safe_iterator_t<R1>, safe_iterator_t<R2>>
        mismatch(R1&& r1, R2&& r2, Pred pred = {},
                 Proj1 proj1 = {}, Proj2 proj2 = {});
  }
 
  // equal:
  template<class InputIt1, class InputIt2>
    constexpr bool equal(InputIt1 first1, InputIt1 last1, InputIt2 first2);
  template<class InputIt1, class InputIt2, class BinaryPred>
    constexpr bool equal(InputIt1 first1, InputIt1 last1, InputIt2 first2,
                         BinaryPred pred);
  template<class InputIt1, class InputIt2>
    constexpr bool equal(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2);
  template<class InputIt1, class InputIt2, class BinaryPred>
    constexpr bool equal(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2,
                         BinaryPred pred);
  template<class ExecutionPolicy, class ForwardIt1, class ForwardIt2>
    bool equal(ExecutionPolicy&& exec,
               ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2);
  template<class ExecutionPolicy, class ForwardIt1, class ForwardIt2, class BinaryPred>
    bool equal(ExecutionPolicy&& exec,
               ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2, BinaryPred pred);
  template<class ExecutionPolicy, class ForwardIt1, class ForwardIt2>
    bool equal(ExecutionPolicy&& exec,
               ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2, ForwardIt2 last2);
  template<class ExecutionPolicy, class ForwardIt1, class ForwardIt2, class BinaryPred>
    bool equal(ExecutionPolicy&& exec,
               ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2, ForwardIt2 last2,
               BinaryPred pred);
 
  namespace ranges {
    template<InputIterator I1, Sentinel<I1> S1, InputIterator I2, Sentinel<I2> S2,
             class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
      requires IndirectlyComparable<I1, I2, Pred, Proj1, Proj2>
      constexpr bool equal(I1 first1, S1 last1, I2 first2, S2 last2,
                           Pred pred = {},
                           Proj1 proj1 = {}, Proj2 proj2 = {});
    template<InputRange R1, InputRange R2, class Pred = ranges::equal_to,
             class Proj1 = identity, class Proj2 = identity>
      requires IndirectlyComparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
      constexpr bool equal(R1&& r1, R2&& r2, Pred pred = {},
                           Proj1 proj1 = {}, Proj2 proj2 = {});
  }
 
  // is permutation:
  template<class ForwardIt1, class ForwardIt2>
    constexpr bool is_permutation(ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2);
  template<class ForwardIt1, class ForwardIt2, class BinaryPred>
    constexpr bool is_permutation(ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2,
                                  BinaryPred pred);
  template<class ForwardIt1, class ForwardIt2>
    constexpr bool is_permutation(ForwardIt1 first1, ForwardIt1 last1,
                                  ForwardIt2 first2, ForwardIt2 last2);
  template<class ForwardIt1, class ForwardIt2, class BinaryPred>
    constexpr bool is_permutation(ForwardIt1 first1, ForwardIt1 last1,
                                  ForwardIt2 first2, ForwardIt2 last2,
                                  BinaryPred pred);
 
  namespace ranges {
    template<ForwardIterator I1, Sentinel<I1> S1, ForwardIterator I2,
             Sentinel<I2> S2, class Pred = ranges::equal_to, class Proj1 = identity,
             class Proj2 = identity>
      requires IndirectlyComparable<I1, I2, Pred, Proj1, Proj2>
      constexpr bool is_permutation(I1 first1, S1 last1, I2 first2, S2 last2,
                                    Pred pred = {},
                                    Proj1 proj1 = {}, Proj2 proj2 = {});
    template<ForwardRange R1, ForwardRange R2, class Pred = ranges::equal_to,
             class Proj1 = identity, class Proj2 = identity>
      requires IndirectlyComparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
      constexpr bool is_permutation(R1&& r1, R2&& r2, Pred pred = {},
                                    Proj1 proj1 = {}, Proj2 proj2 = {});
  }
 
  // search:
  template<class ForwardIt1, class ForwardIt2>
    constexpr ForwardIt1
      search(ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2, ForwardIt2 last2);
  template<class ForwardIt1, class ForwardIt2, class BinaryPred>
    constexpr ForwardIt1
      search(ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2, ForwardIt2 last2,
             BinaryPred pred);
  template<class ExecutionPolicy, class ForwardIt1, class ForwardIt2>
    ForwardIt1
      search(ExecutionPolicy&& exec,
             ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2, ForwardIt2 last2);
  template<class ExecutionPolicy, class ForwardIt1, class ForwardIt2, class BinaryPred>
    ForwardIt1
      search(ExecutionPolicy&& exec,
             ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2, ForwardIt2 last2,
             BinaryPred pred);
 
  namespace ranges {
    template<ForwardIterator I1, Sentinel<I1> S1, ForwardIterator I2,
             Sentinel<I2> S2, class Pred = ranges::equal_to,
             class Proj1 = identity, class Proj2 = identity>
      requires IndirectlyComparable<I1, I2, Pred, Proj1, Proj2>
      constexpr subrange<I1>
        search(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {},
               Proj1 proj1 = {}, Proj2 proj2 = {});
    template<ForwardRange R1, ForwardRange R2, class Pred = ranges::equal_to,
             class Proj1 = identity, class Proj2 = identity>
      requires IndirectlyComparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
      constexpr safe_subrange_t<R1>
        search(R1&& r1, R2&& r2, Pred pred = {},
               Proj1 proj1 = {}, Proj2 proj2 = {});
  }
 
  template<class ForwardIt, class Size, class T>
    constexpr ForwardIt
      search_n(ForwardIt first, ForwardIt last, Size count, const T& value);
  template<class ForwardIt, class Size, class T, class BinaryPred>
    constexpr ForwardIt
      search_n(ForwardIt first, ForwardIt last,
               Size count, const T& value, BinaryPred pred);
  template<class ExecutionPolicy, class ForwardIt, class Size, class T>
    ForwardIt
      search_n(ExecutionPolicy&& exec,
               ForwardIt first, ForwardIt last, Size count, const T& value);
  template<class ExecutionPolicy, class ForwardIt, class Size, class T, class BinaryPred>
    ForwardIt
      search_n(ExecutionPolicy&& exec,
               ForwardIt first, ForwardIt last,
               Size count, const T& value, BinaryPred pred);
 
  namespace ranges {
    template<ForwardIterator I, Sentinel<I> S, class T,
             class Pred = ranges::equal_to, class Proj = identity>
      requires IndirectlyComparable<I, const T*, Pred, Proj>
      constexpr subrange<I>
        search_n(I first, S last, iter_difference_t<I> count,
                 const T& value, Pred pred = {}, Proj proj = {});
    template<ForwardRange R, class T, class Pred = ranges::equal_to,
             class Proj = identity>
      requires IndirectlyComparable<iterator_t<R>, const T*, Pred, Proj>
      constexpr safe_subrange_t<R>
        search_n(R&& r, iter_difference_t<iterator_t<R>> count,
                 const T& value, Pred pred = {}, Proj proj = {});
  }
 
  template<class ForwardIt, class Searcher>
    constexpr ForwardIt
      search(ForwardIt first, ForwardIt last, const Searcher& searcher);
 
  // mutating sequence operations:
  // copy:
  template<class InputIt, class OutputIt>
    constexpr OutputIt copy(InputIt first, InputIt last, OutputIt result);
  template<class ExecutionPolicy, class ForwardIt1, class ForwardIt2>
    ForwardIt2 copy(ExecutionPolicy&& exec,
                    ForwardIt1 first, ForwardIt1 last, ForwardIt2 result);
 
  namespace ranges {
    template<class I, class O>
    struct copy_result {
      [[no_unique_address]] I in;
      [[no_unique_address]] O out;
 
      template<class I2, class O2>
        requires ConvertibleTo<const I&, I2> && ConvertibleTo<const O&, O2>
        operator copy_result<I2, O2>() const & {
          return {in, out};
        }
 
      template<class I2, class O2>
        requires ConvertibleTo<I, I2> && ConvertibleTo<O, O2>
        operator copy_result<I2, O2>() && {
          return {std::move(in), std::move(out)};
        }
    };
 
    template<InputIterator I, Sentinel<I> S, WeaklyIncrementable O>
      requires IndirectlyCopyable<I, O>
      constexpr copy_result<I, O>
        copy(I first, S last, O result);
    template<InputRange R, WeaklyIncrementable O>
      requires IndirectlyCopyable<iterator_t<R>, O>
      constexpr copy_result<safe_iterator_t<R>, O>
        copy(R&& r, O result);
  }
 
  template<class InputIt, class Size, class OutputIt>
    constexpr OutputIt copy_n(InputIt first, Size n, OutputIt result);
  template<class ExecutionPolicy, class ForwardIt1, class Size, class ForwardIt2>
    ForwardIt2 copy_n(ExecutionPolicy&& exec,
                      ForwardIt1 first, Size n, ForwardIt2 result);
 
  namespace ranges {
    template<class I, class O>
    using copy_n_result = copy_result<I, O>;
 
    template<InputIterator I, WeaklyIncrementable O>
      requires IndirectlyCopyable<I, O>
      constexpr copy_n_result<I, O>
        copy_n(I first, iter_difference_t<I> n, O result);
  }
 
  template<class InputIt, class OutputIt, class Pred>
    constexpr OutputIt copy_if(InputIt first, InputIt last, OutputIt result, Pred pred);
  template<class ExecutionPolicy, class ForwardIt1, class ForwardIt2, class Pred>
    ForwardIt2 copy_if(ExecutionPolicy&& exec,
                       ForwardIt1 first, ForwardIt1 last, ForwardIt2 result, Pred pred);
 
  namespace ranges {
    template<class I, class O>
    using copy_if_result = copy_result<I, O>;
 
    template<InputIterator I, Sentinel<I> S, WeaklyIncrementable O, class Proj = identity,
             IndirectUnaryPredicate<projected<I, Proj>> Pred>
      requires IndirectlyCopyable<I, O>
      constexpr copy_if_result<I, O>
        copy_if(I first, S last, O result, Pred pred, Proj proj = {});
    template<InputRange R, WeaklyIncrementable O, class Proj = identity,
             IndirectUnaryPredicate<projected<iterator_t<R>, Proj>> Pred>
      requires IndirectlyCopyable<iterator_t<R>, O>
      constexpr copy_if_result<safe_iterator_t<R>, O>
        copy_if(R&& r, O result, Pred pred, Proj proj = {});
  }
 
  template<class BidirectionalIt1, class BidirectionalIt2>
    constexpr BidirectionalIt2
      copy_backward(BidirectionalIt1 first, BidirectionalIt1 last,
                    BidirectionalIt2 result);
 
  namespace ranges {
    template<class I1, class I2>
    using copy_backward_result = copy_result<I1, I2>;
 
    template<BidirectionalIterator I1, Sentinel<I1> S1, BidirectionalIterator I2>
      requires IndirectlyCopyable<I1, I2>
      constexpr copy_backward_result<I1, I2>
        copy_backward(I1 first, S1 last, I2 result);
    template<BidirectionalRange R, BidirectionalIterator I>
      requires IndirectlyCopyable<iterator_t<R>, I>
      constexpr copy_backward_result<safe_iterator_t<R>, I>
        copy_backward(R&& r, I result);
  }
 
  // move:
  template<class InputIt, class OutputIt>
    constexpr OutputIt move(InputIt first, InputIt last, OutputIt result);
  template<class ExecutionPolicy, class ForwardIt1, class ForwardIt2>
    ForwardIt2 move(ExecutionPolicy&& exec,
                    ForwardIt1 first, ForwardIt1 last, ForwardIt2 result);
 
  namespace ranges {
    template<class I, class O>
    using move_result = copy_result<I, O>;
 
    template<InputIterator I, Sentinel<I> S, WeaklyIncrementable O>
      requires IndirectlyMovable<I, O>
      constexpr move_result<I, O>
        move(I first, S last, O result);
    template<InputRange R, WeaklyIncrementable O>
      requires IndirectlyMovable<iterator_t<R>, O>
      constexpr move_result<safe_iterator_t<R>, O>
        move(R&& r, O result);
  }
 
  template<class BidirectionalIt1, class BidirectionalIt2>
    constexpr BidirectionalIt2
      move_backward(BidirectionalIt1 first, BidirectionalIt1 last,
                    BidirectionalIt2 result);
 
  namespace ranges {
    template<class I1, class I2>
    using move_backward_result = copy_result<I1, I2>;
 
    template<BidirectionalIterator I1, Sentinel<I1> S1, BidirectionalIterator I2>
      requires IndirectlyMovable<I1, I2>
      constexpr move_backward_result<I1, I2>
        move_backward(I1 first, S1 last, I2 result);
    template<BidirectionalRange R, BidirectionalIterator I>
      requires IndirectlyMovable<iterator_t<R>, I>
      constexpr move_backward_result<safe_iterator_t<R>, I>
        move_backward(R&& r, I result);
  }
 
  // swap:
  template<class ForwardIt1, class ForwardIt2>
    constexpr ForwardIt2 swap_ranges(ForwardIt1 first1, ForwardIt1 last1,
                                     ForwardIt2 first2);
  template<class ExecutionPolicy, class ForwardIt1, class ForwardIt2>
    ForwardIt2 swap_ranges(ExecutionPolicy&& exec,
                           ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2);
 
  namespace ranges {
    template<class I1, class I2>
    using swap_ranges_result = mismatch_result<I1, I2>;
 
    template<InputIterator I1, Sentinel<I1> S1, InputIterator I2, Sentinel<I2> S2>
      requires IndirectlySwappable<I1, I2>
      constexpr swap_ranges_result<I1, I2>
        swap_ranges(I1 first1, S1 last1, I2 first2, S2 last2);
    template<InputRange R1, InputRange R2>
      requires IndirectlySwappable<iterator_t<R1>, iterator_t<R2>>
      constexpr swap_ranges_result<safe_iterator_t<R1>, safe_iterator_t<R2>>
        swap_ranges(R1&& r1, R2&& r2);
  }
 
  template<class ForwardIt1, class ForwardIt2>
    constexpr void iter_swap(ForwardIt1 a, ForwardIt2 b);
 
  // transform:
  template<class InputIt, class OutputIt, class UnaryOperation>
    constexpr OutputIt
      transform(InputIt first1, InputIt last1, OutputIt result, UnaryOperation op);
  template<class InputIt1, class InputIt2, class OutputIt, class BinaryOperation>
    constexpr OutputIt
      transform(InputIt1 first1, InputIt1 last1, InputIt2 first2, OutputIt result,
                BinaryOperation binary_op);
  template<class ExecutionPolicy, class ForwardIt1, class ForwardIt2, class UnaryOperation>
    ForwardIt2
      transform(ExecutionPolicy&& exec,
                ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 result, UnaryOperation op);
  template<class ExecutionPolicy, class ForwardIt1, class ForwardIt2,
           class ForwardIt, class BinaryOperation>
    ForwardIt
      transform(ExecutionPolicy&& exec,
                ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2, ForwardIt result,
                BinaryOperation binary_op);
 
  namespace ranges {
    template<class I, class O>
    using unary_transform_result = copy_result<I, O>;
 
    template<InputIterator I, Sentinel<I> S, WeaklyIncrementable O,
             CopyConstructible F, class Proj = identity>
      requires Writable<O, indirect_result_t<F&, projected<I, Proj>>>
      constexpr unary_transform_result<I, O>
        transform(I first1, S last1, O result, F op, Proj proj = {});
    template<InputRange R, WeaklyIncrementable O, CopyConstructible F,
             class Proj = identity>
      requires Writable<O, indirect_result_t<F&, projected<iterator_t<R>, Proj>>>
      constexpr unary_transform_result<safe_iterator_t<R>, O>
        transform(R&& r, O result, F op, Proj proj = {});
 
    template<class I1, class I2, class O>
    struct binary_transform_result {
      [[no_unique_address]] I1 in1;
      [[no_unique_address]] I2 in2;
      [[no_unique_address]] O  out;
 
      template<class II1, class II2, class OO>
        requires ConvertibleTo<const I1&, II1> &&
          ConvertibleTo<const I2&, II2> && ConvertibleTo<const O&, OO>
        operator binary_transform_result<II1, II2, OO>() const & {
          return {in1, in2, out};
        }
 
      template<class II1, class II2, class OO>
        requires ConvertibleTo<I1, II1> &&
          ConvertibleTo<I2, II2> && ConvertibleTo<O, OO>
        operator binary_transform_result<II1, II2, OO>() && {
          return {std::move(in1), std::move(in2), std::move(out)};
        }
    };
 
    template<InputIterator I1, Sentinel<I1> S1, InputIterator I2, Sentinel<I2> S2,
             WeaklyIncrementable O, CopyConstructible F, class Proj1 = identity,
             class Proj2 = identity>
      requires Writable<O, indirect_result_t<F&, projected<I1, Proj1>,
                                             projected<I2, Proj2>>>
      constexpr binary_transform_result<I1, I2, O>
        transform(I1 first1, S1 last1, I2 first2, S2 last2, O result,
                  F binary_op, Proj1 proj1 = {}, Proj2 proj2 = {});
    template<InputRange R1, InputRange R2, WeaklyIncrementable O,
             CopyConstructible F, class Proj1 = identity, class Proj2 = identity>
      requires Writable<O, indirect_result_t<F&, projected<iterator_t<R1>, Proj1>,
                                             projected<iterator_t<R2>, Proj2>>>
      constexpr binary_transform_result<safe_iterator_t<R1>, safe_iterator_t<R2>, O>
        transform(R1&& r1, R2&& r2, O result,
                  F binary_op, Proj1 proj1 = {}, Proj2 proj2 = {});
  }
 
  // replace:
  template<class ForwardIt, class T>
    constexpr void replace(ForwardIt first, ForwardIt last,
                           const T& old_value, const T& new_value);
  template<class ExecutionPolicy, class ForwardIt, class T>
    void replace(ExecutionPolicy&& exec,
                 ForwardIt first, ForwardIt last,
                 const T& old_value, const T& new_value);
  template<class ForwardIt, class Pred, class T>
    constexpr void replace_if(ForwardIt first, ForwardIt last,
                              Pred pred, const T& new_value);
  template<class ExecutionPolicy, class ForwardIt, class Pred, class T>
    void replace_if(ExecutionPolicy&& exec,
                    ForwardIt first, ForwardIt last,
                    Pred pred, const T& new_value);
 
  namespace ranges {
    template<InputIterator I, Sentinel<I> S, class T1, class T2, class Proj = identity>
      requires Writable<I, const T2&> &&
               IndirectRelation<ranges::equal_to, projected<I, Proj>, const T1*>
      constexpr I
        replace(I first, S last, const T1& old_value, const T2& new_value, Proj proj = {});
    template<InputRange R, class T1, class T2, class Proj = identity>
      requires Writable<iterator_t<R>, const T2&> &&
               IndirectRelation<ranges::equal_to, projected<iterator_t<R>, Proj>,
                 const T1*>
      constexpr safe_iterator_t<R>
        replace(R&& r, const T1& old_value, const T2& new_value, Proj proj = {});
    template<InputIterator I, Sentinel<I> S, class T, class Proj = identity,
             IndirectUnaryPredicate<projected<I, Proj>> Pred>
      requires Writable<I, const T&>
      constexpr I replace_if(I first, S last,
                             Pred pred, const T& new_value, Proj proj = {});
    template<InputRange R, class T, class Proj = identity,
             IndirectUnaryPredicate<projected<iterator_t<R>, Proj>> Pred>
      requires Writable<iterator_t<R>, const T&>
      constexpr safe_iterator_t<R>
        replace_if(R&& r, Pred pred, const T& new_value, Proj proj = {});
  }
 
  template<class InputIt, class OutputIt, class T>
    constexpr OutputIt replace_copy(InputIt first, InputIt last, OutputIt result,
                                    const T& old_value, const T& new_value);
  template<class ExecutionPolicy, class ForwardIt1, class ForwardIt2, class T>
    ForwardIt2 replace_copy(ExecutionPolicy&& exec,
                            ForwardIt1 first, ForwardIt1 last, ForwardIt2 result,
                            const T& old_value, const T& new_value);
  template<class InputIt, class OutputIt, class Pred, class T>
    constexpr OutputIt replace_copy_if(InputIt first, InputIt last, OutputIt result,
                                       Pred pred, const T& new_value);
  template<class ExecutionPolicy, class ForwardIt1, class ForwardIt2, class Pred, class T>
    ForwardIt2 replace_copy_if(ExecutionPolicy&& exec,
                               ForwardIt1 first, ForwardIt1 last, ForwardIt2 result,
                               Pred pred, const T& new_value);
 
  namespace ranges {
    template<class I, class O>
    using replace_copy_result = copy_result<I, O>;
 
    template<InputIterator I, Sentinel<I> S, class T1, class T2,
             OutputIterator<const T2&> O, class Proj = identity>
      requires IndirectlyCopyable<I, O> &&
               IndirectRelation<ranges::equal_to, projected<I, Proj>, const T1*>
      constexpr replace_copy_result<I, O>
        replace_copy(I first, S last, O result, const T1& old_value, const T2& new_value,
                     Proj proj = {});
    template<InputRange R, class T1, class T2, OutputIterator<const T2&> O,
             class Proj = identity>
      requires IndirectlyCopyable<iterator_t<R>, O> &&
               IndirectRelation<ranges::equal_to, projected<iterator_t<R>, Proj>,
                 const T1*>
      constexpr replace_copy_result<safe_iterator_t<R>, O>
        replace_copy(R&& r, O result, const T1& old_value, const T2& new_value,
                     Proj proj = {});
 
    template<class I, class O>
    using replace_copy_if_result = copy_result<I, O>;
 
    template<InputIterator I, Sentinel<I> S, class T, OutputIterator<const T&> O,
             class Proj = identity, IndirectUnaryPredicate<projected<I, Proj>> Pred>
      requires IndirectlyCopyable<I, O>
      constexpr replace_copy_if_result<I, O>
        replace_copy_if(I first, S last, O result, Pred pred, const T& new_value,
                        Proj proj = {});
    template<InputRange R, class T, OutputIterator<const T&> O, class Proj = identity,
             IndirectUnaryPredicate<projected<iterator_t<R>, Proj>> Pred>
      requires IndirectlyCopyable<iterator_t<R>, O>
      constexpr replace_copy_if_result<safe_iterator_t<R>, O>
        replace_copy_if(R&& r, O result, Pred pred, const T& new_value,
                        Proj proj = {});
  }
 
  // fill:
  template<class ForwardIt, class T>
    constexpr void fill(ForwardIt first, ForwardIt last, const T& value);
  template<class ExecutionPolicy, class ForwardIt, class T>
    void fill(ExecutionPolicy&& exec,
              ForwardIt first, ForwardIt last, const T& value);
  template<class OutputIt, class Size, class T>
    constexpr OutputIt fill_n(OutputIt first, Size n, const T& value);
  template<class ExecutionPolicy, class ForwardIt, class Size, class T>
    ForwardIt fill_n(ExecutionPolicy&& exec,
                     ForwardIt first, Size n, const T& value);
 
  namespace ranges {
    template<class T, OutputIterator<const T&> O, Sentinel<O> S>
      constexpr O fill(O first, S last, const T& value);
    template<class T, OutputRange<const T&> R>
      constexpr safe_iterator_t<R> fill(R&& r, const T& value);
    template<class T, OutputIterator<const T&> O>
      constexpr O fill_n(O first, iter_difference_t<O> n, const T& value);
  }
 
  // generate:
  template<class ForwardIt, class Generator>
    constexpr void generate(ForwardIt first, ForwardIt last, Generator gen);
  template<class ExecutionPolicy, class ForwardIt, class Generator>
    void generate(ExecutionPolicy&& exec,
                  ForwardIt first, ForwardIt last, Generator gen);
  template<class OutputIt, class Size, class Generator>
    constexpr OutputIt generate_n(OutputIt first, Size n, Generator gen);
  template<class ExecutionPolicy, class ForwardIt, class Size, class Generator>
    ForwardIt generate_n(ExecutionPolicy&& exec,
                         ForwardIt first, Size n, Generator gen);
 
  namespace ranges {
    template<Iterator O, Sentinel<O> S, CopyConstructible F>
      requires Invocable<F&> && Writable<O, invoke_result_t<F&>>
      constexpr O generate(O first, S last, F gen);
    template<class R, CopyConstructible F>
      requires Invocable<F&> && OutputRange<R, invoke_result_t<F&>>
      constexpr safe_iterator_t<R> generate(R&& r, F gen);
    template<Iterator O, CopyConstructible F>
      requires Invocable<F&> && Writable<O, invoke_result_t<F&>>
      constexpr O generate_n(O first, iter_difference_t<O> n, F gen);
  }
 
  // remove:
  template<class ForwardIt, class T>
    constexpr ForwardIt remove(ForwardIt first, ForwardIt last, const T& value);
  template<class ExecutionPolicy, class ForwardIt, class T>
    ForwardIt remove(ExecutionPolicy&& exec,
                     ForwardIt first, ForwardIt last, const T& value);
  template<class ForwardIt, class Pred>
    constexpr ForwardIt remove_if(ForwardIt first, ForwardIt last, Pred pred);
  template<class ExecutionPolicy, class ForwardIt, class Pred>
    ForwardIt remove_if(ExecutionPolicy&& exec,
                        ForwardIt first, ForwardIt last, Pred pred);
 
  namespace ranges {
    template<Permutable I, Sentinel<I> S, class T, class Proj = identity>
      requires IndirectRelation<ranges::equal_to, projected<I, Proj>, const T*>
      constexpr I remove(I first, S last, const T& value, Proj proj = {});
    template<ForwardRange R, class T, class Proj = identity>
      requires Permutable<iterator_t<R>> &&
               IndirectRelation<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*>
      constexpr safe_iterator_t<R>
        remove(R&& r, const T& value, Proj proj = {});
    template<Permutable I, Sentinel<I> S, class Proj = identity,
             IndirectUnaryPredicate<projected<I, Proj>> Pred>
      constexpr I remove_if(I first, S last, Pred pred, Proj proj = {});
    template<ForwardRange R, class Proj = identity,
             IndirectUnaryPredicate<projected<iterator_t<R>, Proj>> Pred>
      requires Permutable<iterator_t<R>>
      constexpr safe_iterator_t<R>
        remove_if(R&& r, Pred pred, Proj proj = {});
  }
 
  template<class InputIt, class OutputIt, class T>
    constexpr OutputIt
      remove_copy(InputIt first, InputIt last, OutputIt result, const T& value);
  template<class ExecutionPolicy, class ForwardIt1, class ForwardIt2, class T>
    ForwardIt2
      remove_copy(ExecutionPolicy&& exec,
                  ForwardIt1 first, ForwardIt1 last, ForwardIt2 result, const T& value);
  template<class InputIt, class OutputIt, class Pred>
    constexpr OutputIt
      remove_copy_if(InputIt first, InputIt last, OutputIt result, Pred pred);
  template<class ExecutionPolicy, class ForwardIt1, class ForwardIt2, class Pred>
    ForwardIt2
      remove_copy_if(ExecutionPolicy&& exec,
                     ForwardIt1 first, ForwardIt1 last, ForwardIt2 result, Pred pred);
 
  namespace ranges {
    template<class I, class O>
    using remove_copy_result = copy_result<I, O>;
 
    template<InputIterator I, Sentinel<I> S, WeaklyIncrementable O, class T,
             class Proj = identity>
      requires IndirectlyCopyable<I, O> &&
               IndirectRelation<ranges::equal_to, projected<I, Proj>, const T*>
      constexpr remove_copy_result<I, O>
        remove_copy(I first, S last, O result, const T& value, Proj proj = {});
    template<InputRange R, WeaklyIncrementable O, class T, class Proj = identity>
      requires IndirectlyCopyable<iterator_t<R>, O> &&
               IndirectRelation<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*>
      constexpr remove_copy_result<safe_iterator_t<R>, O>
        remove_copy(R&& r, O result, const T& value, Proj proj = {});
 
    template<class I, class O>
    using remove_copy_if_result = copy_result<I, O>;
 
    template<InputIterator I, Sentinel<I> S, WeaklyIncrementable O,
             class Proj = identity, IndirectUnaryPredicate<projected<I, Proj>> Pred>
      requires IndirectlyCopyable<I, O>
      constexpr remove_copy_if_result<I, O>
        remove_copy_if(I first, S last, O result, Pred pred, Proj proj = {});
    template<InputRange R, WeaklyIncrementable O, class Proj = identity,
             IndirectUnaryPredicate<projected<iterator_t<R>, Proj>> Pred>
      requires IndirectlyCopyable<iterator_t<R>, O>
      constexpr remove_copy_if_result<safe_iterator_t<R>, O>
        remove_copy_if(R&& r, O result, Pred pred, Proj proj = {});
  }
 
  // unique:
  template<class ForwardIt>
    constexpr ForwardIt unique(ForwardIt first, ForwardIt last);
  template<class ForwardIt, class BinaryPred>
    constexpr ForwardIt unique(ForwardIt first, ForwardIt last, BinaryPred pred);
  template<class ExecutionPolicy, class ForwardIt>
    ForwardIt unique(ExecutionPolicy&& exec,
                     ForwardIt first, ForwardIt last);
  template<class ExecutionPolicy, class ForwardIt, class BinaryPred>
    ForwardIt unique(ExecutionPolicy&& exec,
                     ForwardIt first, ForwardIt last, BinaryPred pred);
 
  namespace ranges {
    template<Permutable I, Sentinel<I> S, class Proj = identity,
             IndirectRelation<projected<I, Proj>> C = ranges::equal_to>
      constexpr I unique(I first, S last, C comp = {}, Proj proj = {});
    template<ForwardRange R, class Proj = identity,
             IndirectRelation<projected<iterator_t<R>, Proj>> C = ranges::equal_to>
      requires Permutable<iterator_t<R>>
      constexpr safe_iterator_t<R>
        unique(R&& r, C comp = {}, Proj proj = {});
  }
 
  template<class InputIt, class OutputIt>
    constexpr OutputIt
      unique_copy(InputIt first, InputIt last, OutputIt result);
  template<class InputIt, class OutputIt, class BinaryPred>
    constexpr OutputIt
      unique_copy(InputIt first, InputIt last, OutputIt result, BinaryPred pred);
  template<class ExecutionPolicy, class ForwardIt1, class ForwardIt2>
    ForwardIt2
      unique_copy(ExecutionPolicy&& exec,
                  ForwardIt1 first, ForwardIt1 last, ForwardIt2 result);
  template<class ExecutionPolicy, class ForwardIt1, class ForwardIt2, class BinaryPred>
    ForwardIt2
      unique_copy(ExecutionPolicy&& exec,
                  ForwardIt1 first, ForwardIt1 last, ForwardIt2 result, BinaryPred pred);
 
  namespace ranges {
    template<class I, class O>
    using unique_copy_result = copy_result<I, O>;
 
    template<InputIterator I, Sentinel<I> S, WeaklyIncrementable O,
             class Proj = identity,
             IndirectRelation<projected<I, Proj>> C = ranges::equal_to>
      requires IndirectlyCopyable<I, O> &&
               (ForwardIterator<I> ||
                (InputIterator<O> && Same<iter_value_t<I>, iter_value_t<O>>) ||
                IndirectlyCopyableStorable<I, O>)
      constexpr unique_copy_result<I, O>
        unique_copy(I first, S last, O result, C comp = {}, Proj proj = {});
    template<InputRange R, WeaklyIncrementable O, class Proj = identity,
             IndirectRelation<projected<iterator_t<R>, Proj>> C = ranges::equal_to>
      requires IndirectlyCopyable<iterator_t<R>, O> &&
               (ForwardIterator<iterator_t<R>> ||
                (InputIterator<O> && Same<iter_value_t<iterator_t<R>>, iter_value_t<O>>) ||
                IndirectlyCopyableStorable<iterator_t<R>, O>)
      constexpr unique_copy_result<safe_iterator_t<R>, O>
        unique_copy(R&& r, O result, C comp = {}, Proj proj = {});
  }
 
  // reverse:
  template<class BidirectionalIt>
    constexpr void reverse(BidirectionalIt first, BidirectionalIt last);
  template<class ExecutionPolicy, class BidirectionalIt>
    void reverse(ExecutionPolicy&& exec,
                 BidirectionalIt first, BidirectionalIt last);
 
  namespace ranges {
    template<BidirectionalIterator I, Sentinel<I> S>
      requires Permutable<I>
      constexpr I reverse(I first, S last);
    template<BidirectionalRange R>
      requires Permutable<iterator_t<R>>
      constexpr safe_iterator_t<R> reverse(R&& r);
  }
 
  template<class BidirectionalIt, class OutputIt>
    constexpr OutputIt
      reverse_copy(BidirectionalIt first, BidirectionalIt last, OutputIt result);
  template<class ExecutionPolicy, class BidirectionalIt, class ForwardIt>
    ForwardIt
      reverse_copy(ExecutionPolicy&& exec,
                   BidirectionalIt first, BidirectionalIt last, ForwardIt result);
 
  namespace ranges {
    template<class I, class O>
    using reverse_copy_result = copy_result<I, O>;
 
    template<BidirectionalIterator I, Sentinel<I> S, WeaklyIncrementable O>
      requires IndirectlyCopyable<I, O>
      constexpr reverse_copy_result<I, O>
        reverse_copy(I first, S last, O result);
    template<BidirectionalRange R, WeaklyIncrementable O>
      requires IndirectlyCopyable<iterator_t<R>, O>
      constexpr reverse_copy_result<safe_iterator_t<R>, O>
        reverse_copy(R&& r, O result);
  }
 
  // rotate:
  template<class ForwardIt>
    constexpr ForwardIt rotate(ForwardIt first, ForwardIt middle, ForwardIt last);
  template<class ExecutionPolicy, class ForwardIt>
    ForwardIt rotate(ExecutionPolicy&& exec,
                     ForwardIt first, ForwardIt middle, ForwardIt last);
 
  namespace ranges {
    template<Permutable I, Sentinel<I> S>
      constexpr subrange<I> rotate(I first, I middle, S last);
    template<ForwardRange R>
      requires Permutable<iterator_t<R>>
      constexpr safe_subrange_t<R> rotate(R&& r, iterator_t<R> middle);
  }
 
  template<class ForwardIt, class OutputIt>
    constexpr OutputIt
      rotate_copy(ForwardIt first, ForwardIt middle, ForwardIt last, OutputIt result);
  template<class ExecutionPolicy, class ForwardIt1, class ForwardIt2>
    ForwardIt2
      rotate_copy(ExecutionPolicy&& exec,
                  ForwardIt1 first, ForwardIt1 middle, ForwardIt1 last, ForwardIt2 result);
 
  namespace ranges {
    template<class I, class O>
    using rotate_copy_result = copy_result<I, O>;
 
    template<ForwardIterator I, Sentinel<I> S, WeaklyIncrementable O>
      requires IndirectlyCopyable<I, O>
      constexpr rotate_copy_result<I, O>
        rotate_copy(I first, I middle, S last, O result);
    template<ForwardRange R, WeaklyIncrementable O>
      requires IndirectlyCopyable<iterator_t<R>, O>
      constexpr rotate_copy_result<safe_iterator_t<R>, O>
        rotate_copy(R&& r, iterator_t<R> middle, O result);
  }
 
  // sample:
  template<class PopulationIt, class SampleIt,
           class Distance, class UniformRndBitGen>
    SampleIt sample(PopulationIt first, PopulationIt last, SampleIt out, Distance n,
                    UniformRndBitGen&& g);
 
  // shuffle:
  template<class RandomAccessIt, class UniformRndBitGen>
    void shuffle(RandomAccessIt first, RandomAccessIt last, UniformRndBitGen&& g);
 
  namespace ranges {
    template<RandomAccessIterator I, Sentinel<I> S, class Gen>
      requires Permutable<I> &&
               UniformRandomBitGenerator<remove_reference_t<Gen>> &&
               ConvertibleTo<invoke_result_t<Gen&>, iter_difference_t<I>>
      I shuffle(I first, S last, Gen&& g);
    template<RandomAccessRange R, class Gen>
      requires Permutable<iterator_t<R>> &&
               UniformRandomBitGenerator<remove_reference_t<Gen>> &&
               ConvertibleTo<invoke_result_t<Gen&>, iter_difference_t<iterator_t<R>>>
      safe_iterator_t<R> shuffle(R&& r, Gen&& g);
  }
 
  // shift:
  template<class ForwardIt>
    constexpr ForwardIt
      shift_left(ForwardIt first, ForwardIt last,
                 typename iterator_traits<ForwardIt>::difference_type n);
  template<class ExecutionPolicy, class ForwardIt>
    ForwardIt
      shift_left(ExecutionPolicy&& exec,
                 ForwardIt first, ForwardIt last,
                 typename iterator_traits<ForwardIt>::difference_type n);
  template<class ForwardIt>
    constexpr ForwardIt
      shift_right(ForwardIt first, ForwardIt last,
                  typename iterator_traits<ForwardIt>::difference_type n);
  template<class ExecutionPolicy, class ForwardIt>
    ForwardIt
      shift_right(ExecutionPolicy&& exec,
                  ForwardIt first, ForwardIt last,
                  typename iterator_traits<ForwardIt>::difference_type n);
 
  // sorting and related operations:
  // sorting:
  template<class RandomAccessIt>
    constexpr void sort(RandomAccessIt first, RandomAccessIt last);
  template<class RandomAccessIt, class Compare>
    constexpr void sort(RandomAccessIt first, RandomAccessIt last, Compare comp);
  template<class ExecutionPolicy, class RandomAccessIt>
    void sort(ExecutionPolicy&& exec,
              RandomAccessIt first, RandomAccessIt last);
  template<class ExecutionPolicy, class RandomAccessIt, class Compare>
    void sort(ExecutionPolicy&& exec,
              RandomAccessIt first, RandomAccessIt last, Compare comp);
 
  namespace ranges {
    template<RandomAccessIterator I, Sentinel<I> S, class Comp = ranges::less,
             class Proj = identity>
      requires Sortable<I, Comp, Proj>
      constexpr I
        sort(I first, S last, Comp comp = {}, Proj proj = {});
    template<RandomAccessRange R, class Comp = ranges::less, class Proj = identity>
      requires Sortable<iterator_t<R>, Comp, Proj>
      constexpr safe_iterator_t<R>
        sort(R&& r, Comp comp = {}, Proj proj = {});
  }
 
  template<class RandomAccessIt>
    void stable_sort(RandomAccessIt first, RandomAccessIt last);
  template<class RandomAccessIt, class Compare>
    void stable_sort(RandomAccessIt first, RandomAccessIt last, Compare comp);
  template<class ExecutionPolicy, class RandomAccessIt>
    void stable_sort(ExecutionPolicy&& exec,
                     RandomAccessIt first, RandomAccessIt last);
  template<class ExecutionPolicy, class RandomAccessIt, class Compare>
    void stable_sort(ExecutionPolicy&& exec,
                     RandomAccessIt first, RandomAccessIt last, Compare comp);
 
  namespace ranges {
    template<RandomAccessIterator I, Sentinel<I> S, class Comp = ranges::less,
             class Proj = identity>
      requires Sortable<I, Comp, Proj>
      I stable_sort(I first, S last, Comp comp = {}, Proj proj = {});
    template<RandomAccessRange R, class Comp = ranges::less, class Proj = identity>
      requires Sortable<iterator_t<R>, Comp, Proj>
      safe_iterator_t<R>
        stable_sort(R&& r, Comp comp = {}, Proj proj = {});
  }
 
  template<class RandomAccessIt>
    constexpr void partial_sort(RandomAccessIt first, RandomAccessIt middle,
                                RandomAccessIt last);
  template<class RandomAccessIt, class Compare>
    constexpr void partial_sort(RandomAccessIt first, RandomAccessIt middle,
                                RandomAccessIt last, Compare comp);
  template<class ExecutionPolicy, class RandomAccessIt>
    void partial_sort(ExecutionPolicy&& exec,
                      RandomAccessIt first, RandomAccessIt middle, RandomAccessIt last);
  template<class ExecutionPolicy, class RandomAccessIt, class Compare>
    void partial_sort(ExecutionPolicy&& exec,
                      RandomAccessIt first, RandomAccessIt middle, RandomAccessIt last,
                      Compare comp);
 
  namespace ranges {
    template<RandomAccessIterator I, Sentinel<I> S, class Comp = ranges::less,
             class Proj = identity>
      requires Sortable<I, Comp, Proj>
      constexpr I
        partial_sort(I first, I middle, S last, Comp comp = {}, Proj proj = {});
    template<RandomAccessRange R, class Comp = ranges::less, class Proj = identity>
      requires Sortable<iterator_t<R>, Comp, Proj>
      constexpr safe_iterator_t<R>
        partial_sort(R&& r, iterator_t<R> middle, Comp comp = {},
                     Proj proj = {});
  }
 
  template<class InputIt, class RandomAccessIt>
    constexpr RandomAccessIt
      partial_sort_copy(InputIt first, InputIt last,
                        RandomAccessIt result_first, RandomAccessIt result_last);
  template<class InputIt, class RandomAccessIt, class Compare>
    constexpr RandomAccessIt
      partial_sort_copy(InputIt first, InputIt last,
                        RandomAccessIt result_first, RandomAccessIt result_last,
                        Compare comp);
  template<class ExecutionPolicy, class ForwardIt, class RandomAccessIt>
    RandomAccessIt
      partial_sort_copy(ExecutionPolicy&& exec, 
                        ForwardIt first, ForwardIt last,
                        RandomAccessIt result_first, RandomAccessIt result_last);
  template<class ExecutionPolicy, class ForwardIt, class RandomAccessIt, class Compare>
    RandomAccessIt
      partial_sort_copy(ExecutionPolicy&& exec, 
                        ForwardIt first, ForwardIt last,
                        RandomAccessIt result_first, RandomAccessIt result_last,
                        Compare comp);
 
  namespace ranges {
    template<InputIterator I1, Sentinel<I1> S1, RandomAccessIterator I2, Sentinel<I2> S2,
             class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity>
      requires IndirectlyCopyable<I1, I2> && Sortable<I2, Comp, Proj2> &&
               IndirectStrictWeakOrder<Comp, projected<I1, Proj1>, projected<I2, Proj2>>
      constexpr I2
        partial_sort_copy(I1 first, S1 last, I2 result_first, S2 result_last,
                          Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {});
    template<InputRange R1, RandomAccessRange R2, class Comp = ranges::less,
             class Proj1 = identity, class Proj2 = identity>
      requires IndirectlyCopyable<iterator_t<R1>, iterator_t<R2>> &&
               Sortable<iterator_t<R2>, Comp, Proj2> &&
               IndirectStrictWeakOrder<Comp, projected<iterator_t<R1>, Proj1>,
                                       projected<iterator_t<R2>, Proj2>>
      constexpr safe_iterator_t<R2>
        partial_sort_copy(R1&& r, R2&& result_r, Comp comp = {},
                          Proj1 proj1 = {}, Proj2 proj2 = {});
  }
 
  template<class ForwardIt>
    constexpr bool is_sorted(ForwardIt first, ForwardIt last);
  template<class ForwardIt, class Compare>
    constexpr bool is_sorted(ForwardIt first, ForwardIt last, Compare comp);
  template<class ExecutionPolicy, class ForwardIt>
    bool is_sorted(ExecutionPolicy&& exec,
                   ForwardIt first, ForwardIt last);
  template<class ExecutionPolicy, class ForwardIt, class Compare>
    bool is_sorted(ExecutionPolicy&& exec,
                   ForwardIt first, ForwardIt last, Compare comp);
 
  namespace ranges {
    template<ForwardIterator I, Sentinel<I> S, class Proj = identity,
             IndirectStrictWeakOrder<projected<I, Proj>> Comp = ranges::less>
      constexpr bool is_sorted(I first, S last, Comp comp = {}, Proj proj = {});
    template<ForwardRange R, class Proj = identity,
             IndirectStrictWeakOrder<projected<iterator_t<R>, Proj>> Comp = ranges::less>
      constexpr bool is_sorted(R&& r, Comp comp = {}, Proj proj = {});
  }
 
  template<class ForwardIt>
    constexpr ForwardIt
      is_sorted_until(ForwardIt first, ForwardIt last);
  template<class ForwardIt, class Compare>
    constexpr ForwardIt
      is_sorted_until(ForwardIt first, ForwardIt last, Compare comp);
  template<class ExecutionPolicy, class ForwardIt>
    ForwardIt
      is_sorted_until(ExecutionPolicy&& exec,
                      ForwardIt first, ForwardIt last);
  template<class ExecutionPolicy, class ForwardIt, class Compare>
    ForwardIt
      is_sorted_until(ExecutionPolicy&& exec,
                      ForwardIt first, ForwardIt last, Compare comp);
 
  namespace ranges {
    template<ForwardIterator I, Sentinel<I> S, class Proj = identity,
             IndirectStrictWeakOrder<projected<I, Proj>> Comp = ranges::less>
      constexpr I is_sorted_until(I first, S last, Comp comp = {}, Proj proj = {});
    template<ForwardRange R, class Proj = identity,
             IndirectStrictWeakOrder<projected<iterator_t<R>, Proj>> Comp = ranges::less>
      constexpr safe_iterator_t<R>
        is_sorted_until(R&& r, Comp comp = {}, Proj proj = {});
  }
 
  // Nth element:
  template<class RandomAccessIt>
    constexpr void nth_element(RandomAccessIt first, RandomAccessIt nth,
                               RandomAccessIt last);
  template<class RandomAccessIt, class Compare>
    constexpr void nth_element(RandomAccessIt first, RandomAccessIt nth,
                               RandomAccessIt last, Compare comp);
  template<class ExecutionPolicy, class RandomAccessIt>
    void nth_element(ExecutionPolicy&& exec,
                     RandomAccessIt first, RandomAccessIt nth,
                     RandomAccessIt last);
  template<class ExecutionPolicy, class RandomAccessIt, class Compare>
    void nth_element(ExecutionPolicy&& exec,
                     RandomAccessIt first, RandomAccessIt nth,
                     RandomAccessIt last, Compare comp);
 
  namespace ranges {
    template<RandomAccessIterator I, Sentinel<I> S, class Comp = ranges::less,
             class Proj = identity>
      requires Sortable<I, Comp, Proj>
      constexpr I
        nth_element(I first, I nth, S last, Comp comp = {}, Proj proj = {});
    template<RandomAccessRange R, class Comp = ranges::less, class Proj = identity>
      requires Sortable<iterator_t<R>, Comp, Proj>
      constexpr safe_iterator_t<R>
        nth_element(R&& r, iterator_t<R> nth, Comp comp = {}, Proj proj = {});
  }
 
  // binary search:
  template<class ForwardIt, class T>
    constexpr ForwardIt
      lower_bound(ForwardIt first, ForwardIt last, const T& value);
  template<class ForwardIt, class T, class Compare>
    constexpr ForwardIt
      lower_bound(ForwardIt first, ForwardIt last, const T& value, Compare comp);
 
  namespace ranges {
    template<ForwardIterator I, Sentinel<I> S, class T, class Proj = identity,
             IndirectStrictWeakOrder<const T*, projected<I, Proj>> Comp = ranges::less>
      constexpr I lower_bound(I first, S last, const T& value, Comp comp = {},
                              Proj proj = {});
    template<ForwardRange R, class T, class Proj = identity,
             IndirectStrictWeakOrder<const T*, projected<iterator_t<R>, Proj>> Comp =
               ranges::less>
      constexpr safe_iterator_t<R>
        lower_bound(R&& r, const T& value, Comp comp = {}, Proj proj = {});
  }
 
  template<class ForwardIt, class T>
    constexpr ForwardIt
      upper_bound(ForwardIt first, ForwardIt last, const T& value);
  template<class ForwardIt, class T, class Compare>
    constexpr ForwardIt
      upper_bound(ForwardIt first, ForwardIt last, const T& value, Compare comp);
 
  namespace ranges {
    template<ForwardIterator I, Sentinel<I> S, class T, class Proj = identity,
             IndirectStrictWeakOrder<const T*, projected<I, Proj>> Comp = ranges::less>
      constexpr I upper_bound(I first, S last,
                              const T& value, Comp comp = {}, Proj proj = {});
    template<ForwardRange R, class T, class Proj = identity,
             IndirectStrictWeakOrder<const T*, projected<iterator_t<R>, Proj>> Comp =
               ranges::less>
      constexpr safe_iterator_t<R>
        upper_bound(R&& r, const T& value, Comp comp = {}, Proj proj = {});
  }
 
  template<class ForwardIt, class T>
    constexpr pair<ForwardIt, ForwardIt>
      equal_range(ForwardIt first, ForwardIt last, const T& value);
  template<class ForwardIt, class T, class Compare>
    constexpr pair<ForwardIt, ForwardIt>
      equal_range(ForwardIt first, ForwardIt last, const T& value, Compare comp);
 
  namespace ranges {
    template<ForwardIterator I, Sentinel<I> S, class T, class Proj = identity,
             IndirectStrictWeakOrder<const T*, projected<I, Proj>> Comp = ranges::less>
      constexpr subrange<I>
        equal_range(I first, S last, const T& value, Comp comp = {}, Proj proj = {});
    template<ForwardRange R, class T, class Proj = identity,
             IndirectStrictWeakOrder<const T*, projected<iterator_t<R>, Proj>> Comp =
               ranges::less>
      constexpr safe_subrange_t<R>
        equal_range(R&& r, const T& value, Comp comp = {}, Proj proj = {});
  }
 
  template<class ForwardIt, class T>
    constexpr bool
      binary_search(ForwardIt first, ForwardIt last, const T& value);
  template<class ForwardIt, class T, class Compare>
    constexpr bool
      binary_search(ForwardIt first, ForwardIt last, const T& value, Compare comp);
 
  namespace ranges {
    template<ForwardIterator I, Sentinel<I> S, class T, class Proj = identity,
             IndirectStrictWeakOrder<const T*, projected<I, Proj>> Comp = ranges::less>
      constexpr bool binary_search(I first, S last, const T& value, Comp comp = {},
                                   Proj proj = {});
    template<ForwardRange R, class T, class Proj = identity,
             IndirectStrictWeakOrder<const T*, projected<iterator_t<R>, Proj>> Comp =
               ranges::less>
      constexpr bool binary_search(R&& r, const T& value, Comp comp = {},
                                   Proj proj = {});
  }
 
  // partitions:
  template<class InputIt, class Pred>
    constexpr bool is_partitioned(InputIt first, InputIt last, Pred pred);
  template<class ExecutionPolicy, class ForwardIt, class Pred>
    bool is_partitioned(ExecutionPolicy&& exec,
                        ForwardIt first, ForwardIt last, Pred pred);
 
  namespace ranges {
    template<InputIterator I, Sentinel<I> S, class Proj = identity,
             IndirectUnaryPredicate<projected<I, Proj>> Pred>
      constexpr bool is_partitioned(I first, S last, Pred pred, Proj proj = {});
    template<InputRange R, class Proj = identity,
             IndirectUnaryPredicate<projected<iterator_t<R>, Proj>> Pred>
      constexpr bool is_partitioned(R&& r, Pred pred, Proj proj = {});
  }
 
  template<class ForwardIt, class Pred>
    constexpr ForwardIt partition(ForwardIt first, ForwardIt last, Pred pred);
  template<class ExecutionPolicy, class ForwardIt, class Pred>
    ForwardIt partition(ExecutionPolicy&& exec,
                        ForwardIt first, ForwardIt last, Pred pred);
 
  namespace ranges {
    template<Permutable I, Sentinel<I> S, class Proj = identity,
             IndirectUnaryPredicate<projected<I, Proj>> Pred>
      constexpr I
        partition(I first, S last, Pred pred, Proj proj = {});
    template<ForwardRange R, class Proj = identity,
             IndirectUnaryPredicate<projected<iterator_t<R>, Proj>> Pred>
      requires Permutable<iterator_t<R>>
      constexpr safe_iterator_t<R>
        partition(R&& r, Pred pred, Proj proj = {});
  }
 
  template<class BidirectionalIt, class Pred>
    BidirectionalIt stable_partition(BidirectionalIt first, BidirectionalIt last,
                                     Pred pred);
  template<class ExecutionPolicy, class BidirectionalIt, class Pred>
    BidirectionalIt stable_partition(ExecutionPolicy&& exec,
                                     BidirectionalIt first, BidirectionalIt last,
                                     Pred pred);
 
  namespace ranges {
    template<BidirectionalIterator I, Sentinel<I> S, class Proj = identity,
             IndirectUnaryPredicate<projected<I, Proj>> Pred>
      requires Permutable<I>
      I stable_partition(I first, S last, Pred pred, Proj proj = {});
    template<BidirectionalRange R, class Proj = identity,
             IndirectUnaryPredicate<projected<iterator_t<R>, Proj>> Pred>
      requires Permutable<iterator_t<R>>
      safe_iterator_t<R> stable_partition(R&& r, Pred pred, Proj proj = {});
  }
 
  template<class InputIt, class OutputIt1, class OutputIt2, class Pred>
    constexpr pair<OutputIt1, OutputIt2>
      partition_copy(InputIt first, InputIt last, OutputIt1 out_true, OutputIt2 out_false,
                     Pred pred);
  template<class ExecutionPolicy, class ForwardIt, class ForwardIt1,
           class ForwardIt2, class Pred>
    pair<ForwardIt1, ForwardIt2>
      partition_copy(ExecutionPolicy&& exec,
                     ForwardIt first, ForwardIt last,
                     ForwardIt1 out_true, ForwardIt2 out_false,
                     Pred pred);
 
  namespace ranges {
    template<class I, class O1, class O2>
    struct partition_copy_result {
      [[no_unique_address]] I  in;
      [[no_unique_address]] O1 out1;
      [[no_unique_address]] O2 out2;
 
      template<class II, class OO1, class OO2>
        requires ConvertibleTo<const I&, II> &&
          ConvertibleTo<const O1&, OO1> && ConvertibleTo<const O2&, OO2>
        operator partition_copy_result<II, OO1, OO2>() const & {
          return {in, out1, out2};
        }
 
      template<class II, class OO1, class OO2>
        requires ConvertibleTo<I, II> &&
          ConvertibleTo<O1, OO1> && ConvertibleTo<O2, OO2>
        operator partition_copy_result<II, OO1, OO2>() && {
          return {std::move(in), std::move(out1), std::move(out2)};
        }
    };
 
    template<InputIterator I, Sentinel<I> S,
             WeaklyIncrementable O1, WeaklyIncrementable O2,
             class Proj = identity, IndirectUnaryPredicate<projected<I, Proj>> Pred>
      requires IndirectlyCopyable<I, O1> && IndirectlyCopyable<I, O2>
      constexpr partition_copy_result<I, O1, O2>
        partition_copy(I first, S last, O1 out_true, O2 out_false, Pred pred,
                       Proj proj = {});
    template<InputRange R, WeaklyIncrementable O1, WeaklyIncrementable O2,
             class Proj = identity,
             IndirectUnaryPredicate<projected<iterator_t<R>, Proj>> Pred>
      requires IndirectlyCopyable<iterator_t<R>, O1> &&
               IndirectlyCopyable<iterator_t<R>, O2>
      constexpr partition_copy_result<safe_iterator_t<R>, O1, O2>
        partition_copy(R&& r, O1 out_true, O2 out_false, Pred pred, Proj proj = {});
  }
 
  template<class ForwardIt, class Pred>
    constexpr ForwardIt
      partition_point(ForwardIt first, ForwardIt last, Pred pred);
 
  namespace ranges {
    template<ForwardIterator I, Sentinel<I> S, class Proj = identity,
             IndirectUnaryPredicate<projected<I, Proj>> Pred>
      constexpr I partition_point(I first, S last, Pred pred, Proj proj = {});
    template<ForwardRange R, class Proj = identity,
             IndirectUnaryPredicate<projected<iterator_t<R>, Proj>> Pred>
      constexpr safe_iterator_t<R>
        partition_point(R&& r, Pred pred, Proj proj = {});
  }
 
  // merge:
  template<class InputIt1, class InputIt2, class OutputIt>
    constexpr OutputIt
      merge(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2,
            OutputIt result);
  template<class InputIt1, class InputIt2, class OutputIt, class Compare>
    constexpr OutputIt
      merge(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2,
            OutputIt result, Compare comp);
  template<class ExecutionPolicy, class ForwardIt1, class ForwardIt2, class ForwardIt>
    ForwardIt
      merge(ExecutionPolicy&& exec,
            ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2, ForwardIt2 last2,
            ForwardIt result);
  template<class ExecutionPolicy, class ForwardIt1, class ForwardIt2,
           class ForwardIt, class Compare>
    ForwardIt
      merge(ExecutionPolicy&& exec,
            ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2, ForwardIt2 last2,
            ForwardIt result, Compare comp);
 
  namespace ranges {
    template<class I1, class I2, class O>
    using merge_result = binary_transform_result<I1, I2, O>;
 
    template<InputIterator I1, Sentinel<I1> S1, InputIterator I2, Sentinel<I2> S2,
             WeaklyIncrementable O, class Comp = ranges::less, class Proj1 = identity,
             class Proj2 = identity>
      requires Mergeable<I1, I2, O, Comp, Proj1, Proj2>
      constexpr merge_result<I1, I2, O>
        merge(I1 first1, S1 last1, I2 first2, S2 last2, O result,
              Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {});
    template<InputRange R1, InputRange R2, WeaklyIncrementable O,
             class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity>
      requires Mergeable<iterator_t<R1>, iterator_t<R2>, O, Comp, Proj1, Proj2>
      constexpr merge_result<safe_iterator_t<R1>, safe_iterator_t<R2>, O>
        merge(R1&& r1, R2&& r2, O result,
              Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {});
  }
 
  template<class BidirectionalIt>
    void inplace_merge(BidirectionalIt first,
                       BidirectionalIt middle,
                       BidirectionalIt last);
  template<class BidirectionalIt, class Compare>
    void inplace_merge(BidirectionalIt first,
                       BidirectionalIt middle,
                       BidirectionalIt last, Compare comp);
  template<class ExecutionPolicy, class BidirectionalIt>
    void inplace_merge(ExecutionPolicy&& exec,
                       BidirectionalIt first,
                       BidirectionalIt middle,
                       BidirectionalIt last);
  template<class ExecutionPolicy, class BidirectionalIt, class Compare>
    void inplace_merge(ExecutionPolicy&& exec,
                       BidirectionalIt first,
                       BidirectionalIt middle,
                       BidirectionalIt last, Compare comp);
 
  namespace ranges {
    template<BidirectionalIterator I, Sentinel<I> S, class Comp = ranges::less,
             class Proj = identity>
      requires Sortable<I, Comp, Proj>
      I inplace_merge(I first, I middle, S last, Comp comp = {}, Proj proj = {});
    template<BidirectionalRange R, class Comp = ranges::less, class Proj = identity>
      requires Sortable<iterator_t<R>, Comp, Proj>
      safe_iterator_t<R>
        inplace_merge(R&& r, iterator_t<R> middle, Comp comp = {},
                      Proj proj = {});
  }
 
  // set operations:
  template<class InputIt1, class InputIt2>
    constexpr bool includes(InputIt1 first1, InputIt1 last1,
                            InputIt2 first2, InputIt2 last2);
  template<class InputIt1, class InputIt2, class Compare>
    constexpr bool includes(InputIt1 first1, InputIt1 last1,
                            InputIt2 first2, InputIt2 last2,
                            Compare comp);
  template<class ExecutionPolicy, class ForwardIt1, class ForwardIt2>
    bool includes(ExecutionPolicy&& exec,
                  ForwardIt1 first1, ForwardIt1 last1,
                  ForwardIt2 first2, ForwardIt2 last2);
  template<class ExecutionPolicy, class ForwardIt1, class ForwardIt2,
           class Compare>
    bool includes(ExecutionPolicy&& exec,
                  ForwardIt1 first1, ForwardIt1 last1,
                  ForwardIt2 first2, ForwardIt2 last2,
                  Compare comp);
 
  namespace ranges {
    template<InputIterator I1, Sentinel<I1> S1, InputIterator I2, Sentinel<I2> S2,
             class Proj1 = identity, class Proj2 = identity,
             IndirectStrictWeakOrder<projected<I1, Proj1>, projected<I2, Proj2>> Comp =
               ranges::less>
      constexpr bool includes(I1 first1, S1 last1, I2 first2, S2 last2, Comp comp = {},
                              Proj1 proj1 = {}, Proj2 proj2 = {});
    template<InputRange R1, InputRange R2, class Proj1 = identity,
             class Proj2 = identity,
             IndirectStrictWeakOrder<projected<iterator_t<R1>, Proj1>,
                                     projected<iterator_t<R2>, Proj2>> Comp = ranges::less>
      constexpr bool includes(R1&& r1, R2&& r2, Comp comp = {},
                              Proj1 proj1 = {}, Proj2 proj2 = {});
  }
 
  template<class InputIt1, class InputIt2, class OutputIt>
    constexpr OutputIt
      set_union(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2,
                OutputIt result);
  template<class InputIt1, class InputIt2, class OutputIt, class Compare>
    constexpr OutputIt
                set_union(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2,
                OutputIt result, Compare comp);
  template<class ExecutionPolicy, class ForwardIt1, class ForwardIt2,
           class ForwardIt>
    ForwardIt
      set_union(ExecutionPolicy&& exec,
                ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2, ForwardIt2 last2,
                ForwardIt result);
  template<class ExecutionPolicy, class ForwardIt1, class ForwardIt2,
           class ForwardIt, class Compare>
    ForwardIt
      set_union(ExecutionPolicy&& exec,
                ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2, ForwardIt2 last2,
                ForwardIt result, Compare comp);
 
  namespace ranges {
    template<class I1, class I2, class O>
    using set_union_result = binary_transform_result<I1, I2, O>;
 
    template<InputIterator I1, Sentinel<I1> S1, InputIterator I2, Sentinel<I2> S2,
             WeaklyIncrementable O, class Comp = ranges::less,
             class Proj1 = identity, class Proj2 = identity>
      requires Mergeable<I1, I2, O, Comp, Proj1, Proj2>
      constexpr set_union_result<I1, I2, O>
        set_union(I1 first1, S1 last1, I2 first2, S2 last2, O result, Comp comp = {},
                  Proj1 proj1 = {}, Proj2 proj2 = {});
    template<InputRange R1, InputRange R2, WeaklyIncrementable O,
             class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity>
      requires Mergeable<iterator_t<R1>, iterator_t<R2>, O, Comp, Proj1, Proj2>
      constexpr set_union_result<safe_iterator_t<R1>, safe_iterator_t<R2>, O>
        set_union(R1&& r1, R2&& r2, O result, Comp comp = {},
                  Proj1 proj1 = {}, Proj2 proj2 = {});
  }
 
  template<class InputIt1, class InputIt2, class OutputIt>
    constexpr OutputIt
      set_intersection(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2,
                       OutputIt result);
  template<class InputIt1, class InputIt2, class OutputIt, class Compare>
    constexpr OutputIt
      set_intersection(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2,
                       OutputIt result, Compare comp);
  template<class ExecutionPolicy, class ForwardIt1, class ForwardIt2,
           class ForwardIt>
    ForwardIt
      set_intersection(ExecutionPolicy&& exec,
                       ForwardIt1 first1, ForwardIt1 last1,
                       ForwardIt2 first2, ForwardIt2 last2,
                       ForwardIt result);
  template<class ExecutionPolicy, class ForwardIt1, class ForwardIt2,
           class ForwardIt, class Compare>
    ForwardIt
      set_intersection(ExecutionPolicy&& exec,
                       ForwardIt1 first1, ForwardIt1 last1,
                       ForwardIt2 first2, ForwardIt2 last2,
                       ForwardIt result, Compare comp);
 
  namespace ranges {
    template<class I1, class I2, class O>
    using set_intersection_result = binary_transform_result<I1, I2, O>;
 
    template<InputIterator I1, Sentinel<I1> S1, InputIterator I2, Sentinel<I2> S2,
             WeaklyIncrementable O, class Comp = ranges::less,
             class Proj1 = identity, class Proj2 = identity>
      requires Mergeable<I1, I2, O, Comp, Proj1, Proj2>
      constexpr set_intersection_result<I1, I2, O>
        set_intersection(I1 first1, S1 last1, I2 first2, S2 last2, O result,
                         Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {});
    template<InputRange R1, InputRange R2, WeaklyIncrementable O,
             class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity>
      requires Mergeable<iterator_t<R1>, iterator_t<R2>, O, Comp, Proj1, Proj2>
      constexpr set_intersection_result<safe_iterator_t<R1>, safe_iterator_t<R2>, O>
        set_intersection(R1&& r1, R2&& r2, O result,
                         Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {});
  }
 
  template<class InputIt1, class InputIt2, class OutputIt>
    constexpr OutputIt
      set_difference(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2,
                     OutputIt result);
  template<class InputIt1, class InputIt2, class OutputIt, class Compare>
    constexpr OutputIt
      set_difference(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2,
                     OutputIt result, Compare comp);
  template<class ExecutionPolicy, class ForwardIt1, class ForwardIt2,
           class ForwardIt>
    ForwardIt
      set_difference(ExecutionPolicy&& exec,
                     ForwardIt1 first1, ForwardIt1 last1,
                     ForwardIt2 first2, ForwardIt2 last2,
                     ForwardIt result);
  template<class ExecutionPolicy, class ForwardIt1, class ForwardIt2,
           class ForwardIt, class Compare>
    ForwardIt
      set_difference(ExecutionPolicy&& exec,
                     ForwardIt1 first1, ForwardIt1 last1,
                     ForwardIt2 first2, ForwardIt2 last2,
                     ForwardIt result, Compare comp);
 
  namespace ranges {
    template<class I, class O>
    using set_difference_result = copy_result<I, O>;
 
    template<InputIterator I1, Sentinel<I1> S1, InputIterator I2, Sentinel<I2> S2,
             WeaklyIncrementable O, class Comp = ranges::less,
             class Proj1 = identity, class Proj2 = identity>
      requires Mergeable<I1, I2, O, Comp, Proj1, Proj2>
      constexpr set_difference_result<I1, O>
        set_difference(I1 first1, S1 last1, I2 first2, S2 last2, O result,
                       Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {});
    template<InputRange R1, InputRange R2, WeaklyIncrementable O,
             class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity>
      requires Mergeable<iterator_t<R1>, iterator_t<R2>, O, Comp, Proj1, Proj2>
      constexpr set_difference_result<safe_iterator_t<R1>, O>
        set_difference(R1&& r1, R2&& r2, O result,
                       Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {});
  }
 
  template<class InputIt1, class InputIt2, class OutputIt>
    constexpr OutputIt
      set_symmetric_difference(InputIt1 first1, InputIt1 last1,
                               InputIt2 first2, InputIt2 last2,
                               OutputIt result);
  template<class InputIt1, class InputIt2, class OutputIt, class Compare>
    constexpr OutputIt
      set_symmetric_difference(InputIt1 first1, InputIt1 last1,
                               InputIt2 first2, InputIt2 last2,
                               OutputIt result, Compare comp);
  template<class ExecutionPolicy, class ForwardIt1, class ForwardIt2,
           class ForwardIt>
    ForwardIt
      set_symmetric_difference(ExecutionPolicy&& exec,
                               ForwardIt1 first1, ForwardIt1 last1,
                               ForwardIt2 first2, ForwardIt2 last2,
                               ForwardIt result);
  template<class ExecutionPolicy, class ForwardIt1, class ForwardIt2,
           class ForwardIt, class Compare>
    ForwardIt
      set_symmetric_difference(ExecutionPolicy&& exec,
                               ForwardIt1 first1, ForwardIt1 last1,
                               ForwardIt2 first2, ForwardIt2 last2,
                               ForwardIt result, Compare comp);
 
  namespace ranges {
    template<class I1, class I2, class O>
    using set_symmetric_difference_result = binary_transform_result<I1, I2, O>;
 
    template<InputIterator I1, Sentinel<I1> S1, InputIterator I2, Sentinel<I2> S2,
             WeaklyIncrementable O, class Comp = ranges::less,
             class Proj1 = identity, class Proj2 = identity>
      requires Mergeable<I1, I2, O, Comp, Proj1, Proj2>
      constexpr set_symmetric_difference_result<I1, I2, O>
        set_symmetric_difference(I1 first1, S1 last1, I2 first2, S2 last2, O result,
                                 Comp comp = {}, Proj1 proj1 = {},
                                 Proj2 proj2 = {});
    template<InputRange R1, InputRange R2, WeaklyIncrementable O,
             class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity>
      requires Mergeable<iterator_t<R1>, iterator_t<R2>, O, Comp, Proj1, Proj2>
      constexpr
        set_symmetric_difference_result<safe_iterator_t<R1>, safe_iterator_t<R2>, O>
        set_symmetric_difference(R1&& r1, R2&& r2, O result, Comp comp = {},
                                 Proj1 proj1 = {}, Proj2 proj2 = {});
  }
 
  // heap operations:
  template<class RandomAccessIt>
    constexpr void push_heap(RandomAccessIt first, RandomAccessIt last);
  template<class RandomAccessIt, class Compare>
    constexpr void push_heap(RandomAccessIt first, RandomAccessIt last, Compare comp);
 
  namespace ranges {
    template<RandomAccessIterator I, Sentinel<I> S, class Comp = ranges::less,
             class Proj = identity>
      requires Sortable<I, Comp, Proj>
      constexpr I
        push_heap(I first, S last, Comp comp = {}, Proj proj = {});
    template<RandomAccessRange R, class Comp = ranges::less, class Proj = identity>
      requires Sortable<iterator_t<R>, Comp, Proj>
      constexpr safe_iterator_t<R>
        push_heap(R&& r, Comp comp = {}, Proj proj = {});
  }
 
  template<class RandomAccessIt>
    constexpr void pop_heap(RandomAccessIt first, RandomAccessIt last);
  template<class RandomAccessIt, class Compare>
    constexpr void pop_heap(RandomAccessIt first, RandomAccessIt last, Compare comp);
 
  namespace ranges {
    template<RandomAccessIterator I, Sentinel<I> S, class Comp = ranges::less,
             class Proj = identity>
      requires Sortable<I, Comp, Proj>
      constexpr I
        pop_heap(I first, S last, Comp comp = {}, Proj proj = {});
    template<RandomAccessRange R, class Comp = ranges::less, class Proj = identity>
      requires Sortable<iterator_t<R>, Comp, Proj>
      constexpr safe_iterator_t<R>
        pop_heap(R&& r, Comp comp = {}, Proj proj = {});
  }
 
  template<class RandomAccessIt>
    constexpr void make_heap(RandomAccessIt first, RandomAccessIt last);
  template<class RandomAccessIt, class Compare>
    constexpr void make_heap(RandomAccessIt first, RandomAccessIt last, Compare comp);
 
  namespace ranges {
    template<RandomAccessIterator I, Sentinel<I> S, class Comp = ranges::less,
             class Proj = identity>
      requires Sortable<I, Comp, Proj>
      constexpr I
        make_heap(I first, S last, Comp comp = {}, Proj proj = {});
    template<RandomAccessRange R, class Comp = ranges::less, class Proj = identity>
      requires Sortable<iterator_t<R>, Comp, Proj>
      constexpr safe_iterator_t<R>
        make_heap(R&& r, Comp comp = {}, Proj proj = {});
  }
 
  template<class RandomAccessIt>
    constexpr void sort_heap(RandomAccessIt first, RandomAccessIt last);
  template<class RandomAccessIt, class Compare>
    constexpr void sort_heap(RandomAccessIt first, RandomAccessIt last, Compare comp);
 
  namespace ranges {
    template<RandomAccessIterator I, Sentinel<I> S, class Comp = ranges::less,
             class Proj = identity>
      requires Sortable<I, Comp, Proj>
      constexpr I
        sort_heap(I first, S last, Comp comp = {}, Proj proj = {});
    template<RandomAccessRange R, class Comp = ranges::less, class Proj = identity>
      requires Sortable<iterator_t<R>, Comp, Proj>
      constexpr safe_iterator_t<R>
        sort_heap(R&& r, Comp comp = {}, Proj proj = {});
  }
 
  template<class RandomAccessIt>
    constexpr bool is_heap(RandomAccessIt first, RandomAccessIt last);
  template<class RandomAccessIt, class Compare>
    constexpr bool is_heap(RandomAccessIt first, RandomAccessIt last, Compare comp);
  template<class ExecutionPolicy, class RandomAccessIt>
    bool is_heap(ExecutionPolicy&& exec,
                 RandomAccessIt first, RandomAccessIt last);
  template<class ExecutionPolicy, class RandomAccessIt, class Compare>
    bool is_heap(ExecutionPolicy&& exec,
                 RandomAccessIt first, RandomAccessIt last, Compare comp);
 
  namespace ranges {
    template<RandomAccessIterator I, Sentinel<I> S, class Proj = identity,
             IndirectStrictWeakOrder<projected<I, Proj>> Comp = ranges::less>
      constexpr bool is_heap(I first, S last, Comp comp = {}, Proj proj = {});
    template<RandomAccessRange R, class Proj = identity,
             IndirectStrictWeakOrder<projected<iterator_t<R>, Proj>> Comp = ranges::less>
      constexpr bool is_heap(R&& r, Comp comp = {}, Proj proj = {});
  }
 
  template<class RandomAccessIt>
    constexpr RandomAccessIt
      is_heap_until(RandomAccessIt first, RandomAccessIt last);
  template<class RandomAccessIt, class Compare>
    constexpr RandomAccessIt
      is_heap_until(RandomAccessIt first, RandomAccessIt last, Compare comp);
  template<class ExecutionPolicy, class RandomAccessIt>
    RandomAccessIt
      is_heap_until(ExecutionPolicy&& exec,
                    RandomAccessIt first, RandomAccessIt last);
  template<class ExecutionPolicy, class RandomAccessIt, class Compare>
    RandomAccessIt
      is_heap_until(ExecutionPolicy&& exec,
                    RandomAccessIt first, RandomAccessIt last, Compare comp);
 
  namespace ranges {
    template<RandomAccessIterator I, Sentinel<I> S, class Proj = identity,
             IndirectStrictWeakOrder<projected<I, Proj>> Comp = ranges::less>
      constexpr I is_heap_until(I first, S last, Comp comp = {}, Proj proj = {});
    template<RandomAccessRange R, class Proj = identity,
             IndirectStrictWeakOrder<projected<iterator_t<R>, Proj>> Comp = ranges::less>
      constexpr safe_iterator_t<R>
        is_heap_until(R&& r, Comp comp = {}, Proj proj = {});
  }
 
  // minimum and maximum:
  template<class T> constexpr const T& min(const T& a, const T& b);
  template<class T, class Compare>
    constexpr const T& min(const T& a, const T& b, Compare comp);
  template<class T>
    constexpr T min(initializer_list<T> t);
  template<class T, class Compare>
    constexpr T min(initializer_list<T> t, Compare comp);
 
  namespace ranges {
    template<class T, class Proj = identity,
             IndirectStrictWeakOrder<projected<const T*, Proj>> Comp = ranges::less>
      constexpr const T& min(const T& a, const T& b, Comp comp = {}, Proj proj = {});
    template<Copyable T, class Proj = identity,
             IndirectStrictWeakOrder<projected<const T*, Proj>> Comp = ranges::less>
      constexpr T min(initializer_list<T> r, Comp comp = {}, Proj proj = {});
    template<InputRange R, class Proj = identity,
             IndirectStrictWeakOrder<projected<iterator_t<R>, Proj>> Comp = ranges::less>
      requires IndirectlyCopyableStorable<iterator_t<R>, iter_value_t<iterator_t<R>>*>
      constexpr iter_value_t<iterator_t<R>>
        min(R&& r, Comp comp = {}, Proj proj = {});
  }
 
  template<class T> constexpr const T& max(const T& a, const T& b);
  template<class T, class Compare>
    constexpr const T& max(const T& a, const T& b, Compare comp);
  template<class T>
    constexpr T max(initializer_list<T> t);
  template<class T, class Compare>
    constexpr T max(initializer_list<T> t, Compare comp);
 
  namespace ranges {
    template<class T, class Proj = identity,
             IndirectStrictWeakOrder<projected<const T*, Proj>> Comp = ranges::less>
      constexpr const T& max(const T& a, const T& b, Comp comp = {}, Proj proj = {});
    template<Copyable T, class Proj = identity,
             IndirectStrictWeakOrder<projected<const T*, Proj>> Comp = ranges::less>
      constexpr T max(initializer_list<T> r, Comp comp = {}, Proj proj = {});
    template<InputRange R, class Proj = identity,
             IndirectStrictWeakOrder<projected<iterator_t<R>, Proj>> Comp = ranges::less>
      requires IndirectlyCopyableStorable<iterator_t<R>, iter_value_t<iterator_t<R>>*>
      constexpr iter_value_t<iterator_t<R>>
        max(R&& r, Comp comp = {}, Proj proj = {});
  }
 
  template<class T> constexpr pair<const T&, const T&> minmax(const T& a, const T& b);
  template<class T, class Compare>
    constexpr pair<const T&, const T&> minmax(const T& a, const T& b, Compare comp);
  template<class T>
    constexpr pair<T, T> minmax(initializer_list<T> t);
  template<class T, class Compare>
    constexpr pair<T, T> minmax(initializer_list<T> t, Compare comp);
 
  namespace ranges {
    template<class T>
    struct minmax_result {
      [[no_unique_address]] T min;
      [[no_unique_address]] T max;
 
      template<class T2>
        requires ConvertibleTo<const T&, T2>
        operator minmax_result<T2>() const & {
          return {min, max};
        }
 
      template<class T2>
        requires ConvertibleTo<T, T2>
        operator minmax_result<T2>() && {
          return {std::move(min), std::move(max)};
        }
    };
 
    template<class T, class Proj = identity,
             IndirectStrictWeakOrder<projected<const T*, Proj>> Comp = ranges::less>
      constexpr minmax_result<const T&>
        minmax(const T& a, const T& b, Comp comp = {}, Proj proj = {});
    template<Copyable T, class Proj = identity,
             IndirectStrictWeakOrder<projected<const T*, Proj>> Comp = ranges::less>
      constexpr minmax_result<T>
        minmax(initializer_list<T> r, Comp comp = {}, Proj proj = {});
    template<InputRange R, class Proj = identity,
             IndirectStrictWeakOrder<projected<iterator_t<R>, Proj>> Comp = ranges::less>
      requires IndirectlyCopyableStorable<iterator_t<R>, iter_value_t<iterator_t<R>>*>
      constexpr minmax_result<iter_value_t<iterator_t<R>>>
        minmax(R&& r, Comp comp = {}, Proj proj = {});
  }
 
  template<class ForwardIt>
    constexpr ForwardIt min_element(ForwardIt first, ForwardIt last);
  template<class ForwardIt, class Compare>
    constexpr ForwardIt min_element(ForwardIt first, ForwardIt last,
                                          Compare comp);
  template<class ExecutionPolicy, class ForwardIt>
    ForwardIt min_element(ExecutionPolicy&& exec,
                          ForwardIt first, ForwardIt last);
  template<class ExecutionPolicy, class ForwardIt, class Compare>
    ForwardIt min_element(ExecutionPolicy&& exec,
                          ForwardIt first, ForwardIt last, Compare comp);
 
  namespace ranges {
    template<ForwardIterator I, Sentinel<I> S, class Proj = identity,
             IndirectStrictWeakOrder<projected<I, Proj>> Comp = ranges::less>
      constexpr I min_element(I first, S last, Comp comp = {}, Proj proj = {});
    template<ForwardRange R, class Proj = identity,
             IndirectStrictWeakOrder<projected<iterator_t<R>, Proj>> Comp = ranges::less>
      constexpr safe_iterator_t<R>
        min_element(R&& r, Comp comp = {}, Proj proj = {});
  }
 
  template<class ForwardIt>
    constexpr ForwardIt max_element(ForwardIt first, ForwardIt last);
  template<class ForwardIt, class Compare>
    constexpr ForwardIt max_element(ForwardIt first, ForwardIt last, Compare comp);
  template<class ExecutionPolicy, class ForwardIt>
    ForwardIt max_element(ExecutionPolicy&& exec,
                          ForwardIt first, ForwardIt last);
  template<class ExecutionPolicy, class ForwardIt, class Compare>
    ForwardIt max_element(ExecutionPolicy&& exec,
                          ForwardIt first, ForwardIt last, Compare comp);
 
 namespace ranges {
    template<ForwardIterator I, Sentinel<I> S, class Proj = identity,
             IndirectStrictWeakOrder<projected<I, Proj>> Comp = ranges::less>
      constexpr I max_element(I first, S last, Comp comp = {}, Proj proj = {});
    template<ForwardRange R, class Proj = identity,
             IndirectStrictWeakOrder<projected<iterator_t<R>, Proj>> Comp = ranges::less>
      constexpr safe_iterator_t<R>
        max_element(R&& r, Comp comp = {}, Proj proj = {});
  }
 
  template<class ForwardIt>
    constexpr pair<ForwardIt, ForwardIt>
      minmax_element(ForwardIt first, ForwardIt last);
  template<class ForwardIt, class Compare>
    constexpr pair<ForwardIt, ForwardIt>
      minmax_element(ForwardIt first, ForwardIt last, Compare comp);
  template<class ExecutionPolicy, class ForwardIt>
    pair<ForwardIt, ForwardIt>
      minmax_element(ExecutionPolicy&& exec,
                     ForwardIt first, ForwardIt last);
  template<class ExecutionPolicy, class ForwardIt, class Compare>
    pair<ForwardIt, ForwardIt>
      minmax_element(ExecutionPolicy&& exec,
                     ForwardIt first, ForwardIt last, Compare comp);
 
  namespace ranges {
    template<class I>
    using minmax_element_result = minmax_result<I>;
 
    template<ForwardIterator I, Sentinel<I> S, class Proj = identity,
             IndirectStrictWeakOrder<projected<I, Proj>> Comp = ranges::less>
      constexpr minmax_element_result<I>
        minmax_element(I first, S last, Comp comp = {}, Proj proj = {});
    template<ForwardRange R, class Proj = identity,
             IndirectStrictWeakOrder<projected<iterator_t<R>, Proj>> Comp = ranges::less>
      constexpr minmax_element_result<safe_iterator_t<R>>
        minmax_element(R&& r, Comp comp = {}, Proj proj = {});
  }
 
  // bounded value:
  template<class T>
    constexpr const T& clamp(const T& v, const T& lo, const T& hi);
  template<class T, class Compare>
    constexpr const T& clamp(const T& v, const T& lo, const T& hi, Compare comp);
 
  // lexicographical comparison:
  template<class InputIt1, class InputIt2>
    constexpr bool
      lexicographical_compare(InputIt1 first1, InputIt1 last1,
                              InputIt2 first2, InputIt2 last2);
  template<class InputIt1, class InputIt2, class Compare>
    constexpr bool
      lexicographical_compare(InputIt1 first1, InputIt1 last1,
                              InputIt2 first2, InputIt2 last2,
                              Compare comp);
  template<class ExecutionPolicy, class ForwardIt1, class ForwardIt2>
    bool
      lexicographical_compare(ExecutionPolicy&& exec,
                              ForwardIt1 first1, ForwardIt1 last1,
                              ForwardIt2 first2, ForwardIt2 last2);
  template<class ExecutionPolicy, class ForwardIt1, class ForwardIt2,
           class Compare>
    bool
      lexicographical_compare(ExecutionPolicy&& exec,
                              ForwardIt1 first1, ForwardIt1 last1,
                              ForwardIt2 first2, ForwardIt2 last2,
                              Compare comp);
 
  namespace ranges {
    template<InputIterator I1, Sentinel<I1> S1, InputIterator I2, Sentinel<I2> S2,
             class Proj1 = identity, class Proj2 = identity,
             IndirectStrictWeakOrder<projected<I1, Proj1>, projected<I2, Proj2>> Comp =
               ranges::less>
      constexpr bool
        lexicographical_compare(I1 first1, S1 last1, I2 first2, S2 last2,
                                Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {});
    template<InputRange R1, InputRange R2, class Proj1 = identity,
             class Proj2 = identity,
             IndirectStrictWeakOrder<projected<iterator_t<R1>, Proj1>,
                                     projected<iterator_t<R2>, Proj2>> Comp = ranges::less>
      constexpr bool
        lexicographical_compare(R1&& r1, R2&& r2, Comp comp = {},
                                Proj1 proj1 = {}, Proj2 proj2 = {});
  }
 
  // three-way comparison algorithms:
  template<class T, class U>
    constexpr auto compare_3way(const T& a, const U& b);
  template<class InputIt1, class InputIt2, class Cmp>
    constexpr auto
      lexicographical_compare_3way(InputIt1 b1, InputIt1 e1, InputIt2 b2, InputIt2 e2,
                                   Cmp comp)
        -> common_comparison_category_t<decltype(comp(*b1, *b2)), strong_ordering>;
  template<class InputIt1, class InputIt2>
    constexpr auto
      lexicographical_compare_3way(InputIt1 b1, InputIt1 e1, InputIt2 b2, InputIt2 e2);
 
  // permutations:
  template<class BidirectionalIt>
    constexpr bool next_permutation(BidirectionalIt first, BidirectionalIt last);
  template<class BidirectionalIt, class Compare>
    constexpr bool next_permutation(BidirectionalIt first, BidirectionalIt last,
                                    Compare comp);
 
  namespace ranges {
    template<BidirectionalIterator I, Sentinel<I> S, class Comp = ranges::less,
             class Proj = identity>
      requires Sortable<I, Comp, Proj>
      constexpr bool
        next_permutation(I first, S last, Comp comp = {}, Proj proj = {});
    template<BidirectionalRange R, class Comp = ranges::less,
             class Proj = identity>
      requires Sortable<iterator_t<R>, Comp, Proj>
      constexpr bool
        next_permutation(R&& r, Comp comp = {}, Proj proj = {});
  }
 
  template<class BidirectionalIt>
    constexpr bool prev_permutation(BidirectionalIt first, BidirectionalIt last);
  template<class BidirectionalIt, class Compare>
    constexpr bool prev_permutation(BidirectionalIt first, BidirectionalIt last,
                                    Compare comp);
 
  namespace ranges {
    template<BidirectionalIterator I, Sentinel<I> S, class Comp = ranges::less,
             class Proj = identity>
      requires Sortable<I, Comp, Proj>
      constexpr bool
        prev_permutation(I first, S last, Comp comp = {}, Proj proj = {});
    template<BidirectionalRange R, class Comp = ranges::less,
             class Proj = identity>
      requires Sortable<iterator_t<R>, Comp, Proj>
      constexpr bool
        prev_permutation(R&& r, Comp comp = {}, Proj proj = {});
  }
}

© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
http://en.cppreference.com/w/cpp/header/algorithm