std::generator<Ref,V,Allocator>::iterator
协程特征 | ||||
(C++20)
|
||||
协程柄 | ||||
(C++20)
|
||||
无操作协程 | ||||
(C++20)
|
||||
(C++20)
|
||||
平凡可等待体 | ||||
(C++20)
|
||||
(C++20)
|
成员函数 | ||||
(C++23)
|
||||
(C++23)
|
||||
(C++23)
|
||||
(C++23)
|
||||
(C++23)
|
||||
promise_type | ||||
Iterator | ||||
(C++23)
|
||||
(C++23)
|
||||
(C++23)
|
||||
class
/*iterator*/;
|
(C++23 起) | |
generator::begin
的返回类型。名字 iterator
仅用于阐释。
实现 indirectly_readable
和 input_iterator
。
成员类型
成员类型 | 定义 |
value_type
|
std::generator::value
|
difference_type
|
std::ptrdiff_t |
数据成员
iterator
的典型实现仅包含如下非静态数据成员:
- 类型为 std::coroutine_handle<std::generator::promise_type>
的协程句柄 (表示为
coroutine_
仅用于阐释)。
成员函数
(C++23)
|
构造迭代器 (公开成员函数) |
(C++23)
|
赋值给另一迭代器 (公开成员函数) |
(C++23)
|
返回底层的值 (公开成员函数) |
(C++23)
|
自增迭代器 (公开成员函数) |
std::generator::iterator::iterator
/*iterator*/(
/*iterator*/&&
other )
noexcept;
|
(C++23 起) | |
如同 std::exchange(other.coroutine_, {}); 初始化
coroutine_
。
std::generator::iterator::operator=
/*iterator*/&
operator=(
/*iterator*/&&
other )
noexcept;
|
(C++23 起) | |
等价于 coroutine_ = std::exchange(other.coroutine_, {});。
返回: *this.
std::generator::iterator::operator*
reference
operator*()
const
noexcept( std::is_nothrow_copy_constructible_v<reference> ); |
(C++23 起) | |
- 令
reference
表示std::generator
的底层类型。 - 令 x
是某个生成器对象,其
coroutine_
在栈 *x.active_ 中。 - 令 x.active_->top() 指代具有承诺对象 p 的暂停的协程。
等价于 return static_cast<reference>(*p.value_);。
std::generator::iterator::operator++
constexpr
/*iterator*/&
operator++();
|
(1) | (C++23 起) |
constexpr
void
operator++(
int
);
|
(2) | (C++23 起) |
coroutine_
在栈 *x.active_
中。非成员函数
(C++23)
|
将底层迭代器和哨位进行比较 (函数) |
operator==(std::generator::iterator)
friend
bool
operator==(
const
/*iterator*/&
i, std::default_sentinel_t
);
|
(C++23 起) | |
等价于 return i.coroutine_.done();。
!=
运算符从 ==
运算符合成。
此函数对通常无限定或有限定查找不可见,而只能在
std::generator::iterator
为参数的关联类时由实参依赖查找找到。
Example
本节未完成 原因:暂无示例 |