Skip to content

Commit

Permalink
coroutine: LWG3460を反映
Browse files Browse the repository at this point in the history
  • Loading branch information
yohhoy committed Jan 11, 2023
1 parent df12b1d commit 1f03563
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
14 changes: 12 additions & 2 deletions reference/coroutine/coroutine_handle.md
Expand Up @@ -15,7 +15,7 @@ namespace std {
};

template<class Promise>
struct coroutine_handle : coroutine_handle<> {
struct coroutine_handle {
// (メンバ宣言は省略)
};
}
Expand All @@ -30,7 +30,7 @@ namespace std {
例: 後述サンプルコードでは`task`クラス内に隠蔽されており、コルーチン`f`や関数`main`から間接的に利用される。
`coroutine_handle<void>`または単に`coroutine_handle<>`は、Promise型について型消去(Type-erased)されたコルーチンハンドルとして取り扱える。
コルーチンのPromise型を明示した`coroutine_handle<Promise>`は型消去された`coroutine_handle<>`から公開派生されており、前者から後者への暗黙変換を行うことが可能となっている
コルーチンのPromise型を明示した`coroutine_handle<Promise>`から`coroutine_handle<>`へと暗黙変換が可能となっている
C++コルーチンとC API(コールバック関数へのポインタと`void*`をとる関数)との組合せ利用を可能とするため、`coroutine_handle`とポインタ型`void*`との相互変換がサポートされる。
Expand All @@ -51,6 +51,12 @@ C++コルーチンとC API(コールバック関数へのポインタと`void*
|-----------------|----------------|----------------|
| [`address`](coroutine_handle/address.md) | コルーチンハンドルに対応するアドレス値 | C++20 |
### 変換
| 名前 | 説明 | 対応バージョン |
|-----------------|---------------|----------------|
| `operator coroutine_handle<>` | 型消去されたコルーチンハンドルを返す | C++20 |
### 観測
| 名前 | 説明 | 対応バージョン |
Expand Down Expand Up @@ -188,3 +194,7 @@ result=42

## 関連項目
- [C++20 コルーチン](/lang/cpp20/coroutines.md)


## 参照
- [LWG3460 Unimplementable `noop_coroutine_handle` guarantees](https://cplusplus.github.io/LWG/issue3460)
4 changes: 4 additions & 0 deletions reference/coroutine/coroutine_handle/from_promise.md
Expand Up @@ -25,6 +25,10 @@ Promiseオブジェクトから対応するコルーチンハンドルを取得
[`addressof`](/reference/memory/addressof.md)`(h.`[`promise()`](promise.md)`) ==` [`addressof`](/reference/memory/addressof.md)`(p)`
## 備考
型消去されたコルーチンハンドル`coroutine_handle<>`では、本メンバ関数は提供されない。
## バージョン
### 言語
- C++20
Expand Down
4 changes: 4 additions & 0 deletions reference/coroutine/coroutine_handle/promise.md
Expand Up @@ -21,6 +21,10 @@ Promise& promise() const;
コルーチンのPromiseオブジェクトへの参照。


## 備考
型消去されたコルーチンハンドル`coroutine_handle<>`では、本メンバ関数は提供されない。


## バージョン
### 言語
- C++20
Expand Down
14 changes: 10 additions & 4 deletions reference/coroutine/noop_coroutine_handle.md
Expand Up @@ -9,8 +9,10 @@ namespace std {
struct noop_coroutine_promise {};

template<>
struct coroutine_handle<noop_coroutine_promise> : coroutine_handle<>
struct coroutine_handle<noop_coroutine_promise>
{
constexpr operator coroutine_handle<>() const noexcept;

constexpr explicit operator bool() const noexcept;
constexpr bool done() const noexcept;

Expand All @@ -29,8 +31,7 @@ namespace std {
using noop_coroutine_handle = coroutine_handle<noop_coroutine_promise>;
}
```
* coroutine_handle<>[link coroutine_handle.md]
* coroutine_handle<noop_coroutine_promise>[link coroutine_handle.md]
* coroutine_handle[link coroutine_handle.md]
* unspecified[italic]
Expand All @@ -41,6 +42,11 @@ namespace std {
## メンバ関数
### 変換
| 名前 | 説明 | 対応バージョン |
|-----------------|---------------|----------------|
| `operator coroutine_handle<>` | 型消去されたコルーチンハンドルを返す | C++20 |
### 観測
| 名前 | 説明 | 対応バージョン |
Expand Down Expand Up @@ -87,4 +93,4 @@ namespace std {
## 参照
- [P0913R1 Add symmetric coroutine control transfer](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0913r1.html)
- [LWG3460. Unimplementable noop_coroutine_handle guarantees](https://cplusplus.github.io/LWG/issue3460)
- [LWG3460 Unimplementable `noop_coroutine_handle` guarantees](https://cplusplus.github.io/LWG/issue3460)

0 comments on commit 1f03563

Please sign in to comment.