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
処理系
- Clang: ??
- GCC: ??
- ICC: ??
- Visual C++: ??