Skip to content

Commit e0f4f29

Browse files
author
cpprefjp-autoupdate
committed
update automatically
1 parent 823cd5a commit e0f4f29

File tree

3 files changed

+47
-116
lines changed

3 files changed

+47
-116
lines changed

reference/mutex/lock_guard.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@
188188

189189
<p class="text-right"><small>
190190
最終更新日時(UTC):
191-
<span itemprop="datePublished" content="2024-12-21T02:23:16">
192-
2024年12月21日 02時23分16秒
191+
<span itemprop="datePublished" content="2024-12-21T04:04:29">
192+
2024年12月21日 04時04分29秒
193193
</span>
194194
<br/>
195195
<span itemprop="author" itemscope itemtype="http://schema.org/Person">
@@ -315,15 +315,15 @@ <h3>基本的な使い方</h3>
315315
</div></p>
316316
<h4>出力例</h4>
317317
<p><pre><code>value:5
318-
value:6
319-
value:7
320-
value:8
321-
value:9
322318
value:0
319+
value:6
323320
value:1
324321
value:2
325322
value:3
323+
value:7
326324
value:4
325+
value:8
326+
value:9
327327
</code></pre></p>
328328
<h2>バージョン</h2>
329329
<h3>言語</h3>

rss.xml

Lines changed: 40 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,48 @@
22
<feed xmlns="http://www.w3.org/2005/Atom">
33
<title>cpprefjp - C++日本語リファレンス</title>
44
<link href="https://cpprefjp.github.io" />
5-
<updated>2024-12-21T02:26:18.973075</updated>
6-
<id>a786e704-e4c3-4576-8e87-41b386044623</id>
5+
<updated>2024-12-21T04:07:35.701117</updated>
6+
<id>de998b6d-b81a-4016-867e-9e6d53966ea7</id>
77

88

9+
<entry>
10+
<title>lock_guard -- lock_guard: 出力を更新してなかった</title>
11+
<link href="https://cpprefjp.github.io/reference/mutex/lock_guard.html"/>
12+
<id>815f9db290edf40da0e3c4415fdda0cebce66e05:reference/mutex/lock_guard.md</id>
13+
<updated>2024-12-21T13:04:29+09:00</updated>
14+
15+
<summary type="html">&lt;pre&gt;&lt;code&gt;diff --git a/reference/mutex/lock_guard.md b/reference/mutex/lock_guard.md
16+
index dab1029c9..781ade9c0 100644
17+
--- a/reference/mutex/lock_guard.md
18+
+++ b/reference/mutex/lock_guard.md
19+
@@ -86,15 +86,15 @@ int main()
20+
#### 出力例
21+
```
22+
value:5
23+
-value:6
24+
-value:7
25+
-value:8
26+
-value:9
27+
value:0
28+
+value:6
29+
value:1
30+
value:2
31+
value:3
32+
+value:7
33+
value:4
34+
+value:8
35+
+value:9
36+
```
37+
38+
## バージョン
39+
&lt;/code&gt;&lt;/pre&gt;</summary>
40+
41+
<author>
42+
<name>Akira Takahashi</name>
43+
<email>[email protected]</email>
44+
</author>
45+
</entry>
46+
947
<entry>
1048
<title>lock_guard -- lock_guard: 出力がうまく混ざらなかったのでランダム時間のsleepを入れた</title>
1149
<link href="https://cpprefjp.github.io/reference/mutex/lock_guard.html"/>
@@ -284,111 +322,4 @@ index cb813a6b4..8e36638dc 100644
284322
</author>
285323
</entry>
286324

