|
Console Library 8.0.0
A header-only library that makes C++ simple
|
无参数协程的特化,可用作输入迭代器。 More...
#include <coroutine.h>
Public Types | |
| using | value_type = Ret |
| 值类型。 | |
| using | difference_type = ptrdiff_t |
| 差值类型。 | |
| using | pointer = value_type * |
| 指针类型。 | |
| using | reference = value_type |
| 引用类型 (事实上是值类型)。 | |
| using | iterator_category = std::input_iterator_tag |
| 迭代器类别 (输入迭代器)。 | |
Public Member Functions | |
| template<class F> | |
| Coroutine (F f) | |
| 从可调用对象构造协程迭代器。 | |
| Ret | operator() () |
| 直接调用协程,取下一个产出值。 | |
| value_type | operator* () |
| 解引用操作符,返回当前缓存值。 | |
| Coroutine & | operator++ () |
| 前置自增,推进协程。 | |
| Coroutine | operator++ (int) |
| 后置自增,推进协程。 | |
| bool | operator== (const Coroutine &) |
| 相等比较。 | |
| bool | operator!= (const Coroutine &) |
| 不相等比较。 | |
| Coroutine | begin () |
| 返回自身作为范围 for 的起始迭代器。 | |
| Coroutine | end () |
| 返回自身作为范围 for 的结束哨兵迭代器。 | |
Private Attributes | |
| std::shared_ptr< std::function< Ret()> > | coro |
| 底层协程函数 (由宏生成的 lambda)。 | |
| std::shared_ptr< Ret > | ptr |
| 缓存当前产出值;协程结束后为 nullptr。 | |
无参数协程的特化,可用作输入迭代器。
返回引用无参数协程的特化,可用作输入迭代器。
每次调用 operator() 获取下一个产出值。该特化支持范围 for 循环 (通过 begin() 和 end()),也提供迭代器语义。 当协程结束 (抛出 StopIteration)后, 迭代被视为到达末尾。
| Ret | 产出值的类型。 |
每次调用 operator() 获取下一个产出引用。该特化支持范围 for 循环 (通过 begin() 和 end()),也提供迭代器语义。 当协程结束 (抛出 StopIteration)后, 迭代被视为到达末尾。
| Ret | 产出值的类型。 |
| using console::Coroutine< Ret()>::difference_type = ptrdiff_t |
差值类型。
| using console::Coroutine< Ret()>::iterator_category = std::input_iterator_tag |
迭代器类别 (输入迭代器)。
| using console::Coroutine< Ret()>::pointer = value_type * |
指针类型。
| using console::Coroutine< Ret()>::reference = value_type |
引用类型 (事实上是值类型)。
| using console::Coroutine< Ret()>::value_type = Ret |
值类型。
从可调用对象构造协程迭代器。
| f | 协程函数 (如宏组合生成的 lambda)。 |
|
inline |
返回自身作为范围 for 的起始迭代器。
|
inline |
返回自身作为范围 for 的结束哨兵迭代器。
|
inline |
不相等比较。
|
inline |
|
inline |
|
inline |
前置自增,推进协程。
|
inline |
后置自增,推进协程。
|
inline |
相等比较。
若尚未到达末尾,先推进协程再判断。
|
private |
底层协程函数 (由宏生成的 lambda)。
|
private |
缓存当前产出值;协程结束后为 nullptr。