- execution[meta header]
- concept[meta id-type]
- std::execution[meta namespace]
- cpp26[meta cpp]
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);
};- callable[link /reference/functional/callable.md]
- completion_signatures[link completion_signatures.md]
receiver_ofコンセプトは、以下のように定義される。
template<class Rcvr, class Completions>
concept receiver_of =
receiver<Rcvr> && has-completions<Rcvr, Completions>;- receiver[link receiver.md]
#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()>>);
}- ex::receiver_of[color ff0000]
- ex::receiver_t[link receiver.md]
- ex::completion_signatures[link completion_signatures.md]
- ex::set_value_t[link set_value.md]
- ex::set_error_t[link set_error.md]
- ex::set_stopped_t[link set_stopped.md]
- C++26
- Clang: ??
- GCC: ??
- ICC: ??
- Visual C++: ??