beman::execution26::lazy<T, Context>
is a class template which
is used as the the type of coroutine tasks. The corresponding objects
are senders. The first template argument (T
) defines the result
type which becomes a set_value_t(T)
completion signatures. The
second template argument (Context
) provides a way to configure
the behavior of the coroutine. By default it can be left alone.
Implements: std::execution::lazy
proposed in Add a Coroutine Lazy Type (P3552r0).
The following code snippet shows a basic use of beman::lazy::lazy
using sender/receiver facilities to implement version of hello, world
:
#include <beman/lazy/lazy.hpp>
#include <beman/execution26/execution.hpp>
#include <iostream>
namespace ex = beman::execution26;
namespace ly = beman::lazy;
int main() {
return std::get<0>(*ex::sync_wait([]->ex::lazy<int> {
std::cout << "Hello, world!\n";
co_return co_await ex::just(0);
}()));
}
Full runnable examples can be found in examples/
(e.g., ./examples/hello.cpp
).
This project depends on
beman::execution26
(which
will be automatically obtained using cmake
's FetchContent*
).
Build-time dependencies:
cmake
ninja
,make
, or another CMake-supported build system- CMake defaults to "Unix Makefiles" on POSIX systems
This project strives to be as normal and simple a CMake project as
possible. This build workflow in particular will work, producing
a static libbeman.lazy.a
library, ready to package with its
headers:
cmake --workflow --preset gcc-debug
cmake --workflow --preset gcc-release
cmake --install build/gcc-release --prefix /opt/beman.lazy
Please do! Issues and pull requests are appreciated.