File tree Expand file tree Collapse file tree 4 files changed +54
-3
lines changed
Expand file tree Collapse file tree 4 files changed +54
-3
lines changed Original file line number Diff line number Diff line change 306306| P3034R1: [ モジュール宣言でのモジュール名のマクロ展開を禁止する] ( /lang/cpp26/module_declarations_shouldnt_be_macros.md.nolink ) | ` export module MACRO_NAME; ` を禁止 | | | | |
307307| P2809R3: [ 自明な無限ループは未定義動作ではないと規定] ( /lang/cpp26/trivial_infinite_loops_are_not_undefined_behavior.md.nolink ) | 並行プログラムの進行保証などを考慮して無限ループを未定義動作ではないものとする | 14 | 19 | | |
308308| P2795R5: [ 未初期化変数の読み取りを不正動作 (erroneous behaviour: EB) とする] ( /lang/cpp26/erroneous_behaviour_for_uninitialized_reads.md.nolink ) | 初期化されていない自動変数の読み取りの安全性を規定する | | | | |
309- | P2573R2: [ 関数宣言を削除する理由を指定できるようにする] ( /lang/cpp26/delete_reason.md.nolink ) | ` f() = delete("reason"); ` | 15 | 19 | | |
309+ | P2573R2: [ 関数宣言を削除する理由を指定できるようにする] ( /lang/cpp26/delete_reason.md ) | ` f() = delete("reason"); ` | 15 | 19 | | |
310310| P2893R3: [ 可変引数テンプレートで` friend ` 宣言をできるようにする] ( /lang/cpp26/variadic_friends.md.nolink ) | クラステンプレートの可変引数テンプレートでまとめて` friend ` 宣言できるようにする | 15 | | | |
311311| P2747R2: [ ` constexpr ` 配置` new ` ] ( /lang/cpp26/constexpr_placement_new.md.nolink ) | 定数式の文脈での配置` new ` を許可 | | | | |
312312| P3144R2: [ 不完全型へのポインタに対する` delete ` を不適格とする] ( /lang/cpp26/deleting_a_pointer_to_an_incomplete_type_should_be_ill-formed.md.nolink ) | 未定義動作となる操作をコンパイルエラーとする | 15 | 19 | | |
Original file line number Diff line number Diff line change @@ -124,11 +124,15 @@ int main()
124124 - 非静的メンバ変数の特殊メンバ関数が削除定義されている場合、その変数をメンバとして持つクラスのその特殊メンバ関数は、暗黙的に削除定義される
125125
126126
127+ ## <a id =" relative-page " href =" #relative-page " >関連項目</a >
128+ - [ 関数宣言を削除する理由を指定できるようにする] ( /lang/cpp26/delete_reason.md )
129+
130+
127131## 参照
128132- [ N1582 Compiler Generated Defaults] ( http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1582.pdf )
129133- [ N1702 explicit class and default definitions] ( http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1702.pdf )
130134- [ N1707 explicit class and default definitions] ( http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1717.pdf )
131135- [ N2210 Defaulted and Deleted Functions] ( http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2210.html )
132136- [ N2326 Defaulted and Deleted Functions] ( http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2326.html )
133137- [ N3172 To move or not to move] ( http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3174.pdf )
134- - [ N2346 Defaulted and Deleted Functions] ( http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2346.htm )
138+ - [ N2346 Defaulted and Deleted Functions] ( http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2346.htm )
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ C++26とは、2026年中に改訂される予定の、C++バージョンの通
4141
4242| 言語機能 | 説明 |
4343| ----------| ------|
44- | [ 関数宣言を削除する理由を指定できるようにする] ( /lang/cpp26/delete_reason.md.nolink ) | ` f() = delete("reason"); ` |
44+ | [ 関数宣言を削除する理由を指定できるようにする] ( /lang/cpp26/delete_reason.md ) | ` f() = delete("reason"); ` |
4545
4646
4747### 属性
Original file line number Diff line number Diff line change 1+ # 関数宣言を削除する理由を指定できるようにする [ P2573R2]
2+ * cpp26[ meta cpp]
3+
4+ <!-- start lang caution -->
5+
6+ このページはC++26に採用される見込みの言語機能の変更を解説しています。
7+
8+ のちのC++規格でさらに変更される場合があるため[ 関連項目] ( #relative-page ) を参照してください。
9+
10+ <!-- last lang caution -->
11+
12+ ## 概要
13+ C++26では、関数をdelte宣言する際に、その理由をコンパイル時文字列で指定できるようになる。
14+
15+ ``` cpp
16+ // 別名の新たなAPIを用意する場合に、そちらに誘導する
17+ void newapi ();
18+ void oldapi () = delete("This old API is outdated and already been removed. Please use newapi() instead.");
19+
20+ template <typename T >
21+ struct A {/* … * /};
22+
23+ // 一部のオーバーロードが危険であるために禁止する場合
24+ template<typename T >
25+ A<T > factory(const T&) {/* process lvalue * /}
26+ template<typename T >
27+ A<T > factory(const T&&) = delete("Using rvalue to construct A may result in dangling reference");
28+
29+ // 一部の自動定義される特殊メンバ関数が
30+ // 低パフォーマンスを引き起こすために禁止する場合
31+ struct MoveOnly {
32+ // … (with move members defaulted or defined)
33+ MoveOnly(const MoveOnly&) = delete("Copy-construction is expensive; please use move construction instead.");
34+ MoveOnly& operator=(const MoveOnly&) = delete("Copy-assignment is expensive; please use move assignment instead.");
35+ };
36+ ```
37+
38+ これまでは削除理由を指定できなかったために、ユーザーが誤って削除済み関数にアクセスした際に「エラー!:削除された関数を呼び出そうとした」という情報しか得られなかった。削除理由が指定できるようになることで、その設計意図をユーザーに伝えられるようになる。
39+
40+
41+
42+ ## <a id="relative-page" href="#relative-page">関連項目</a>
43+ - [C++11 関数のdefault/delete宣言](/lang/cpp11/defaulted_and_deleted_functions.md)
44+
45+
46+ ## 参照
47+ - [P2573R2 `= delete("should have a reason");`](https://open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2573r2.html)
You can’t perform that action at this time.
0 commit comments