|
| 1 | +# start |
| 2 | +* execution[meta header] |
| 3 | +* cpo[meta id-type] |
| 4 | +* std::execution[meta namespace] |
| 5 | +* cpp26[meta cpp] |
| 6 | + |
| 7 | +```cpp |
| 8 | +namespace std::execution { |
| 9 | + struct start_t; |
| 10 | + inline constexpr start_t start{}; |
| 11 | +} |
| 12 | +``` |
| 13 | +
|
| 14 | +## 概要 |
| 15 | +`start`は、[Operation State](operation_state.md)を開始するカスタマイゼーションポイントオブジェクトである。 |
| 16 | +
|
| 17 | +
|
| 18 | +## 効果 |
| 19 | +式`start(op)`は、`op`が右辺値の場合は不適格となる。 |
| 20 | +そうでなければ、`op.start()`と等価。 |
| 21 | +
|
| 22 | +`op.start()`が[Operation State](operation_state.md)に関連付けさられた非同期操作を開始しない場合、式`start(op)`は未定義動作となる。 |
| 23 | +
|
| 24 | +
|
| 25 | +## カスタマイゼーションポイント |
| 26 | +[Operation State](operation_state.md)`op`に対して式`op.start()`が呼び出される。 |
| 27 | +このとき`noexcept(op.start()) == true`であること。 |
| 28 | +
|
| 29 | +
|
| 30 | +## 例 |
| 31 | +```cpp |
| 32 | +#include <print> |
| 33 | +#include <execution> |
| 34 | +namespace ex = std::execution; |
| 35 | +
|
| 36 | +struct ValueReceiver { |
| 37 | + using receiver_concept = ex::receiver_t; |
| 38 | +
|
| 39 | + void set_value(int v) && noexcept |
| 40 | + { |
| 41 | + std::println("{}", v); |
| 42 | + } |
| 43 | +}; |
| 44 | +
|
| 45 | +int main() |
| 46 | +{ |
| 47 | + // 値42を送信するSender |
| 48 | + ex::sender auto sndr = ex::just(42); |
| 49 | + // int値を受信して表示するReceiver |
| 50 | + ValueReceiver rcvr; |
| 51 | + |
| 52 | + // SenderとReceiverを接続 |
| 53 | + ex::operation_state auto op = ex::connect(sndr, rcvr); |
| 54 | + // Operation Stateを開始 |
| 55 | + ex::start(op); |
| 56 | +} |
| 57 | +``` |
| 58 | +* ex::start[color ff0000] |
| 59 | +* ex::receiver_t[link receiver.md] |
| 60 | +* ex::sender[link sender.md] |
| 61 | +* ex::just[link just.md.nolink] |
| 62 | +* ex::operation_state[link operation_state.md] |
| 63 | +* ex::connect[link connect.md] |
| 64 | + |
| 65 | +### 出力 |
| 66 | +``` |
| 67 | +42 |
| 68 | +``` |
| 69 | + |
| 70 | + |
| 71 | +## バージョン |
| 72 | +### 言語 |
| 73 | +- C++26 |
| 74 | + |
| 75 | +### 処理系 |
| 76 | +- [Clang](/implementation.md#clang): ?? |
| 77 | +- [GCC](/implementation.md#gcc): ?? |
| 78 | +- [ICC](/implementation.md#icc): ?? |
| 79 | +- [Visual C++](/implementation.md#visual_cpp): ?? |
| 80 | + |
| 81 | + |
| 82 | +## 関連項目 |
| 83 | +- [`execution::operation_state`](operation_state.md) |
| 84 | + |
| 85 | + |
| 86 | +## 参照 |
| 87 | +- [P2300R10 `std::execution`](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2300r10.html) |
0 commit comments