|
| 1 | +# receiver_of |
| 2 | +* execution[meta header] |
| 3 | +* concept[meta id-type] |
| 4 | +* std::execution[meta namespace] |
| 5 | +* cpp26[meta cpp] |
| 6 | + |
| 7 | +```cpp |
| 8 | +namespace std::execution { |
| 9 | + template<class Rcvr, class Completions> |
| 10 | + concept receiver_of; |
| 11 | +} |
| 12 | +``` |
| 13 | +
|
| 14 | +## 概要 |
| 15 | +`receiver_of`は、[Receiver型](receiver.md)`Rcvr`が完了シグネチャの集合`Completions`に適合することを表すコンセプトである。 |
| 16 | +
|
| 17 | +
|
| 18 | +## 要件 |
| 19 | +説明専用コンセプト`valid-completion-for`, `has-completions`を以下のように定義する。 |
| 20 | +
|
| 21 | +```cpp |
| 22 | +template<class Signature, class Rcvr> |
| 23 | +concept valid-completion-for = |
| 24 | + requires (Signature* sig) { |
| 25 | + []<class Tag, class... Args>(Tag(*)(Args...)) |
| 26 | + requires callable<Tag, remove_cvref_t<Rcvr>, Args...> |
| 27 | + {}(sig); |
| 28 | + }; |
| 29 | +
|
| 30 | +template<class Rcvr, class Completions> |
| 31 | +concept has-completions = |
| 32 | + requires (Completions* completions) { |
| 33 | + []<valid-completion-for<Rcvr>...Sigs>(completion_signatures<Sigs...>*) |
| 34 | + {}(completions); |
| 35 | + }; |
| 36 | +``` |
| 37 | +* callable[link /reference/functional/callable.md.nolink] |
| 38 | +* completion_signatures[link completion_signatures.md.nolink] |
| 39 | + |
| 40 | +`receiver_of`コンセプトは、以下のように定義される。 |
| 41 | + |
| 42 | +```cpp |
| 43 | +template<class Rcvr, class Completions> |
| 44 | +concept receiver_of = |
| 45 | + receiver<Rcvr> && has-completions<Rcvr, Completions>; |
| 46 | +``` |
| 47 | +* receiver<Rcvr>[link receiver.md] |
| 48 | +
|
| 49 | +
|
| 50 | +## 例 |
| 51 | +```cpp example |
| 52 | +#include <execution> |
| 53 | +namespace ex = std::execution; |
| 54 | +
|
| 55 | +struct ValueReceiver { |
| 56 | + using receiver_concept = ex::receiver_t; |
| 57 | +
|
| 58 | + void set_value(int) noexcept; |
| 59 | +}; |
| 60 | +
|
| 61 | +int main() |
| 62 | +{ |
| 63 | + // 完了操作ex::set_value(int)に対応 |
| 64 | + static_assert(ex::receiver_of<ValueReceiver, |
| 65 | + ex::completion_signatures<ex::set_value_t(int)>>); |
| 66 | +
|
| 67 | + // 完了操作ex::set_value(int, int)には非対応 |
| 68 | + static_assert(not ex::receiver_of<ValueReceiver, |
| 69 | + ex::completion_signatures<ex::set_value_t(int, int)>>); |
| 70 | +} |
| 71 | +``` |
| 72 | +* ex::receiver_of[color ff0000] |
| 73 | +* ex::completion_signatures[link completion_signatures.md.nolink] |
| 74 | + |
| 75 | +### 出力 |
| 76 | +``` |
| 77 | +``` |
| 78 | + |
| 79 | + |
| 80 | +## バージョン |
| 81 | +### 言語 |
| 82 | +- C++26 |
| 83 | + |
| 84 | +### 処理系 |
| 85 | +- [Clang](/implementation.md#clang): ?? |
| 86 | +- [GCC](/implementation.md#gcc): ?? |
| 87 | +- [ICC](/implementation.md#icc): ?? |
| 88 | +- [Visual C++](/implementation.md#visual_cpp): ?? |
| 89 | + |
| 90 | + |
| 91 | +## 関連項目 |
| 92 | +- [`execution::receiver`](receiver.md) |
| 93 | + |
| 94 | + |
| 95 | +## 参照 |
| 96 | +- [P2300R10 `std::execution`](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2300r10.html) |
0 commit comments