template<class C, class Promise>
concept is-awaitable;
概要
is-awaitable
は、Promise型をもつコルーチンのco_await演算子オペランドにおいてC
型オブジェクトが妥当であることを表す説明専用コンセプトである。
要件
説明用の式GET-AWAITER(c, p)
を、Promise型p
をもつコルーチン内のco_await
演算子オペランドに適用される一連変換後の左辺値とする。
- (有効ならば)Promise型の
await_transform
メンバ関数を適用 - (有効ならば)
co_await
演算子オーバーロードを適用
また、説明用のコンセプトawait-suspend-result
, is-awaiter
を以下のように定義する。
template<class T>
concept await-suspend-result = /*see below*/;
template<class A, class Promise>
concept is-awaiter =
requires (A& a, coroutine_handle<Promise> h) {
a.await_ready() ? 1 : 0;
{ a.await_suspend(h) } -> await-suspend-result;
a.await_resume();
};
下記いずれかのうち1つがtrue
のとき、await-suspend-result<T>
はtrue
となる。
T
がvoid
、もしくはT
がbool
、もしくはT
がcoroutine_handle
の特殊化
is-awaitable
コンセプトは、以下のように定義される。
template<class C, class Promise>
concept is-awaitable =
requires (C (*fc)() noexcept, Promise& p) {
{ GET-AWAITER(fc(), p) } -> is-awaiter<Promise>;
};
バージョン
言語
- C++26