Repository navigation
Expand file tree
/
Copy pathrss.xml
More file actions
234 lines (203 loc) · 8.14 KB
/
Copy pathrss.xml
File metadata and controls
234 lines (203 loc) · 8.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>cpprefjp - C++日本語リファレンス</title>
<link href="https://cpprefjp.github.io" />
<updated>2026-11-19T03:55:12.605919</updated>
<id>8b3cb520-e73a-4989-b145-8be281701bd5</id>
<entry>
<title>file_time -- fixing file_time wrong output example</title>
<link href="https://cpprefjp.github.io/reference/chrono/file_time.html"/>
<id>248171dbdbadc7087be28f91ed22ba5843b30888:reference/chrono/file_time.md</id>
<updated>2026-11-19T12:50:01+09:00</updated>
<summary type="html"><pre><code>diff --git a/reference/chrono/file_time.md b/reference/chrono/file_time.md
index de27171de..921a839a3 100644
--- a/reference/chrono/file_time.md
+++ b/reference/chrono/file_time.md
@@ -147,7 +147,7 @@ int main()
#### 出力例
```
-2019-10-24 11:15:10
+2019-10-24 20:15:10
2019-10-24 11:15:10
UTC
540
</code></pre></summary>
<author>
<name>rotarymars</name>
<email>s.goto2050@gmail.com</email>
</author>
</entry>
<entry>
<title>copysign -- fixing copysign wrong implementation example</title>
<link href="https://cpprefjp.github.io/reference/cmath/copysign.html"/>
<id>05b2049b4764f55e7b3105cf81781616c2ee7cf6:reference/cmath/copysign.md</id>
<updated>2026-11-19T12:49:17+09:00</updated>
<summary type="html"><pre><code>diff --git a/reference/cmath/copysign.md b/reference/cmath/copysign.md
index 39312958c..c84e758f9 100644
--- a/reference/cmath/copysign.md
+++ b/reference/cmath/copysign.md
@@ -119,32 +119,25 @@ int main()
namespace std {
float copysign(float x, float y)
{
- float absolute_value = std::isnan(x) ?
- std::numeric_limits&lt;float&gt;::quiet_NaN() :
- std::abs(x);
- return y &gt;= 0 ? absolute_value : -absolute_value;
+ float absolute_value = std::abs(x);
+ return std::signbit(y) ? -absolute_value : absolute_value;
}
double copysign(double x, double y)
{
- double absolute_value = std::isnan(x) ?
- std::numeric_limits&lt;double&gt;::quiet_NaN() :
- std::abs(x);
- return y &gt;= 0 ? absolute_value : -absolute_value;
+ double absolute_value = std::abs(x);
+ return std::signbit(y) ? -absolute_value : absolute_value;
}
long double copysign(long double x, long double y)
{
- long double absolute_value = std::isnan(x) ?
- std::numeric_limits&lt;long double&gt;::quiet_NaN() :
- std::abs(x);
- return y &gt;= 0 ? absolute_value : -absolute_value;
+ long double absolute_value = std::abs(x);
+ return std::signbit(y) ? -absolute_value : absolute_value;
}
}
```
* std::abs[link abs.md]
-* std::isnan[link isnan.md]
-* quiet_NaN()[link /reference/limits/numeric_limits/quiet_nan.md]
+* std::signbit[link signbit.md]
## バージョン
</code></pre></summary>
<author>
<name>rotarymars</name>
<email>s.goto2050@gmail.com</email>
</author>
</entry>
<entry>
<title>コンストラクタ -- fixing barrier constructor wrong sample</title>
<link href="https://cpprefjp.github.io/reference/barrier/barrier/op_constructor.html"/>
<id>dbd60ff0be210941add4f596ba373fec716494f4:reference/barrier/barrier/op_constructor.md</id>
<updated>2026-11-19T12:42:05+09:00</updated>
<summary type="html"><pre><code>diff --git a/reference/barrier/barrier/op_constructor.md b/reference/barrier/barrier/op_constructor.md
index 409bac4b6..7ba478cf8 100644
--- a/reference/barrier/barrier/op_constructor.md
+++ b/reference/barrier/barrier/op_constructor.md
@@ -59,7 +59,7 @@ int main() {
std::barrier&lt;&gt; sync1{2};
// 完了関数付きのバリアを定義
- std::barrier sync2{2, []{
+ std::barrier sync2{2, []() noexcept {
// 完了関数はバリアに関与するいずれか一つのスレッド上でのみ実行されることが保証される
std::cout &lt;&lt; &#34;finished @&#34; &lt;&lt; std::this_thread::get_id() &lt;&lt; std::endl;
}};
</code></pre></summary>
<author>
<name>rotarymars</name>
<email>s.goto2050@gmail.com</email>
</author>
</entry>
<entry>
<title>barrier -- fixing barrier wrong sample</title>
<link href="https://cpprefjp.github.io/reference/barrier/barrier.html"/>
<id>b4a60cfba2b374fcb2b1bf5117e8f00fde81c8c9:reference/barrier/barrier.md</id>
<updated>2026-11-19T12:40:30+09:00</updated>
<summary type="html"><pre><code>diff --git a/reference/barrier/barrier.md b/reference/barrier/barrier.md
index b281b44fc..37e46416e 100644
--- a/reference/barrier/barrier.md
+++ b/reference/barrier/barrier.md
@@ -88,6 +88,7 @@ namespace std {
#include &lt;iostream&gt;
#include &lt;thread&gt;
#include &lt;mutex&gt;
+#include &lt;vector&gt;
constexpr int NWORKERS = 2; // ワーカ数
constexpr int NPHASES = 3; // フェーズ数
@@ -103,9 +104,10 @@ int main()
// バリア同期: 初期カウント値=ワーカ数+1(メインスレッド)
std::barrier&lt;&gt; sync{NWORKERS+1};
- // ワーカスレッド群をFire-and-Forget起動
+ // ワーカスレッド群を起動
+ std::vector&lt;std::thread&gt; workers;
for (int id = 1; id &lt;= NWORKERS; id++) {
- std::thread([&amp;,id]{
+ workers.emplace_back([&amp;,id]{
for (int phase = 1; phase &lt;= NPHASES; phase++) {
{ // ワーカスレッドのフェーズタスクを実行
std::lock_guard lk{cout_mtx};
@@ -115,7 +117,7 @@ int main()
// 合流ポイント: メインスレッド+他ワーカスレッドと同期
sync.arrive_and_wait();
}
- }).detach();
+ });
}
// メインスレッド処理
@@ -128,11 +130,17 @@ int main()
// 合流ポイント: 全ワーカスレッドと同期
sync.arrive_and_wait();
}
+
+ // バリアsyncの破棄前に、全ワーカスレッドの終了を待機する
+ for (std::thread&amp; t : workers) {
+ t.join();
+ }
}
```
* std::barrier[color ff0000]
* arrive_and_wait()[link barrier/arrive_and_wait.md]
-* detach()[link /reference/thread/thread/detach.md]
+* emplace_back[link /reference/vector/vector/emplace_back.md]
+* t.join()[link /reference/thread/thread/join.md]
### 出力例
```
</code></pre></summary>
<author>
<name>rotarymars</name>
<email>s.goto2050@gmail.com</email>
</author>
</entry>
<entry>
<title>lower_bound -- fixing ranges::lower_bound wrong sample</title>
<link href="https://cpprefjp.github.io/reference/algorithm/ranges_lower_bound.html"/>
<id>d1d7e21defac58211aa3f4b709443f7cb7278342:reference/algorithm/ranges_lower_bound.md</id>
<updated>2026-11-19T12:33:45+09:00</updated>
<summary type="html"><pre><code>diff --git a/reference/algorithm/ranges_lower_bound.md b/reference/algorithm/ranges_lower_bound.md
index b832d27c4..336720bdc 100644
--- a/reference/algorithm/ranges_lower_bound.md
+++ b/reference/algorithm/ranges_lower_bound.md
@@ -237,12 +237,13 @@ struct X {
};
int main() {
+ // 要素はnameメンバ変数をキーとして昇順に並んでいる
std::vector&lt;X&gt; v = {
- {1, &#34;Carol&#34;},
{3, &#34;Alice&#34;},
{4, &#34;Bob&#34;},
- {5, &#34;Eve&#34;},
- {6, &#34;Dave&#34;}
+ {1, &#34;Carol&#34;},
+ {6, &#34;Dave&#34;},
+ {5, &#34;Eve&#34;}
};
const std::string key = &#34;Bob&#34;;
@@ -277,8 +278,8 @@ int main() {
#### 出力
```
-id=4 name=Bob pos=2
-id=4 name=Bob pos=2
+id=4 name=Bob pos=1
+id=4 name=Bob pos=1
```
## バージョン
</code></pre></summary>
<author>
<name>rotarymars</name>
<email>s.goto2050@gmail.com</email>
</author>
</entry>
</feed>