Код: Выделить всё
cppcoro::async_generator ticker(int count, threadpool& tp)
{
for (int i = 0; i < count; ++i)
{
co_await tp.delay(std::chrono::seconds(1));
co_yield i;
}
}
cppcoro::task consumer(threadpool& tp)
{
auto sequence = ticker(10, tp);
for co_await (std::uint32_t i : sequence)
{
std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/68720497/why-is-co-await-for-loop-not-shipped-in-c20[/url]