名前空間
変種
操作

標準ライブラリヘッダ <algorithm>

提供: cppreference.com
< cpp‎ | header
 
 
 

このヘッダはアルゴリズムライブラリの一部です。

目次

[編集] 関数

非変更シーケンス操作
(C++11)(C++11)(C++11)
述語が指定範囲の要素のすべてに対して true を返すかどうか、いずれかに対して true を返すかどうか、またはいずれに対しても true を返さないかどうか、調べます
(関数テンプレート) [edit]
指定範囲の要素に関数を適用します
(関数テンプレート) [edit]
指定個数の要素に関数を適用します
(関数テンプレート) [edit]
一定の基準を満たす要素の数を返します
(関数テンプレート) [edit]
2つの範囲が異なる最初の位置を探します
(関数テンプレート) [edit]
一定の基準を満たす最初の要素を探します
(関数テンプレート) [edit]
指定された要素の並びが現れる最後の位置を探します
(関数テンプレート) [edit]
指定された要素のいずれかが現れる位置を探します
(関数テンプレート) [edit]
同じ要素 (または指定された述語を満たす要素) 2つが隣接している最初の位置を探します
(関数テンプレート) [edit]
指定範囲の要素に対して検索を行います
(関数テンプレート) [edit]
指定個数の連続する指定要素を指定範囲から検索します
(関数テンプレート) [edit]
変更シーケンス操作
指定範囲の要素を新しい位置にコピーします
(関数テンプレート) [edit]
(C++11)
指定個数の要素を新しい位置にコピーします
(関数テンプレート) [edit]
指定範囲の要素を後ろからコピーします
(関数テンプレート) [edit]
(C++11)
指定範囲の要素を新しい位置にムーブします
(関数テンプレート) [edit]
指定範囲の要素を後ろからムーブします
(関数テンプレート) [edit]
指定された要素を範囲内の全要素にコピー代入します
(関数テンプレート) [edit]
指定された要素を指定個数の要素にコピー代入します
(関数テンプレート) [edit]
指定範囲の要素に関数を適用します
(関数テンプレート) [edit]
関数を連続的に呼び出した結果を指定範囲の全要素に代入します
(関数テンプレート) [edit]
関数を連続的に呼び出した結果を指定個数の要素に代入します
(関数テンプレート) [edit]
一定の基準を満たす要素を削除します
(関数テンプレート) [edit]
指定範囲の要素から一定の基準を満たすものを除いてコピーします
(関数テンプレート) [edit]
一定の基準を満たすすべての値を別の値に置き換えます
(関数テンプレート) [edit]
一定の基準を満たす要素を別の値に置き換えながら指定範囲をコピーします
(関数テンプレート) [edit]
2つのオブジェクトの値を入れ替えます
(関数テンプレート) [edit]
2つの範囲の要素を入れ替えます
(関数テンプレート) [edit]
2つのイテレータが指す要素を入れ替えます
(関数テンプレート) [edit]
指定範囲の要素の順序を反転させます
(関数テンプレート) [edit]
指定範囲の要素の順序を反転させたコピーを作成します
(関数テンプレート) [edit]
指定範囲の要素の順序を回転させます
(関数テンプレート) [edit]
指定範囲の要素の順序を回転させたコピーを作成します
(関数テンプレート) [edit]
範囲内の要素をシフトします
(関数テンプレート) [edit]
(C++17未満)(C++11)
指定範囲の要素をランダムに並べ替えます
(関数テンプレート) [edit]
(C++17)
指定個数の要素をランダムに選択します
(関数テンプレート) [edit]
指定範囲の連続している重複要素を削除します
(関数テンプレート) [edit]
指定範囲の要素の連続している重複要素が含まれないコピーを作成します
(関数テンプレート) [edit]
分割操作
指定範囲が指定した述語で分割されているかどうか調べます
(関数テンプレート) [edit]
指定範囲の要素を2つのグループに分割します
(関数テンプレート) [edit]
指定範囲の要素を2つのグループに分割しながらコピーします
(関数テンプレート) [edit]
相対的な順序を維持しながら要素を2つのグループに分割します
(関数テンプレート) [edit]
分割された範囲の分割点を探します
(関数テンプレート) [edit]
ソート操作
(C++11)
指定範囲が昇順にソートされているか調べます
(関数テンプレート) [edit]
最も大きなソート済みの部分範囲を探します
(関数テンプレート) [edit]
指定範囲を昇順にソートします
(関数テンプレート) [edit]
指定範囲の最初の N 個の要素をソートします
(関数テンプレート) [edit]
指定範囲の最初の N 個の要素がソートされたコピーを作成します
(関数テンプレート) [edit]
等しい要素間の順序を維持しながら指定範囲の要素をソートします
(関数テンプレート) [edit]
指定された要素で分割されるように指定範囲を部分ソートします
(関数テンプレート) [edit]
二分探索操作 (ソート済み範囲用)
指定された値より小さくない最初の要素を指すイテレータを返します
(関数テンプレート) [edit]
指定された値より大きい最初の要素へのイテレータを返します
(関数テンプレート) [edit]
指定範囲に要素が存在するかどうか調べます
(関数テンプレート) [edit]
特定のキーに一致する要素の範囲を返します
(関数テンプレート) [edit]
ソート済み範囲に対するその他の操作
2つのソート済み範囲をマージします
(関数テンプレート) [edit]
2つのソート済み範囲をその場でマージします
(関数テンプレート) [edit]
集合演算 (ソート済み範囲用)
ある集合が別の集合の部分集合であるかどうか調べます
(関数テンプレート) [edit]
2つの集合の差を計算します
(関数テンプレート) [edit]
2つの集合の交叉を計算します
(関数テンプレート) [edit]
2つの集合の対称差を計算します
(関数テンプレート) [edit]
2つの集合の和を計算します
(関数テンプレート) [edit]
ヒープ操作
(C++11)
指定範囲が最大ヒープであるかどうか調べます
(関数テンプレート) [edit]
最大ヒープである最も大きな部分範囲を探します
(関数テンプレート) [edit]
指定範囲の要素から最大ヒープを作成します
(関数テンプレート) [edit]
最大ヒープに要素を追加します
(関数テンプレート) [edit]
最大ヒープから最も大きな要素を削除します
(関数テンプレート) [edit]
最大ヒープを昇順にソートされた要素の範囲に変換します
(関数テンプレート) [edit]
最小/最大演算
指定された値の大きい方を返します
(関数テンプレート) [edit]
指定範囲の最も大きな要素を返します
(関数テンプレート) [edit]
指定された値の小さい方を返します
(関数テンプレート) [edit]
指定範囲の最も小さな要素を返します
(関数テンプレート) [edit]
(C++11)
2つの要素の小さい方と大きい方を返します
(関数テンプレート) [edit]
指定範囲の最も小さな要素と最も大きな要素を返します
(関数テンプレート) [edit]
(C++17)
値を境界値の間にクランプします
(関数テンプレート) [edit]
比較演算
2つの要素集合が同じかどうか調べます
(関数テンプレート) [edit]
ある範囲が別の範囲より辞書的に小さいかどうか調べます
(関数テンプレート) [edit]
三方比較を使用して2つの値を比較します
(関数テンプレート) [edit]
三方比較を使用して2つの範囲を比較します
(関数テンプレート) [edit]
順列操作
あるシーケンスが別のシーケンスの順列並び替えになっているかどうか調べます
(関数テンプレート) [edit]
指定範囲の要素より辞書的に大きな次の順列を生成します
(関数テンプレート) [edit]
指定範囲の要素より辞書的に小さな次の順列を生成します
(関数テンプレート) [edit]

