标准库头文件 <algorithm>
来自cppreference.com
此头文件是算法库的一部分。
目录 |
[编辑] 函数
不修改序列的操作 | |
| (C++11)(C++11)(C++11) |
检查谓词是否对范围中所有、任一或无元素为 true (函数模板) |
| 应用函数到范围中的元素 (函数模板) | |
| (C++17) |
应用一个函数对象到序列的前 n 个元素 (函数模板) |
| 返回满足指定判别标准的元素数 (函数模板) | |
| 寻找两个范围出现不同的首个位置 (函数模板) | |
| (C++11) |
寻找首个满足特定判别标准的元素 (函数模板) |
| 在特定范围中寻找最后出现的元素序列 (函数模板) | |
| 搜索元素集合中的任意元素 (函数模板) | |
| 查找首对相邻的相同(或满足给定谓词的)元素 (函数模板) | |
| 搜索一个元素范围 (函数模板) | |
| 在范围中搜索一定量的某个元素的连续副本 (函数模板) | |
修改序列的操作 | |
| (C++11) |
将某一范围的元素复制到一个新的位置 (函数模板) |
| (C++11) |
将一定数目的元素复制到一个新的位置 (函数模板) |
| 按从后往前的顺序复制一个范围内的元素 (函数模板) | |
| (C++11) |
将某一范围的元素移动到一个新的位置 (函数模板) |
| (C++11) |
按从后往前的顺序移动某一范围的元素到新的位置 (函数模板) |
| 将一个给定值复制赋值给一个范围内的每个元素 (函数模板) | |
| 将一个给定值复制赋值给一个范围内的 N 个元素 (函数模板) | |
| 将一个函数应用于某一范围的各个元素 (函数模板) | |
| 将相继的函数调用结果赋值给一个范围中的每个元素 (函数模板) | |
| 将相继的函数调用结果赋值给一个范围中的 N 个元素 (函数模板) | |
| 移除满足特定判别标准的元素 (函数模板) | |
| 复制一个范围的元素,忽略满足特定判别标准的元素 (函数模板) | |
| 将所有满足特定判别标准的值替换为另一个值 (函数模板) | |
| 复制一个范围内的元素,并将满足特定判别标准的元素替换为另一个值 (函数模板) | |
| 交换两个对象的值 (函数模板) | |
| 交换两个范围的元素 (函数模板) | |
| 交换两个迭代器所指向的元素 (函数模板) | |
| 逆转范围中的元素顺序 (函数模板) | |
| 创建一个范围的逆向副本 (函数模板) | |
| 旋转范围中的元素顺序 (函数模板) | |
| 复制并旋转元素范围 (函数模板) | |
| (C++20) |
迁移范围中的元素 (函数模板) |
| (C++17 前)(C++11) |
随机重排范围中的元素 (函数模板) |
| (C++17) |
从一个序列中随机选择 n 个元素 (函数模板) |
| 移除范围内的连续重复元素 (函数模板) | |
| 创建某范围的不含连续重复元素的副本 (函数模板) | |
划分操作 | |
| (C++11) |
判断范围是否已按给定的谓词划分 (函数模板) |
| 将范围中的元素分为两组 (函数模板) | |
| (C++11) |
复制一个范围,将各元素分为两组 (函数模板) |
| 将元素分为两组,同时保留其相对顺序 (函数模板) | |
| (C++11) |
定位已划分范围的划分点 (函数模板) |
排序操作 | |
| (C++11) |
检查范围是否已按升序排列 (函数模板) |
| (C++11) |
找出最大的已排序子范围 (函数模板) |
| 将范围按升序排序 (函数模板) | |
| 排序一个范围的前 N 个元素 (函数模板) | |
| 对范围内的元素进行复制并部分排序 (函数模板) | |
| 将范围内的元素排序,同时保持相等的元素之间的顺序 (函数模板) | |
| 将给定的范围部分排序,确保其按给定元素划分 (函数模板) | |
(已排序范围上的)二分搜索操作 | |
| 返回指向第一个不小于给定值的元素的迭代器 (函数模板) | |
| 返回指向第一个大于给定值的元素的迭代器 (函数模板) | |
| 确定元素是否存在于某范围中 (函数模板) | |
| 返回匹配特定键值的元素范围 (函数模板) | |
其他已排序范围上的操作 | |
| 归并两个已排序的范围 (函数模板) | |
| 就地归并两个有序范围 (函数模板) | |
(已排序范围上的)集合操作 | |
| 若一个集合是另一个的子集则返回 true (函数模板) | |
| 计算两个集合的差集 (函数模板) | |
| 计算两个集合的交集 (函数模板) | |
| 计算两个集合的对称差 (函数模板) | |
| 计算两个集合的并集 (函数模板) | |
堆操作 | |
| 检查给定范围是否为一个最大堆 (函数模板) | |
| (C++11) |
查找能成为最大堆的最大子范围 (函数模板) |
| 从一个元素范围创建出一个最大堆 (函数模板) | |
| 将一个元素加入到一个最大堆 (函数模板) | |
| 从最大堆中移除最大元素 (函数模板) | |
| 将一个最大堆变成一个按升序排序的元素范围 (函数模板) | |
最小/最大操作 | |
| 返回各给定值中的较大者 (函数模板) | |
| 返回范围内的最大元素 (函数模板) | |
| 返回各给定值中的较小者 (函数模板) | |
| 返回范围内的最小元素 (函数模板) | |
| (C++11) |
返回两个元素的较小和较大者 (函数模板) |
| (C++11) |
返回范围内的最小元素和最大元素 (函数模板) |
| (C++17) |
在一对边界值间夹逼一个值 (函数模板) |
比较操作 | |
| 确定两个元素集合是否是相同的 (函数模板) | |
| 当一个范围按字典顺序小于另一个范围时,返回 true (函数模板) | |
| (C++20) |
用三路比较比较两个值 (函数模板) |
| (C++20) |
用三路比较比较两个范围 (函数模板) |
排列操作 | |
| (C++11) |
判断一个序列是否为另一个序列的排列 (函数模板) |
| 产生某个元素范围的按字典顺序的下一个较大的排列 (函数模板) | |
| 产生某个元素范围的按字典顺序的下一个较小的排列 (函数模板) | |
[编辑] Niebloid
| 定义于命名空间
std::ranges | |
不修改序列的操作 | |
| 检查谓词是否对范围中所有、任一或无元素为 true (niebloid) | |
| 应用函数到范围中的元素 (niebloid) | |
| 返回满足指定判别标准的元素数 (niebloid) | |
| 寻找两个范围出现不同的首个位置 (niebloid) | |
| 寻找首个满足特定判别标准的元素 (niebloid) | |
| 在特定范围中寻找最后出现的元素序列 (niebloid) | |
| 搜索元素集合中的任意元素 (niebloid) | |
| 查找首对相邻的相同(或满足给定谓词的)元素 (niebloid) | |
| 搜索一个元素范围 (niebloid) | |
| 在范围中搜索一定量的某个元素的连续副本 (niebloid) | |
修改序列的操作 | |
| 将某一范围的元素复制到一个新的位置 (niebloid) | |
| 将一定数目的元素复制到一个新的位置 (niebloid) | |
| 按从后往前的顺序复制一个范围内的元素 (niebloid) | |
| 将某一范围的元素移动到一个新的位置 (niebloid) | |
| 按从后往前的顺序移动某一范围的元素到新的位置 (niebloid) | |
| 将一个给定值复制赋值给一个范围内的每个元素 (niebloid) | |
| 将一个值复制赋值给一定量的元素 (niebloid) | |
| 将一个函数应用于某一范围的各个元素 (niebloid) | |
| 保存函数结果到一个范围中 (niebloid) | |
| 保存 N 次函数应用的结果 (niebloid) | |
| 移除满足特定判别标准的元素 (niebloid) | |
| 复制一个范围的元素,忽略满足特定判别标准的元素 (niebloid) | |
| 将所有满足特定判别标准的值替换为另一个值 (niebloid) | |
| 复制一个范围内的元素,并将满足特定判别标准的元素替换为另一个值 (niebloid) | |
| 交换两个范围的元素 (niebloid) | |
| 逆转范围中的元素顺序 (niebloid) | |
| 创建一个范围的逆向副本 (niebloid) | |
| 旋转范围中的元素顺序 (niebloid) | |
| 复制并旋转元素范围 (niebloid) | |
| 随机重排范围中的元素 (niebloid) | |
| 移除范围中的连续重复元素 (niebloid) | |
| 创建某范围的不含连续重复元素的副本 (niebloid) | |
划分操作 | |
| 判断范围是否已按给定的谓词划分 (niebloid) | |
| 将范围中的元素分为二组 (niebloid) | |
| 复制一个范围,将各元素分为二组 (niebloid) | |
| 将元素分成二组,同时保持其相对顺序 (niebloid) | |
| 定位已划分范围的划分点 (niebloid) | |
排序操作 | |
| 检查范围是否以升序排序 (niebloid) | |
| 寻找最大的已排序子范围 (niebloid) | |
| 将范围按升序排序 (niebloid) | |
| 排序一个范围的前 N 个元素 (niebloid) | |
| 对范围内的元素进行复制并部分排序 (niebloid) | |
| 将范围内的元素排序,同时保持相等的元素之间的顺序 (niebloid) | |
| 将给定的范围部分排序,确保其按给定元素划分 (niebloid) | |
(已排序范围上的)集合操作 | |
| 返回指向首个不小于给定值的元素的迭代器 (niebloid) | |
| 返回指向首个大于某值的元素的迭代器 (niebloid) | |
| 确定元素是否存在于某范围中 (niebloid) | |
| 返回匹配特定键值的元素范围 (niebloid) | |
其他已排序范围上的操作 | |
| 归并二个已排序范围 (niebloid) | |
| 在原位归并两个有序范围 (niebloid) | |
(已排序范围上的)集合操作 | |
若一个集合是另一个的子集则返回 true (niebloid) | |
| 计算两个集合的差集 (niebloid) | |
| 计算两个集合的交集 (niebloid) | |
| 计算两个集合的对称差 (niebloid) | |
| 计算两个集合的并集 (niebloid) | |
堆操作 | |
| 检查给定范围是否为最大堆 (niebloid) | |
| 寻找能成为最大堆的最大子范围 (niebloid) | |
| 从一个元素范围创建出一个最大堆 (niebloid) | |
| 将一个元素加入到一个最大堆 (niebloid) | |
| 从最大堆中移除最大元素 (niebloid) | |
| 将一个最大堆变成一个按升序排序的元素范围 (niebloid) | |
最小/最大操作 | |
| 返回给定值的较大者 (niebloid) | |
| 返回范围中的最大元素 (niebloid) | |
| 返回给定值的较小者 (niebloid) | |
| 返回范围中的最小元素 (niebloid) | |
| 返回两个元素的较小和较大者 (niebloid) | |
| 返回范围中的最小和最大元素 (niebloid) | |
比较操作 | |
| 确定两个元素集合是否是相同的 (niebloid) | |
| 当一个范围按字典顺序小于另一个范围时,返回 true (niebloid) | |
排列操作 | |
| 确定一个序列是否为另一序列的重排 (niebloid) | |
| 产生某个元素范围的按字典序下一个较大的排列 (niebloid) | |
| 产生某个元素范围的按字典序下一个较小的排列 (niebloid) | |
[编辑] 概要
#include <initializer_list> namespace std { // 不修改序列的操作: // 全部(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); // 修改序列的操作: // 复制(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); // 排序与相关操作: // 排序: 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 = {}); } // 第 N 元素: 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 = {}); } // 二分搜索: 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 = {}); } // 划分(partition): 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)操作: 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)操作: 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 = {}); } // 最小与最大: 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 = {}); } // 有界值: 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); // 字典序比较: 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 = {}); } // 三路比较算法: 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); // 排列: 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 = {}); } }

