std::projected
迭代器概念 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
迭代器原语 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
算法概念与工具 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
间接可调用概念 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
常用算法要求 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
工具 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
迭代器适配器 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
流迭代器 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
迭代器定制点 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
(C++20)
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
(C++20)
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
迭代器操作 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
范围访问 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
在标头
<iterator>
定义
|
||
(1) | ||
template<
std::indirectly_readable
I,
std::indirectly_regular_unary_invocable<I>
Proj > |
(C++20
起) (C++26 前) |
|
template<
std::indirectly_readable
I,
std::indirectly_regular_unary_invocable<I>
Proj > |
(C++26 起) | |
template<
std::weakly_incrementable
I, class
Proj >
struct
incrementable_traits<std::projected<I,
Proj>>
{ |
(2) | (C++20
起) (C++26 前) |
template<
class
I, class
Proj >
struct
/*projected-impl*/
{
//
仅用于阐释 |
(3) | (C++26 起) |
projected
组合 indirectly_readable
类型 I
与可调用对象类型 Proj
到新的
indirectly_readable
类型中,其引用类型是应用 Proj
到 std::iter_reference_t<I> 的结果。I
为 weakly_incrementable
类型时亦为 weakly_incrementable
类型。projected
仅用于约束约接受可调用对象与投影的算法,从而其 operator*()
没有得到定义。
模板形参
I | - | 间接可读类型 |
Proj | - | 应用到解引用的 I 的投影
|
注解
间接层使得 I
与 Proj
不会成为 projected
的关联类。当一个
I
或 Proj
的关联类为不完整类类型时,间接层避免检查该类型的定义的尝试,而尝试会导致硬错误。