Skip to content

Commit 070dd0d

Browse files
committed
C++23 : 「無意味なexport宣言を禁止する」を追加 (close #1110)
1 parent 38888cf commit 070dd0d

File tree

4 files changed

+37
-2
lines changed

4 files changed

+37
-2
lines changed

implementation-status.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@
251251
| P2290R3: [エスケープシーケンスの区切り](/lang/cpp23/delimited_escape_sequences.md) | エスケープシーケンスの範囲を明確にする構文を追加する | 13 | 15 | 2023.2 | - |
252252
| P2266R3: [暗黙的なムーブを簡略化](/lang/cpp23/simpler_implicit_move.md.nolink) | 参照を返す関数の`return`文で暗黙的にムーブされない問題を修正 | 13 | 13 | 2022.2 | - |
253253
| P1787R6: [スコープと名前ルックアップの仕様整理](/lang/cpp23/declarations_and_where_to_find_them.md.nolink) | 複雑で不完全になっているスコープと名前ルックアップの仕様を整理し、一部の問題を解決する | - | - | - | - |
254-
| P2615R1: [無意味なexport宣言を禁止する](/lang/cpp23/meaningful_exports.md.nolink) | | - | - | - | - |
254+
| P2615R1: [無意味なexport宣言を禁止する](/lang/cpp23/meaningful_exports.md) | いくつかの不必要な宣言に対するモジュールexportを禁止する | - | - | - | - |
255255
| P2360R0: [初期化文での型の別名宣言を許可](/lang/cpp23/extend_init_statement_to_allow_alias_declaration.md) | `for (using T = int; T e : v) {}`を許可 | 12 | 14 | 2022.2 | - |
256256
| P2718R0: [範囲for文が範囲初期化子内で生じた一時オブジェクトを延命することを規定](lang/cpp23/lifetime_extension_in_range_based_for_loop.md) | | - | - | - | - |
257257
| P2324R2: [複合文の末尾へのラベルを許可](/lang/cpp23/labels_at_the_end_of_compound_statements.md) | C互換のため、複合文の末尾でのgoto文のラベルを許可する | 13 | 16 | 2023.2 | - |

lang/cpp20/modules.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,11 @@ int main() {
479479

480480
モジュールは、以上のような問題のないプログラム分割の仕組みとして導入された。
481481

482+
483+
## 関連項目
484+
- [C++23 無意味なexport宣言を禁止する](/lang/cpp23/meaningful_exports.md)
485+
486+
482487
## 参照
483488
- [[C++]C++20モジュールの変遷 - Module TSからC++20DISまで - 地面を見下ろす少年の足蹴にされる私](https://onihusube.hatenablog.com/entry/2021/05/28/214612)
484489
- [P1103R3 Merging Modules](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1103r3.pdf)

lang/cpp23.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ C++23とは、2023年中に改訂される予定の、C++バージョンの通
2222
| 言語機能 | 説明 |
2323
|----------|------|
2424
| [スコープと名前ルックアップの仕様整理](cpp23/declarations_and_where_to_find_them.md.nolink) | 複雑で不完全になっているスコープと名前ルックアップの仕様を整理し、一部の問題を解決する |
25-
| [無意味なexport宣言を禁止する](cpp23/meaningful_exports.md.nolink) | |
25+
| [無意味なexport宣言を禁止する](cpp23/meaningful_exports.md) | いくつかの不必要な宣言に対するモジュールexportを禁止する |
2626

2727

2828
### 制御構文

lang/cpp23/meaningful_exports.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# 無意味なexport宣言を禁止する
2+
* cpp23[meta cpp]
3+
4+
## 概要
5+
C++20時点でのモジュール定義では、いくつかの不必要なexport宣言ができてしまっていた。
6+
7+
```cpp
8+
template export void f();
9+
export template void f();
10+
export template<> void g(int);
11+
template<> export void g(int);
12+
export template<class T> struct trait<T*>;
13+
```
14+
15+
C++23では、本来必要のない以下の宣言に対するexport宣言を禁止する:
16+
17+
- 明示的なインスタンス化
18+
- 明示的な特殊化
19+
- export宣言
20+
21+
ただし、この変更のあとでも、`export { … }`で囲まれた中では、これらが含まれていてもコンパイルエラーにはならない。
22+
23+
24+
## 関連項目
25+
- [C++20 モジュール](/lang/cpp20/modules.md)
26+
27+
28+
## 参照
29+
- [P2615R1 Meaningful exports](https://open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2615r1.html)
30+
- [CWG Issue 2443. Meaningless template exports](https://wg21.cmeerw.net/cwg/issue2443)

0 commit comments

Comments
 (0)