最終更新日時(UTC):
が更新

履歴 編集

concept
<execution>

std::is-awaitable(C++26)

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となる。

  • Tvoid、もしくは
  • Tbool、もしくは
  • Tcoroutine_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

関連項目

参照