2
2
<feed xmlns =" http://www.w3.org/2005/Atom" >
3
3
<title >cpprefjp - C++日本語リファレンス</title >
4
4
<link href =" https://cpprefjp.github.io" />
5
- <updated >2024-04-30T14:38:51.283716 </updated >
6
- <id >b769832f-9b6b-494e-99d3-a530066f63af </id >
5
+ <updated >2024-04-30T15:33:30.991579 </updated >
6
+ <id >1c85f645-130c-49f6-aec5-6267f3741f42 </id >
7
7
8
8
9
+ <entry >
10
+ <title >デストラクタ -- promiseデストラクタが例外を格納するコード例を作成 #1270</title >
11
+ <link href =" https://cpprefjp.github.io/reference/future/promise/op_destructor.html" />
12
+ <id >8e854b8d24bb6774f4e3622c881edc0addde5614:reference/future/promise/op_destructor.md</id >
13
+ <updated >2024-05-01T00:29:19+09:00</updated >
14
+
15
+ <summary type =" html" >< pre>< code> diff --git a/reference/future/promise/op_destructor.md b/reference/future/promise/op_destructor.md
16
+ index 6203910d3..a922bd7d3 100644
17
+ --- a/reference/future/promise/op_destructor.md
18
+ +++ b/reference/future/promise/op_destructor.md
19
+ @@ -18,11 +18,44 @@
20
+ 2. 共有状態を解放する。
21
+
22
+ ## 例
23
+ -```cpp
24
+ +```cpp example
25
+ +#include & lt;iostream& gt;
26
+ +#include & lt;future& gt;
27
+ +#include & lt;thread& gt;
28
+ +#include & lt;utility& gt;
29
+ +
30
+ +void calc(std::promise& lt;int& gt; p)
31
+ +{
32
+ + // 通常行う p.set_value() をしなかったとする
33
+ +
34
+ + // ここで promise のデストラクタが例外オブジェクトを書き込む
35
+ +}
36
+ +
37
+ +int main()
38
+ +{
39
+ + std::promise& lt;int& gt; p;
40
+ + std::future& lt;int& gt; f = p.get_future();
41
+ +
42
+ + std::thread t(calc, std::move(p));
43
+ +
44
+ + try {
45
+ + std::cout & lt;& lt; f.get() & lt;& lt; std::endl; // 上で書き込まれた例外が送出される
46
+ + }
47
+ + catch (std::future_error& amp; e) {
48
+ + std::cout & lt;& lt; e.what() & lt;& lt; std::endl;
49
+ + }
50
+ +
51
+ + t.join();
52
+ +}
53
+ ```
54
+ +* std::future[link /reference/future/future.md]
55
+ +* p.get_future()[link get_future.md]
56
+ +* std::move[link /reference/utility/move.md]
57
+ +* f.get()[link /reference/future/future/get.md]
58
+
59
+ -### 出力
60
+ +### 出力例
61
+ ```
62
+ +std::future_error: Broken promise
63
+ ```
64
+
65
+ ## バージョン
66
+ < /code>< /pre> </summary >
67
+
68
+ <author >
69
+ <name >tshino</name >
70
+
71
+ </author >
72
+ </entry >
73
+
9
74
<entry >
10
75
<title >デストラクタ -- 共有状態を放棄するとき例外を格納する動作を追記(規格に明記された3メソッド) #1270</title >
11
76
<link href =" https://cpprefjp.github.io/reference/future/packaged_task/op_destructor.html" />
@@ -180,34 +245,4 @@ index 50f3d223f..de63ef902 100644
180
245
</author >
181
246
</entry >
182
247
183
- <entry >
184
- <title >async -- `std::async` throw `std::system_error`</title >
185
- <link href =" https://cpprefjp.github.io/reference/future/async.html" />
186
- <id >0a7bbedcfb3cbe0c6fc59102d25a3e71a2447461:reference/future/async.md</id >
187
- <updated >2024-04-27T16:04:39+09:00</updated >
188
-
189
- <summary type =" html" >< pre>< code> diff --git a/reference/future/async.md b/reference/future/async.md
190
- index 50f3d223f..de63ef902 100644
191
- --- a/reference/future/async.md
192
- +++ b/reference/future/async.md
193
- @@ -85,9 +85,9 @@ namespace std {
194
- 非同期実行される関数オブジェクト`f`の結果値取得のための`future`オブジェクトを返す。
195
-
196
- ## 例外
197
- -この関数は、以下のerror conditionを持つ[`future_error`](future_error.md)例外オブジェクトを送出する可能性がある:
198
- +この関数は、以下のerror conditionを持つ[`system_error`](/reference/system_error/system_error.md)例外オブジェクトを送出する可能性がある:
199
-
200
- -- [`resource_unavailable_try_again`](future_errc.md) : [`launch::async`](launch.md)が指定され、新たなスレッドを起動しようとしたができなかった
201
- +- [`resource_unavailable_try_again`](/reference/system_error/errc.md) : [`launch::async`](launch.md)が指定され、新たなスレッドを起動しようとしたができなかった
202
-
203
- ## launch::asyncポリシーを指定した場合の注意点
204
-
205
- < /code>< /pre> </summary >
206
-
207
- <author >
208
- <name >Nagarei</name >
209
-
210
- </author >
211
- </entry >
212
-
213
248
</feed >
0 commit comments