Skip to content

Latest commit

 

History

History
71 lines (51 loc) · 2.09 KB

README.md

File metadata and controls

71 lines (51 loc) · 2.09 KB

beman.lazy: Beman Library Implementation of lazy (P3552)

Continuous Integration Tests

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).

Usage

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).

Building beman.lazy

Dependencies

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

How to build beman.lazy

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

Contributing

Please do! Issues and pull requests are appreciated.