Iros
Loading...
Searching...
No Matches
is_awaiter.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
di/execution/concepts/await_suspend_result.h
"
4
#include "
di/meta/core.h
"
5
#include "
di/meta/language.h
"
6
#include "
di/meta/operations.h
"
7
8
namespace
di::concepts
{
9
namespace
detail
{
10
template
<
typename
Promise,
typename
Awaiter>
11
auto
do_await_suspend
(Awaiter& awaiter) ->
decltype
(
auto
) {
12
if
constexpr
(!
concepts::SameAs<Promise, void>
) {
13
return
awaiter.await_suspend(std::coroutine_handle<Promise> {});
14
}
15
}
16
}
17
18
// An awaiter object requires 3 methods: await_ready(), await_suspend(), and await_resume().
19
// Because in reality, await_suspend() is only called with coroutine handles with concrete promise
20
// types, it cannot be checked when the promise type is unknown.
21
template
<
typename
T,
typename
Promise =
void
>
22
concept
IsAwaiter
=
requires
(T& awaiter) {
23
{ awaiter.await_ready() } ->
BooleanTestable
;
24
{
detail::do_await_suspend<Promise>
(awaiter) } ->
AwaitSuspendResult
;
25
awaiter.await_resume();
26
};
27
}
await_suspend_result.h
di::concepts::AwaitSuspendResult
Definition
await_suspend_result.h:9
di::concepts::BooleanTestable
Definition
operations.h:128
di::concepts::IsAwaiter
Definition
is_awaiter.h:22
di::concepts::SameAs
Definition
core.h:114
core.h
operations.h
language.h
di::concepts::detail
Definition
impl.h:7
di::concepts::detail::do_await_suspend
auto do_await_suspend(Awaiter &awaiter) -> decltype(auto)
Definition
is_awaiter.h:11
di::concepts
Definition
any_storable.h:9
libs
di
include
di
execution
concepts
is_awaiter.h
Generated by
1.13.0