[編集] ニーブロイド

名前空間 std::ranges で定義
非変更シーケンス操作
指定範囲内の要素のすべて、1個以上、または0個に対して述語が true を返すかどうか調べます
(ニーブロイド) [edit]
指定範囲の要素に関数を適用します
(ニーブロイド) [edit]
特定の基準を満たす要素の数を返します
(ニーブロイド) [edit]
2つの範囲が異なる最初の位置を探します
(ニーブロイド) [edit]
特定の基準を満たす最初の要素を探します
(ニーブロイド) [edit]
特定の範囲内の要素の最後のシーケンスを探します
(ニーブロイド) [edit]
要素の集合のいずれかを検索します
(ニーブロイド) [edit]
最初の等しい (または指定の述語を満たす) 隣接する2つの項目を探します
(ニーブロイド) [edit]
指定範囲の要素に対して検索を行います
(ニーブロイド) [edit]
指定個数の連続する指定要素を指定範囲から検索します
(ニーブロイド) [edit]
変更シーケンス操作
指定範囲の要素を新しい位置にコピーします
(ニーブロイド) [edit]
指定個数の要素を新しい位置にコピーします
(ニーブロイド) [edit]
指定範囲の要素を逆順にコピーします
(ニーブロイド) [edit]
指定範囲の要素を新しい位置にムーブします
(ニーブロイド) [edit]
指定範囲の要素を新しい位置に逆順でムーブします
(ニーブロイド) [edit]
特定の値を指定範囲の要素に代入します
(ニーブロイド) [edit]
値を指定個数の要素に代入します
(ニーブロイド) [edit]
指定範囲の要素に関数を適用します
(ニーブロイド) [edit]
関数の結果を指定範囲に保存します
(ニーブロイド) [edit]
関数の N 回の適用の結果を保存します
(ニーブロイド) [edit]
特定の基準を満たす要素を削除します
(ニーブロイド) [edit]
特定の基準を満たす要素を省きながら指定範囲の要素をコピーします
(ニーブロイド) [edit]
特定の基準を満たすすべての値を別の値に置き換えます
(ニーブロイド) [edit]
特定の基準を満たす要素を別の値で置換しながら範囲をコピーします
(ニーブロイド) [edit]
2つの範囲の要素を入れ替えます
(ニーブロイド) [edit]
指定範囲の要素の順序を反転させます
(ニーブロイド) [edit]
指定範囲の逆順のコピーを作成します
(ニーブロイド) [edit]
指定範囲の要素の順序を回転させます
(ニーブロイド) [edit]
指定範囲の要素をコピーして回転させます
(ニーブロイド) [edit]
措定範囲の要素をランダムに並べ替えます
(ニーブロイド) [edit]
指定範囲の連続する重複要素を削除します
(ニーブロイド) [edit]
連続する重複を含まない要素の範囲のコピーを作成します
(ニーブロイド) [edit]
分割操作
指定範囲が指定の述語で分割されているかどうか判定します
(ニーブロイド) [edit]
指定範囲の要素を2つのグループに分割します
(ニーブロイド) [edit]
要素を2つのグループに分割しながら指定範囲をコピーします
(ニーブロイド) [edit]
相対順序を維持しながら要素を2つのグループに分割します
(ニーブロイド) [edit]
分割済み範囲の分割点を探します
(ニーブロイド) [edit]
ソート操作
指定範囲が昇順にソートされているかどうか調べます
(ニーブロイド) [edit]
最も大きなソート済み部分範囲を探します
(ニーブロイド) [edit]
指定範囲を昇順にソートします
(ニーブロイド) [edit]
指定範囲の最初の N 個の要素をソートします
(ニーブロイド) [edit]
指定範囲の要素をコピーして部分的にソートします
(ニーブロイド) [edit]
等しい要素間の順序を維持しながら指定範囲の要素をソートします
(ニーブロイド) [edit]
指定要素で分割されることを保証しながら指定範囲を部分的にソートします
(ニーブロイド) [edit]
二分探索操作 (ソート済み範囲用)
指定された値より小さくない最初の要素を指すイテレータを返します
(ニーブロイド) [edit]
特定の値より大きい最初の要素を指すイテレータを返します
(ニーブロイド) [edit]
特定の範囲に要素が存在するかどうか判定します
(ニーブロイド) [edit]
特定のキーにマッチする要素の範囲を返します
(ニーブロイド) [edit]
ソート済み範囲用のその他の操作
2つのソート済み範囲をマージします
(ニーブロイド) [edit]
2つの順序付き範囲をその場でマージします
(ニーブロイド) [edit]
集合操作 (ソート済み範囲用)
ある集合が別の集合の部分集合であれば true を返します
(ニーブロイド) [edit]
2つの集合の差を計算します
(ニーブロイド) [edit]
2つの集合の交差を計算します
(ニーブロイド) [edit]
2つの集合の対称差を計算します
(ニーブロイド) [edit]
2つの集合の和を計算します
(ニーブロイド) [edit]
ヒープ操作
指定された範囲が最大ヒープかどうか調べます
(ニーブロイド) [edit]
最大ヒープである最も大きな部分範囲を探します
(ニーブロイド) [edit]
指定範囲の要素から最大ヒープを作成します
(ニーブロイド) [edit]
最大ヒープに要素を追加します
(ニーブロイド) [edit]
最大ヒープから最も大きな要素を削除します
(ニーブロイド) [edit]
最大ヒープを昇順にソートされた要素の範囲に変換します
(ニーブロイド) [edit]
最小/最大演算
指定された値の大きい方を返します
(ニーブロイド) [edit]
指定範囲の最も大きな要素を返します
(ニーブロイド) [edit]
指定された値の小さい方を返します
(ニーブロイド) [edit]
指定範囲の最も小さな要素を返します
(ニーブロイド) [edit]
2つの要素の小さい方と大きい方を返します
(ニーブロイド) [edit]
指定範囲の最も小さな要素と最も大きな要素を返します
(ニーブロイド) [edit]
比較演算
2つの集合の要素が同じかどうか判定します
(ニーブロイド) [edit]
ある範囲が別の範囲より辞書順で小さい場合に true を返します
(ニーブロイド) [edit]
順列操作
シーケンスが別のシーケンスの順列かどうか判定します
(ニーブロイド) [edit]
指定範囲の要素より辞書的に大きな次の順列を生成します
(ニーブロイド) [edit]
指定範囲の要素より辞書的に小さな次の順列を生成します
(ニーブロイド) [edit]

[編集] 概要

#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 = {});
  }
}