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

履歴 編集

concept
<execution>

std::execution::receiver_of(C++26)

namespace std::execution {
  template<class Rcvr, class Completions>
  concept receiver_of;
}

概要

receiver_ofは、Receiver型Rcvr完了シグネチャ集合Completionsに適合することを表すコンセプトである。

要件

説明専用コンセプトvalid-completion-for, has-completionsを以下のように定義する。

template<class Signature, class Rcvr>
concept valid-completion-for =
  requires (Signature* sig) {
    []<class Tag, class... Args>(Tag(*)(Args...))
      requires callable<Tag, remove_cvref_t<Rcvr>, Args...>
    {}(sig);
  };

template<class Rcvr, class Completions>
concept has-completions =
  requires (Completions* completions) {
    []<valid-completion-for<Rcvr>...Sigs>(completion_signatures<Sigs...>*)
    {}(completions);
  };

receiver_ofコンセプトは、以下のように定義される。

template<class Rcvr, class Completions>
concept receiver_of =
  receiver<Rcvr> && has-completions<Rcvr, Completions>;

#include <execution>
namespace ex = std::execution;

struct MyReceiver {
  using receiver_concept = ex::receiver_t;

  void set_value(int, int) && noexcept;
  void set_error(int) && noexcept;
};

int main()
{
  // 値完了操作set_value(int, int)に対応
  static_assert(ex::receiver_of<MyReceiver,
    ex::completion_signatures<ex::set_value_t(int, int)>>);

  // 値完了操作set_value(int)には非対応
  static_assert(not ex::receiver_of<MyReceiver,
    ex::completion_signatures<ex::set_value_t(int)>>);

  // エラー完了操作set_error(int)に対応
  static_assert(ex::receiver_of<MyReceiver,
    ex::completion_signatures<ex::set_error_t(int)>>);

  // 停止完了操作set_stopped()には非対応
  static_assert(not ex::receiver_of<MyReceiver,
    ex::completion_signatures<ex::set_stopped_t()>>);
}

出力

バージョン

言語

  • C++26

処理系

関連項目

参照