Skip to content

Commit 3e8c7c7

Browse files
committed
execution: receiver,receiver_of (#1384)
1 parent efc1070 commit 3e8c7c7

File tree

6 files changed

+184
-8
lines changed

6 files changed

+184
-8
lines changed

reference/execution/execution.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ namespace std::execution {
6262
6363
| 名前 | 説明 | 対応バージョン |
6464
|------|------|----------------|
65-
| [`execution::receiver`](execution/receiver.md.nolink) | Receiver (concept) | C++26 |
66-
| [`execution::receiver_of`](execution/receiver_of.md.nolink) | 完了ハンドラ指定Receiver (concept) | C++26 |
65+
| [`execution::receiver`](execution/receiver.md) | Receiver型 (concept) | C++26 |
66+
| [`execution::receiver_of`](execution/receiver_of.md) | 完了シグネチャ集合を持つReceiver (concept) | C++26 |
6767
| [`execution::set_value`](execution/set_value.md.nolink) | 値による完了関数 (customization point object) | C++26 |
6868
| [`execution::set_error`](execution/set_error.md.nolink) | エラーによる完了関数 (customization point object) | C++26 |
6969
| [`execution::set_stopped`](execution/set_stopped.md.nolink) | 停止による完了関数 (customization point object) | C++26 |
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# receiver
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>
10+
concept receiver =
11+
derived_from<typename remove_cvref_t<Rcvr>::receiver_concept, receiver_t> &&
12+
requires(const remove_cvref_t<Rcvr>& rcvr) {
13+
{ get_env(rcvr) } -> queryable;
14+
} &&
15+
move_constructible<remove_cvref_t<Rcvr>> &&
16+
constructible_from<remove_cvref_t<Rcvr>, Rcvr>;
17+
18+
struct receiver_t {}; // タグ型
19+
}
20+
```
21+
* get_env[link get_env.md.nolink]
22+
* queryable[link queryable.md.nolink]
23+
* derived_from[link /reference/concepts/derived_from.md]
24+
* move_constructible[link /reference/concepts/move_constructible.md]
25+
* constructible_from[link /reference/concepts/constructible_from.md]
26+
27+
## 概要
28+
`receiver`は、型`Rcvr`がReceiver型の要件を満たすことを表すコンセプトである。
29+
30+
`receiver_t`をメンバ型`Rcvr::receiver_concept`として定義するクラス型はReceiverとみなせる。
31+
32+
33+
## モデル
34+
`final`指定されたクラス型は`receiver`のモデルではない。
35+
36+
37+
## 例
38+
```cpp example
39+
#include <execution>
40+
namespace ex = std::execution;
41+
42+
struct SinkReceiver {
43+
using receiver_concept = ex::receiver_t;
44+
45+
void set_value(auto&&...) noexcept {}
46+
void set_error(auto&&) noexcept {}
47+
void set_stopped() noexcept {}
48+
};
49+
50+
int main()
51+
{
52+
static_assert(ex::receiver<SinkReceiver>);
53+
}
54+
```
55+
* ex::receiver[color ff0000]
56+
57+
### 出力
58+
```
59+
```
60+
61+
62+
## バージョン
63+
### 言語
64+
- C++26
65+
66+
### 処理系
67+
- [Clang](/implementation.md#clang): ??
68+
- [GCC](/implementation.md#gcc): ??
69+
- [ICC](/implementation.md#icc): ??
70+
- [Visual C++](/implementation.md#visual_cpp): ??
71+
72+
73+
## 関連項目
74+
- [`execution::receiver_of`](receiver_of.md)
75+
76+
77+
## 参照
78+
- [P2300R10 `std::execution`](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2300r10.html)
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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)

reference/execution/execution/sender_in.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ namespace std::execution {
2323
* valid-completion-signatures[link valid-completion-signatures.md.nolink]
2424
2525
## 概要
26-
`sender_in`は、[Sender型](sender.md)`Sndr`が[環境](env.md.nolink)`Env`において非同期操作を作成できること表すコンセプトである
26+
`sender_in`は、[Sender型](sender.md)`Sndr`が[環境](env.md.nolink)`Env`において非同期操作を作成できることを表すコンセプトである
2727
2828
2929
## モデル
30-
説明用に`sndr`を`decltype((sndr))`が`Sndr`型となる式、`rcvr`を環境`Env`に関連付けられた[Receiver](receiver.md.nolink)とする。
30+
説明用に`sndr`を`decltype((sndr))`が`Sndr`型となる式、`rcvr`を環境`Env`に関連付けられた[Receiver](receiver.md)とする。
3131
3232
また、ある完了操作の完了シグネチャが[`completion_signatures_of_t`](completion_signatures_of_t.md.nolink)`<Sndr, Env>`で取得される[`completion_signatures`](completion_signatures.md.nolink)リストに含まれるとき、`Sndr`と`Env`における許容可能完了(permissible completion)となる。
3333

reference/execution/execution/sender_to.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@ namespace std::execution {
1717
```
1818
* sender_in[link sender_in.md]
1919
* env_of_t[link env_of_t.md.nolink]
20-
* receiver_of[link receiver_of.md.nolink]
20+
* receiver_of[link receiver_of.md]
2121
* completion_signatures_of_t[link completion_signatures_of_t.md.nolink]
2222
* connect[link connect.md.nolink]
2323
2424
## 概要
25-
`sender_to`は、[Sender型](sender.md)`Sndr`が[Receiver型](receiver.md.nolink)`Rcvr`と接続可能であること表すコンセプトである
25+
`sender_to`は、[Sender型](sender.md)`Sndr`が[Receiver型](receiver.md)`Rcvr`と接続可能であることを表すコンセプトである
2626
2727
2828
## 例
2929
```cpp example
3030
#include <print>
3131
#include <execution>
32-
namespace ex = stdexec;
32+
namespace ex = std::execution;
3333
3434
struct ValueReceiver {
3535
using receiver_concept = ex::receiver_t;
@@ -55,6 +55,7 @@ int main()
5555
}
5656
```
5757
* ex::sender_to[color ff0000]
58+
* ex::sender[link sender.md]
5859
* ex::just[link just.md.nolink]
5960
* ex::operation_state[link operation_state.md.nolink]
6061
* ex::connect[link connect.md.nolink]
@@ -79,7 +80,7 @@ int main()
7980

8081
## 関連項目
8182
- [`execution::sender`](sender.md)
82-
- [`execution::receiver`](receiver.md.nolink)
83+
- [`execution::receiver`](receiver.md)
8384

8485

8586
## 参照

working_style.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ C++11以降対応については対応バージョンを明記します。バー
7070
| base class | 基底クラス |
7171
| bidirectional iterator | 双方向イテレータ |
7272
| bucket | バケット |
73+
| completion operation | 完了操作 |
7374
| completion signature | 完了シグネチャ |
7475
| complexity | 計算量 |
7576
| compound type | 複合型 |

0 commit comments

Comments
 (0)