|
| 1 | +# basic-receiver |
| 2 | +* execution[meta header] |
| 3 | +* class template[meta id-type] |
| 4 | +* std::execution[meta namespace] |
| 5 | +* cpp26[meta cpp] |
| 6 | + |
| 7 | +```cpp |
| 8 | +namespace std::execution { |
| 9 | + template<class Sndr, class Rcvr, class Index> |
| 10 | + requires valid-specialization<env-type, Index, Sndr, Rcvr> |
| 11 | + struct basic-receiver { // exposition only |
| 12 | + using receiver_concept = receiver_t; |
| 13 | + |
| 14 | + using tag-t = tag_of_t<Sndr>; // exposition only |
| 15 | + using state-t = state-type<Sndr, Rcvr>; // exposition only |
| 16 | + static constexpr const auto& complete = impls-for<tag-t>::complete; // exposition only |
| 17 | + |
| 18 | + template<class... Args> |
| 19 | + requires callable<decltype(complete), Index, state-t&, Rcvr&, set_value_t, Args...> |
| 20 | + void set_value(Args&&... args) && noexcept { |
| 21 | + complete(Index(), op->state, op->rcvr, set_value_t(), std::forward<Args>(args)...); |
| 22 | + } |
| 23 | + |
| 24 | + template<class Error> |
| 25 | + requires callable<decltype(complete), Index, state-t&, Rcvr&, set_error_t, Error> |
| 26 | + void set_error(Error&& err) && noexcept { |
| 27 | + complete(Index(), op->state, op->rcvr, set_error_t(), std::forward<Error>(err)); |
| 28 | + } |
| 29 | + |
| 30 | + void set_stopped() && noexcept |
| 31 | + requires callable<decltype(complete), Index, state-t&, Rcvr&, set_stopped_t> { |
| 32 | + complete(Index(), op->state, op->rcvr, set_stopped_t()); |
| 33 | + } |
| 34 | + |
| 35 | + auto get_env() const noexcept -> env-type<Index, Sndr, Rcvr> { |
| 36 | + return impls-for<tag-t>::get-env(Index(), op->state, op->rcvr); |
| 37 | + } |
| 38 | + |
| 39 | + basic-state<Sndr, Rcvr>* op; // exposition only |
| 40 | + }; |
| 41 | +} |
| 42 | +``` |
| 43 | +* receiver_t[link receiver.md] |
| 44 | +* tag_of_t[link tag_of_t.md] |
| 45 | +* state-type[link basic-operation.md] |
| 46 | +* impls-for[link impls-for.md] |
| 47 | +* callable[link /reference/functional/callable.md.nolink] |
| 48 | +* set_value_t[link set_value.md] |
| 49 | +* set_error_t[link set_error.md] |
| 50 | +* set_stopped_t[link set_stopped.md] |
| 51 | +* basic-state[link basic-operation.md] |
| 52 | +
|
| 53 | +
|
| 54 | +## 概要 |
| 55 | +`basic-receiver`は、Senderアルゴリズム動作仕様定義で用いられる説明専用のクラステンプレートである。 |
| 56 | +
|
| 57 | +`basic-receiver<Sndr, Rcvr, Index>`は[`receiver`](receiver.md)のモデルであり、SenderアルゴリズムのReceiverとしてして[子Senderとの接続時](basic-operation.md)に利用される。 |
| 58 | +
|
| 59 | +- `Sndr` : Senderアルゴリズムの[Sender](sender.md)。 |
| 60 | +- `Rcvr` : Senderアルゴリズムの接続先[Receiver](receiver.md)。Senderアルゴリズム同士を連結する場合は、親Senderアルゴリズム側のReceiver型。 |
| 61 | +- `Index` : Senderアルゴリズムの子Sender識別用インデクス値。Senderアダプタは通常1個の子Senderと接続され、この場合は`Index()`は定数値`0`となる。 |
| 62 | +
|
| 63 | +
|
| 64 | +## 説明専用エンティティ |
| 65 | +
|
| 66 | +```cpp |
| 67 | +template<template<class...> class T, class... Args> |
| 68 | +concept valid-specialization = // exposition only |
| 69 | + requires { typename T<Args...>; }; |
| 70 | +
|
| 71 | +template<class Index, class Sndr, class Rcvr> // exposition only |
| 72 | +using env-type = call-result-t< |
| 73 | + decltype(impls-for<tag_of_t<Sndr>>::get-env), Index, |
| 74 | + state-type<Sndr, Rcvr>&, const Rcvr&>; |
| 75 | +``` |
| 76 | +* call-result-t[link call-result-t.md.nolink] |
| 77 | +* impls-for[link impls-for.md] |
| 78 | +* tag_of_t[link tag_of_t.md] |
| 79 | +* state-type[link basic-operation.md] |
| 80 | + |
| 81 | + |
| 82 | +## バージョン |
| 83 | +### 言語 |
| 84 | +- C++26 |
| 85 | + |
| 86 | + |
| 87 | +## 関連項目 |
| 88 | +- [`basic-sender`](basic-sender.md) |
| 89 | +- [`basic-operation`](basic-operation.md) |
| 90 | +- [`execution::receiver`](receiver.md) |
| 91 | + |
| 92 | + |
| 93 | +## 参照 |
| 94 | +- [P2300R10 `std::execution`](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2300r10.html) |
0 commit comments