libcoro  1.0
Coroutine support library for C++20
List of all members
coro::make_awaitable< Fn > Class Template Reference

Converts any result to awaitable object. More...

#include <make_awaitable.h>

Inherits std::suspend_never.

Detailed Description

template<std::invocable<> Fn>
class coro::make_awaitable< Fn >

Converts any result to awaitable object.

This can be useful, when used in template coroutines, when caller supplies own function, which could be awaitable.

To use this class, you need to construct it inside of co_await expression

auto result = co_await coro::make_awaitable([&]{return user_fn(args...);});
Converts any result to awaitable object.

The object is constructed using the lambda expression, which must return whatever the user function returns. If the return value is not awaitable, you can still use co_await on the result.

If the user function is awaitable, then awaiter just proxies all three required methods to perform true co_await operation.

Template Parameters
Fn

Definition at line 28 of file make_awaitable.h.


The documentation for this class was generated from the following file: