wwa-coro 0.0.1
Yet Another C++20 Coroutine Library
sync_generator_adapter.cpp

Example of adapting an async_generator to use with std::ranges.

#include <iostream>
#include <ranges>
namespace {
wwa::coro::async_generator<int> async_iota(int start = 0)
{
for (int i = start;; ++i) {
co_yield i;
}
}
} // namespace
int main()
{
wwa::coro::sync_generator_adapter sync_iota(async_iota(10));
for (const auto& n : sync_iota | std::views::take(5)) {
std::cout << n << "\n";
}
// Expected output:
// 10
// 11
// 12
// 13
// 14
return 0;
}
Asynchronous generator.
An asynchronous generator that produces values of type Result.
Adapter for converting asynchronous generators to synchronous generators.
Adapter for converting asynchronous generators to synchronous generators.