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_transformメンバ関数を持たずcoroutine_handle<none-such>がcoroutine_handle<void>と同様に振る舞う未規定の空のクラスnone-suchの左辺値pを用いて、説明用の式GET-AWAITER(c)はGET-AWAITER(c, p)と等価とする。
また、説明用のコンセプト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