Skip to content

Commit 885f6ee

Browse files
committed
execution: just (#1384)
make-sender, basic-sender, basic-operation, impls-for
1 parent 9ea31e8 commit 885f6ee

20 files changed

Lines changed: 518 additions & 15 deletions

reference/execution/execution.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ namespace std::execution {
9999
100100
| 名前 | 説明 | 対応バージョン |
101101
|------|------|----------------|
102-
| [`execution::just`](execution/just.md.nolink) | 値を送信するSender (customization point object) | C++26 |
102+
| [`execution::just`](execution/just.md) | 値を送信するSender (customization point object) | C++26 |
103103
| [`execution::just_error`](execution/just_error.md.nolink) | エラーを送信するSender (customization point object) | C++26 |
104104
| [`execution::just_stopped`](execution/just_stopped.md.nolink) | 停止を送信するSender (customization point object) | C++26 |
105105
| [`execution::read_env`](execution/read_env.md.nolink) | Receiver環境から構築されるSender (customization point object) | C++26 |
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
# basic-operation
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>
10+
requires valid-specialization<state-type, Sndr, Rcvr> &&
11+
valid-specialization<connect-all-result, Sndr, Rcvr>
12+
struct basic-operation : basic-state<Sndr, Rcvr> { // exposition only
13+
using operation_state_concept = operation_state_t;
14+
using tag-t = tag_of_t<Sndr>; // exposition only
15+
16+
connect-all-result<Sndr, Rcvr> inner-ops; // exposition only
17+
18+
basic-operation(Sndr&& sndr, Rcvr&& rcvr) noexcept(see below) // exposition only
19+
: basic-state<Sndr, Rcvr>(std::forward<Sndr>(sndr), std::move(rcvr)),
20+
inner-ops(connect-all(this, std::forward<Sndr>(sndr), indices-for<Sndr>()))
21+
{}
22+
23+
void start() & noexcept {
24+
auto& [...ops] = inner-ops;
25+
impls-for<tag-t>::start(this->state, this->rcvr, ops...);
26+
}
27+
};
28+
29+
template<class Sndr, class Rcvr>
30+
struct basic-state { // exposition only
31+
basic-state(Sndr&& sndr, Rcvr&& rcvr) noexcept(see below)
32+
: rcvr(std::move(rcvr))
33+
, state(impls-for<tag_of_t<Sndr>>::get-state(std::forward<Sndr>(sndr), rcvr)) { }
34+
35+
Rcvr rcvr; // exposition only
36+
state-type<Sndr, Rcvr> state; // exposition only
37+
};
38+
}
39+
```
40+
* operation_state_t[link operation_state.md]
41+
* tag_of_t[link tag_of_t.md.nolink]
42+
* impls-for[link impls-for.md]
43+
* see below[italic]
44+
45+
## 概要
46+
`basic-operation`および`basic-state`は、Senderアルゴリズム動作仕様定義で用いられる説明専用のクラステンプレートである。
47+
48+
`basic-operation<Sndr, Rcvr>`[`operation_state`](operation_state.md)のモデルであり、[Senderアルゴリズム](basic-sender.md)[Recevier](receiver.md)[接続(connect)](connect.md)結果型として利用される。
49+
50+
- `rcvr` : 接続先Receiverオブジェクトを保持。Senderアルゴリズム同士を連結する場合は、親Senderアルゴリズム側の[Receiver](receiver.md)が該当する。
51+
- `state` : Senderアルゴリズム構築時の引数リストを保持。([`impls-for`](impls-for.md)でカスタマイズ可能)
52+
- `inner-ops` : 子SenderリストとSenderアルゴリズムとの接続結果[Operation State](operation_state.md)リストを保持。Senderファクトリでは0個、Senderアダプタでは通常1個の子Senderと接続される。
53+
54+
55+
## クラス仕様
56+
`basic-operation`コンストラクタ`noexcept`節の式は下記の通り。
57+
58+
```cpp
59+
is_nothrow_constructible_v<basic-state<Self, Rcvr>, Self, Rcvr> &&
60+
noexcept(connect-all(this, std::forward<Sndr>(sndr), indices-for<Sndr>()))
61+
```
62+
* is_nothrow_constructible_v[link /reference/type_traits/is_nothrow_constructible.md]
63+
64+
`basic-state`コンストラクタ`noexcept`節の式は下記の通り。
65+
66+
```cpp
67+
is_nothrow_move_constructible_v<Rcvr> &&
68+
nothrow-callable<decltype(impls-for<tag_of_t<Sndr>>::get-state), Sndr, Rcvr&> &&
69+
(same_as<state-type<Sndr, Rcvr>, get-state-result> ||
70+
is_nothrow_constructible_v<state-type<Sndr, Rcvr>, get-state-result>)
71+
```
72+
* impls-for[link impls-for.md]
73+
* tag_of_t[link tag_of_t.md.nolink]
74+
* is_nothrow_move_constructible_v[link /reference/type_traits/is_nothrow_move_constructible.md]
75+
* is_nothrow_constructible_v[link /reference/type_traits/is_nothrow_constructible.md]
76+
77+
ここで、説明用の型`get-state-result`は下記の通り定義される。
78+
79+
```cpp
80+
call-result-t<decltype(impls-for<tag_of_t<Sndr>>::get-state), Sndr, Rcvr&>.
81+
```
82+
* impls-for[link impls-for.md]
83+
* tag_of_t[link tag_of_t.md.nolink]
84+
85+
86+
## 説明専用エンティティ
87+
88+
```cpp
89+
template<template<class...> class T, class... Args>
90+
concept valid-specialization = // exposition only
91+
requires { typename T<Args...>; };
92+
93+
template<class Sndr, class Rcvr> // exposition only
94+
using state-type = decay_t<call-result-t<
95+
decltype(impls-for<tag_of_t<Sndr>>::get-state), Sndr, Rcvr&>>;
96+
97+
constexpr auto connect-all = see below; // exposition only
98+
99+
template<class Sndr, class Rcvr>
100+
using connect-all-result = call-result-t< // exposition only
101+
decltype(connect-all), basic-state<Sndr, Rcvr>*, Sndr, indices-for<Sndr>>;
102+
103+
template<class Sndr>
104+
using indices-for = remove_reference_t<Sndr>::indices-for; // exposition only
105+
```
106+
* impls-for[link impls-for.md]
107+
* tag_of_t[link tag_of_t.md.nolink]
108+
* decay_t[link /reference/type_traits/decay.md]
109+
* remove_reference_t[link /reference/type_traits/remove_reference.md]
110+
* see below[italic]
111+
112+
説明専用の定数`connect-all`は、下記ラムダ式と等価な関数呼び出し可能なオブジェクトとして初期化される。
113+
114+
- 全ての子Sender`child`とSenderアルゴリズム`sndr`の[Receiver](basic-receiver.md)を[接続(connect)](connec.md)し、結果の[Operation State](operation_state.md)リストを[`product-type`](product-type.md.nolink)型にまとめて返す。
115+
116+
```cpp
117+
[]<class Sndr, class Rcvr, size_t... Is>(
118+
basic-state<Sndr, Rcvr>* op, Sndr&& sndr, index_sequence<Is...>) noexcept(see below)
119+
-> decltype(auto) {
120+
auto& [_, data, ...child] = sndr;
121+
return product-type{connect(
122+
std::forward_like<Sndr>(child),
123+
basic-receiver<Sndr, Rcvr, integral_constant<size_t, Is>>{op})...};
124+
}
125+
```
126+
* index_sequence[link /reference/utility/index_sequence.md]
127+
* product-type[link product-type.md.nolink]
128+
* connect[link connect.md]
129+
* basic-receiver[link basic-receiver.md.nolink]
130+
* integral_constant[link /reference/type_traits/integral_constant.md]
131+
* see below[italic]
132+
133+
- テンプレートパラメータ制約 : ラムダ式中の`return`文の式が適格であること。
134+
- ラムダ式中の`return`文の式が例外送出する可能性がある場合は、`noexcept(false)`となる。そうでなければ、`noexcept(true)`となる。
135+
136+
137+
## バージョン
138+
### 言語
139+
- C++26
140+
141+
142+
## 関連項目
143+
- [`basic-sender`](basic-sender.md)
144+
- [`basic-receiver`](basic-receiver.md.nolink)
145+
- [`execution::operation_state`](operation_state.md)
146+
147+
148+
## 参照
149+
- [P2300R10 `std::execution`](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2300r10.html)
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# basic-sender
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 Tag, class Data, class... Child>
10+
struct basic-sender : product-type<Tag, Data, Child...> { // exposition only
11+
using sender_concept = sender_t;
12+
using indices-for = index_sequence_for<Child...>; // exposition only
13+
14+
decltype(auto) get_env() const noexcept {
15+
auto& [_, data, ...child] = *this;
16+
return impls-for<Tag>::get-attrs(data, child...);
17+
}
18+
19+
template<decays-to<basic-sender> Self, receiver Rcvr>
20+
auto connect(this Self&& self, Rcvr rcvr) noexcept(see below)
21+
-> basic-operation<Self, Rcvr> {
22+
return {std::forward<Self>(self), std::move(rcvr)};
23+
}
24+
25+
template<decays-to<basic-sender> Self, class Env>
26+
auto get_completion_signatures(this Self&& self, Env&& env) noexcept
27+
-> completion-signatures-for<Self, Env> {
28+
return {};
29+
}
30+
};
31+
}
32+
```
33+
* product-type[link product-type.md.nolink]
34+
* sender_t[link sender.md]
35+
* index_sequence_for[link /reference/utility/index_sequence_for.md]
36+
* impls-for[link impls-for.md]
37+
* receiver[link receiver.md]
38+
* basic-operation[link basic-operation.md]
39+
* this Self[link /lang/cpp23/deducing_this.md.nolink]
40+
* see below[italic]
41+
42+
## 概要
43+
`basic-sender`は、Senderアルゴリズム動作仕様定義で用いられる説明専用のクラステンプレートである。
44+
45+
`basic-sender<Tag, Data, Child...>`は[`sender`](sender.md)のモデルであり、[Senderアルゴリズム構築](make-sender.md)の結果型として利用される。
46+
47+
- `Tag` : [Senderタグ](tag_of_t.md.nolink)(例:[`just`](just.md), [`then`](then.md.nolink))
48+
- `Data` : Senderアルゴリズムに指定された追加の引数。複数個の引数は[`product-type`](product-type.md.nolink)型を用いて単一値として保持する。
49+
- `Child` : 子Senderのリスト。Senderファクトリでは0個、Senderアダプタでは通常1個の子Senderを保持する。
50+
51+
52+
## クラス仕様
53+
`basic-sender`の特殊化が集成体となるか否かは未規定である。
54+
`basic-sender`型の式は[構造化束縛](/lang/cpp17/structured_bindings.md)における初期化子として利用できる。
55+
56+
`basic-sender::connect`メンバ関数`noexcept`節の式は下記の通り。
57+
58+
```cpp
59+
is_nothrow_constructible_v<basic-operation<Self, Rcvr>, Self, Rcvr>
60+
```
61+
* is_nothrow_constructible_v[link /reference/type_traits/is_nothrow_constructible.md]
62+
* basic-operation[link basic-operation.md]
63+
64+
説明専用のエイリアステンプレート`completion-signatures-for`は、下記の通り定義される。
65+
66+
```
67+
template<class Sndr, class Env>
68+
using completion-signatures-for = see below; // exposition only
69+
```
70+
* see below[italic]
71+
72+
説明用の`sndr``decltype((sndr))``Sndr`型となる式、`rcvr`[`sender_in`](sender_in.md)`<Sndr, Env> == true`となる[環境](../queryable.md)`Env`に関連付けられた[`Receiver`](receiver.md)とする。
73+
74+
`completion-signatures-for<Sndr, Env>`[`completion_signatures`](completion_signatures.md)の特殊化であり、そのテンプレート引数は `sndr``rcvr`との[接続(connect)](connect.md)結果[Operation State](operation_state.md)[開始(start)](start.md)して得られる可能性のある結果の完了シグネチャ集合となる。
75+
76+
[`sender_in`](sender_in.md)`<Sndr, Env> == false`となる場合、`completion-signatures-for<Sndr, Env>`[`completion_signatures`](completion_signatures.md)の特殊化ではない別の型となる。
77+
処理系(標準ライブラリ実装者)は、この型を用いてユーザにエラー理由を通知することが推奨される。
78+
79+
80+
## バージョン
81+
### 言語
82+
- C++26
83+
84+
85+
## 関連項目
86+
- [`make-sender`](make-sender.md)
87+
- [`execution::sender`](sender.md)
88+
89+
90+
## 参照
91+
- [P2300R10 `std::execution`](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2300r10.html)

reference/execution/execution/connect.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ int main()
209209
* ex::connect[color ff0000]
210210
* ex::receiver_t[link receiver.md]
211211
* ex::sender[link sender.md]
212-
* ex::just[link just.md.nolink]
212+
* ex::just[link just.md]
213213
* ex::operation_state[link operation_state.md]
214214
* ex::start[link start.md]
215215

reference/execution/execution/error_types_of_t.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ int main()
5252
```
5353
* ex::error_types_of_t[color ff0000]
5454
* ex::sender[link sender.md]
55-
* ex::just[link just.md.nolink]
55+
* ex::just[link just.md]
5656
* ex::just_error[link just_error.md.nolink]
5757

5858
### 出力

reference/execution/execution/get_completion_signatures.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ int main()
6868
```
6969
* ex::get_completion_signatures[color ff0000]
7070
* ex::sender[link sender.md]
71-
* ex::just[link just.md.nolink]
71+
* ex::just[link just.md]
7272
* ex::completion_signatures[link completion_signatures.md]
7373
* ex::env<>[link env.md]
7474
* ex::set_value_t[link set_value.md]

reference/execution/execution/get_env.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ int main()
5252
```
5353
* ex::get_env[color ff0000]
5454
* ex::sender[link sender.md]
55-
* ex::just[link just.md.nolink]
55+
* ex::just[link just.md]
5656

5757
### 出力
5858
```

0 commit comments

Comments
 (0)