Skip to content

Commit 33a231f

Browse files
committed
C++23: 「ラムダ式で()を省略できる条件を緩和」を追加 (close #1041)
1 parent 8bedbe3 commit 33a231f

File tree

4 files changed

+35
-2
lines changed

4 files changed

+35
-2
lines changed

implementation-status.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@
272272
| P2448R2: [`constexpr`関数が定数実行できない場合でも適格とする](/lang/cpp23/relaxing_some_constexpr_restrictions.md) | | 13 | 17 (partial) | 2024.0 (partial) | - |
273273
| P2647R1: [`constexpr`関数内での`static constexpr`変数を許可](/lang/cpp23/permitting_static_constexpr_variables_in_constexpr_functions.md.nolink) | 13 | - | 16 | 2023.2 | - |
274274
| P2564R3: [`constexpr`関数内で`consteval`関数を呼び出せない問題を緩和](/lang/cpp23/consteval_needs_to_propagate_up.md.nolink) | | - | 17 | - | 2024.0 |
275-
| P1102R2: [ラムダ式で`()`を省略できる条件を緩和](/lang/cpp23/down_with_lambda_parens.md.nolink) | キャプチャや修飾をともなってもパラメータリストが空であれば`()`を省略できる | 11 | 13 | 2022.2 | - |
275+
| P1102R2: [ラムダ式で`()`を省略できる条件を緩和](/lang/cpp23/down_with_lambda_parens.md) | 修飾や戻り値型をともなってもパラメータリストが空であれば`()`を省略できる | 11 | 13 | 2022.2 | - |
276276
| P2173R1: [ラムダ式に対する属性](/lang/cpp23/attributes_on_lambda_expressions.md.nolink) | ラムダ式のいくつかの箇所に属性を記述できるようにする | 9 | 13 | 2022.2 | - |
277277
| P1774R8: [コード内容の仮定をコンパイラに伝えるassume属性](/lang/cpp23/portable_assumptions.md) | 最適化のために、コードの仮定をコンパイラに伝える属性を標準化する | 13 | - | - | - |
278278
| P2316R2: [文字リテラルエンコーディングを一貫させる](/lang/cpp23/consistent_character_literal_encoding.md.nolink) | プリプロセッサの条件式での文字リテラルの扱いをC++式と同様にする | yes | yes | 2022.2 | 2022 |

lang/cpp11/lambda_expressions.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,8 @@ for_each(array, array + 4, <&>(double d) ( sum += factor ∗ d ));
530530
- [C++17 ラムダ式での`*this`のコピーキャプチャ](/lang/cpp17/lambda_capture_of_this_by_value.md)
531531
- [C++20 ラムダ式のキャプチャとして`[=, this]`を許可する](/lang/cpp20/allow_lambda_capture_equal_this.md)
532532
- [C++20 ジェネリックラムダのテンプレート構文](/lang/cpp20/familiar_template_syntax_for_generic_lambdas.md)
533+
- [C++23 ラムダ式で()を省略できる条件を緩和](/lang/cpp23/down_with_lambda_parens.md)
534+
- [C++23 ラムダ式に対する属性](/lang/cpp23/attributes_on_lambda_expressions.md.nolink)
533535

534536

535537
## 参照

lang/cpp23.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ C++23とは、2023年中に改訂される予定の、C++バージョンの通
8080

8181
| 言語機能 | 説明 |
8282
|----------|------|
83-
| [ラムダ式で`()`を省略できる条件を緩和](cpp23/down_with_lambda_parens.md.nolink) | キャプチャや修飾をともなってもパラメータリストが空であれば`()`を省略できる |
83+
| [ラムダ式で`()`を省略できる条件を緩和](cpp23/down_with_lambda_parens.md) | 修飾や戻り値型をともなってもパラメータリストが空であれば`()`を省略できる |
8484
| [ラムダ式に対する属性](cpp23/attributes_on_lambda_expressions.md.nolink) | ラムダ式のいくつかの箇所に属性を記述できるようにする |
8585

8686

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# ラムダ式で()を省略できる条件を緩和
2+
* cpp23[meta cpp]
3+
4+
## 概要
5+
C++23では、ラムダ式のパラメータリストが空であれば、以下の要素を含む場合であってもパラメータリストの `()` を省略できる。
6+
7+
- `constexpr`
8+
- `mutable`
9+
- `consteval`
10+
- `noexcept`
11+
- 属性 (C++23時点でここに指定できる標準属性なし)
12+
- 後置戻り値型
13+
- `requires`
14+
15+
```cpp
16+
auto f1 = [b = std::move(a)] () { … }; // C++20 OK, C++23 OK
17+
auto f2 = [b = std::move(a)] { … }; // C++20 OK, C++23 OK
18+
19+
auto f3 = [b = std::move(a)] () mutable { … }; // C++20 OK, C++23 OK
20+
auto f4 = [b = std::move(a)] mutable { … }; // C++20 NG, C++23 OK
21+
22+
auto f5 = [] constexpr mutable noexcept -> bool { return true; }; // C++23 OK
23+
```
24+
25+
26+
## 関連項目
27+
- [C++11 ラムダ式](/lang/cpp11/lambda_expressions.md)
28+
29+
30+
## 参照
31+
- [P1102R2 Down with `()`!](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1102r2.html)

0 commit comments

Comments
 (0)