287-
<entry>
288-
<title>宣言のみで使用しない変数の名前として_をサポート [P2169R4] -- C++26 宣言のみで使用しない変数の名前として_をサポート : ユースケースと仕様を追加</title>
289-
<link href="https://cpprefjp.github.io/lang/cpp26/nice_placeholder_with_no_name.html"/>
290-
<id>d67d018e6b43cbd65b4292f7facb135135e26a67:lang/cpp26/nice_placeholder_with_no_name.md</id>
291-
<updated>2024-12-21T10:43:29+09:00</updated>
292-
293-
<summary type="html">&lt;pre&gt;&lt;code&gt;diff --git a/lang/cpp26/nice_placeholder_with_no_name.md b/lang/cpp26/nice_placeholder_with_no_name.md
294-
index 58c78f94b..cb813a6b4 100644
295-
--- a/lang/cpp26/nice_placeholder_with_no_name.md
296-
+++ b/lang/cpp26/nice_placeholder_with_no_name.md
297-
@@ -10,22 +10,82 @@
298-
&amp;lt;!-- last lang caution --&amp;gt;
299-
300-
## 概要
301-
-C++17で採用された、`[[maybe_unused]]`属性を変数名`_`の場合、自動的につける。
302-
+C++26では、宣言だけして使用しない変数として、変数名`_`を特別扱いする。
303-
+
304-
+宣言だけして使用しない変数が必要な状況としては、以下のようなミューテックスのロック取得や、構造化束縛などがある:
305-
+
306-
+```cpp
307-
+// C++23まで
308-
+std::mutex mux;
309-
+std::tuple&amp;lt;T, U, V&amp;gt; f();
310-
+
311-
+void f() {
312-
+ std::lock_gaurd guard{mux}; // デストラクタでの自動解放だけしたいのでguard変数はとくに使わない
313-
+ auto [a, b, no_use] = f(); // 構造化束縛した一部の変数は使わない
314-
+}
315-
+```
316-
+
317-
+C++26では、変数名として`_`は[`[[maybe_unused]]`属性](/lang/cpp17/maybe_unused.md)が付加される、と規定される。
318-
+
319-
+```cpp
320-
+// C++26
321-
+std::mutex mux;
322-
+std::tuple&amp;lt;T, U, V&amp;gt; f();
323-
+
324-
+void f() {
325-
+ std::lock_gaurd _{mux}; // OK
326-
+ auto [a, b, _] = f(); // OK
327-
+}
328-
+```
329-
+
330-
+
331-
+## 仕様
332-
+- 変数名`_`は、「名前非依存 (name independent) の宣言」という名称で扱われ、実装への推奨としては `[[maybe_unused]]`属性が自動的に付加され、使用されなくても警告は出力されない:
333-
+ ```cpp
334-
+ auto _ = foo(); // [[maybe_unused]] auto _ = f(); と等価
335-
+ ```
336-
+
337-
+- 変数名`_`は、以下の状況では再宣言できる:
338-
+ - 自動変数
339-
+ - 非静的メンバ変数
340-
+ - 構造化束縛
341-
+ - ラムダ式のキャプチャでの導入子
342-
+- 再宣言された変数`_`を使用した場合、プログラムは不適格となる
343-
344-
```cpp
345-
+namespace a {
346-
+ auto _ = f(); // OK: &amp;#34;_&amp;#34;変数の宣言
347-
+ auto _ = f(); // エラー! &amp;#34;_&amp;#34;はこの名前空間ですでに定義されている
348-
+}
349-
+
350-
+void f() {
351-
+ auto _ = 42; // OK: &amp;#34;_&amp;#34;変数の宣言
352-
+ auto _ = 0; // OK: &amp;#34;_&amp;#34;変数の再宣言
353-
+ {
354-
+ auto _ = 1; // OK: シャドウイング
355-
+ assert(_ == 1); // OK
356-
+ }
357-
+ assert( _ == 42 ); // 不適格: 再宣言されたプレースホルダー変数の使用
358-
+}
359-
+```
360-
+
361-
+
362-
+## 例
363-
+```cpp example
364-
int main() {
365-
- [[maybe_unused]]int hardNamingVariable;
366-
// gccやclangの場合、-Wallオプションをつけると、
367-
// 変数が未使用だった場合、警告が出力される。
368-
// [[maybe_unused]]属性によって、これを抑制することができた。
369-
+ [[maybe_unused]] int hardNamingVariable;
370-
+
371-
// しかし、今後は、変数名が_であれば、自動的にその属性が適用されるようになる。
372-
+ // 以下のコードを-Wallでコンパイルしても、警告は表示されない。
373-
int _;
374-
- // このコードを-Wallでコンパイルしても、警告は表示されない。
375-
}
376-
```
377-
378-
## &amp;lt;a id=&amp;#34;relative-page&amp;#34; href=&amp;#34;#relative-page&amp;#34;&amp;gt;関連項目&amp;lt;/a&amp;gt;
379-
-- [\[\[maybe_unused\]\]属性 \[P0212R1\]](/lang/cpp17/maybe_unused.md)
380-
+- [C++17 `[[maybe_unused]]`属性](/lang/cpp17/maybe_unused.md)
381-
382-
## 参照
383-
-- [P2169R4 A nice placeholder with no name](https://open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2169r4.pdf)
384-
\ No newline at end of file
385-
+- [P2169R4 A nice placeholder with no name](https://open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2169r4.pdf)
386-
&lt;/code&gt;&lt;/pre&gt;</summary>
387-
388-
<author>
389-
<name>Akira Takahashi</name>
390-
<email>[email protected]</email>
391-
</author>
392-
</entry>
393-
394325
</feed>

sitemap.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9481,7 +9481,7 @@
94819481

94829482
<url>
94839483
<loc>https://cpprefjp.github.io/reference/mutex/lock_guard.html</loc>
9484-
<lastmod>2024-12-21T11:23:16+09:00</lastmod>
9484+
<lastmod>2024-12-21T13:04:29+09:00</lastmod>
94859485
<changefreq>daily</changefreq>
94869486
<priority>0.7</priority>
94879487
</url>

0 commit comments

Comments
 (0)