diff --git a/implementation-status.html b/implementation-status.html
index 7ff1fb56ed4..1e775a250a0 100644
--- a/implementation-status.html
+++ b/implementation-status.html
@@ -164,8 +164,8 @@
最終更新日時(UTC):
-
- 2025年04月24日 05時15分59秒
+
+ 2025年04月25日 08時57分08秒
@@ -1855,7 +1855,7 @@
|
-P2738R1: 定数式でのvoid* からポインタ型へのキャストを許可 |
+P2738R1: 定数式でのvoid* からポインタ型へのキャストを許可 |
型消去のためにvoid* からポインタ型へのキャストを許可する |
14 |
17 |
@@ -1967,7 +1967,7 @@
|
-P3144R2: 不完全型へのポインタに対するdelete を不適格とする |
+P3144R2: 不完全型へのポインタに対するdelete を不適格とする |
未定義動作を引き起こす操作をコンパイルエラーとする |
15 |
19 |
diff --git a/lang/cpp11/constexpr.html b/lang/cpp11/constexpr.html
index edc81d06b65..429f14b555e 100644
--- a/lang/cpp11/constexpr.html
+++ b/lang/cpp11/constexpr.html
@@ -188,8 +188,8 @@
最終更新日時(UTC):
-
- 2025年04月03日 07時03分23秒
+
+ 2025年04月25日 08時57分08秒
@@ -387,6 +387,7 @@
C++23 constexpr
関数内でのstatic constexpr
変数を許可
C++23 constexpr
関数内でconsteval
関数を呼び出せない問題を軽減
C++26 定数評価での例外送出を許可
+C++26 定数式でのvoid*
からポインタ型へのキャストを許可
参照
diff --git a/lang/cpp26.html b/lang/cpp26.html
index cd76c801470..afa4403c795 100644
--- a/lang/cpp26.html
+++ b/lang/cpp26.html
@@ -176,8 +176,8 @@
最終更新日時(UTC):
-
- 2025年04月24日 05時33分10秒
+
+ 2025年04月25日 08時57分08秒
@@ -223,7 +223,7 @@ 変数
変数名_ は暗黙で[[maybe_unused]] が指定される |
-不完全型へのポインタに対するdelete を不適格とする |
+不完全型へのポインタに対するdelete を不適格とする |
未定義動作を引き起こす操作をコンパイルエラーとする |
@@ -376,7 +376,7 @@ 定数式
-定数式でのvoid* からポインタ型へのキャストを許可 |
+定数式でのvoid* からポインタ型へのキャストを許可 |
型消去のためにvoid* からポインタ型へのキャストを許可する |
diff --git a/lang/cpp26/constexpr_cast_from_voidptr.html b/lang/cpp26/constexpr_cast_from_voidptr.html
new file mode 100644
index 00000000000..16bad316cf9
--- /dev/null
+++ b/lang/cpp26/constexpr_cast_from_voidptr.html
@@ -0,0 +1,296 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ 定数式での`void*`からポインタ型へのキャストを許可 [P2738R1] - cpprefjp C++日本語リファレンス
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
定数式でのvoid*
からポインタ型へのキャストを許可 [P2738R1](C++26)
+
+
このページはC++26に採用される見込みの言語機能の変更を解説しています。
+
のちのC++規格でさらに変更される場合があるため関連項目を参照してください。
+
+
概要
+
C++23までは、定数式の文脈でのvoid*
から元のポインタ型への変換が禁止されていたが、C++26からは許可される。
+
void*
から元のポインタ型への変換は、「型消去 (type erasure)」で有用に使われるもので、標準ライブラリの実装としてはstd::any
、std::function_ref
、std::format()
などで使われており、これらがコンパイル時に使用できるようにするための必要となる。
+
型消去は、テンプレートインスタンスの数を減らし、バイナリサイズを小さくするために一般的に使用される技法である。とくに、メモリ制約のある組み込みプラットフォームでは、共通のコードパスを確保するために型消去が有効である。
+
void*
から元のポインタ型に変換することによる型消去の例としては、以下のようになる:
+
#include <string_view>
+
+struct Sheep {
+ constexpr std::string_view speak() const noexcept { return "Baaaaaa"; }
+};
+struct Cow {
+ constexpr std::string_view speak() const noexcept { return "Mooo"; }
+};
+
+class AnimalView {
+private:
+ const void* animal;
+ std::string_view (*speak_function)(const void*);
+public:
+ template <typename Animal>
+ constexpr AnimalView(const Animal &a)
+ : animal{&a}, speak_function{[](const void* object) {
+ return static_cast<const Animal*>(object)->speak();
+ }}
+ {}
+
+ constexpr std::string_view speak() const noexcept {
+ return speak_function(animal);
+ }
+};
+
+int main() {
+ constexpr Cow cow;
+ constexpr AnimalView av{cow};
+ constexpr auto result = av.speak();
+}
+
+
+
仕様
+
定数式として許可されない操作を、以下のように変更:
+
+- 変更前:「(CV修飾)
void*
型からオブジェクトへのポインタ型への変換」
+- 変更後:「(CV修飾)
void
へのポインタ型のprvalue (一時オブジェクト) P
から、オブジェクトへのポインタ型T
への変換。ただし、P
がT
と類似 (similar) の型のオブジェクトを指している場合を除く」
+
+
これはつまり、T
からvoid*
を経由してT
に変換することは許可されるが、void*
を経由してほかの型に変換することは禁止されたままとなる。
+
+
+
参照
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/lang/cpp26/deleting_a_pointer_to_an_incomplete_type_should_be_ill-formed.html b/lang/cpp26/deleting_a_pointer_to_an_incomplete_type_should_be_ill-formed.html
new file mode 100644
index 00000000000..944821ebe1b
--- /dev/null
+++ b/lang/cpp26/deleting_a_pointer_to_an_incomplete_type_should_be_ill-formed.html
@@ -0,0 +1,255 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ 不完全型へのポインタに対するdeleteを不適格とする [P3144R2] - cpprefjp C++日本語リファレンス
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
不完全型へのポインタに対するdeleteを不適格とする [P3144R2](C++26)
+
+
このページはC++26に採用される見込みの言語機能の変更を解説しています。
+
のちのC++規格でさらに変更される場合があるため関連項目を参照してください。
+
+
概要
+
宣言のみで定義がない不完全型へのポインタへのdelete
は、これまで未定義動作を引き起こす操作になっていた。
+
C++26ではこれを不適格とし、コンパイル時エラーとする。
+
class C; // 不完全型の宣言
+C* cp = nullptr; // 不完全型へのポインタはOK
+delete cp; // C++23:未定義動作, C++26:コンパイルエラー
+
+
+
参照
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/lang/future.html b/lang/future.html
index 24529419ddc..ad1d1c004d8 100644
--- a/lang/future.html
+++ b/lang/future.html
@@ -176,12 +176,12 @@
最終更新日時(UTC):
-
- 2025年03月27日 12時46分35秒
+
+ 2025年04月25日 04時51分33秒
- Tetsuro Matsumura
+ rotarymars
が更新
@@ -231,7 +231,7 @@ ライブラリ
-<contract> |
+<contracts> |
契約違反のハンドリング |
diff --git a/reference.html b/reference.html
index 593021dfd55..284539c1bc1 100644
--- a/reference.html
+++ b/reference.html
@@ -164,12 +164,12 @@
最終更新日時(UTC):
-
- 2025年04月04日 07時45分27秒
+
+ 2025年04月25日 03時45分01秒
- yoh
+ rotarymars
が更新
@@ -678,6 +678,11 @@
デバッグサポート |
C++26 |
+
+<contracts> |
+契約プログラミング |
+C++26 |
+
diff --git a/reference/contract/contract_violation.html b/reference/contract/contract_violation.html
deleted file mode 100644
index d804a7386cd..00000000000
--- a/reference/contract/contract_violation.html
+++ /dev/null
@@ -1,318 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
- contract_violation - cpprefjp C++日本語リファレンス
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
class
std::contract_violation(将来のC++機能)
-
namespace std {
- class contract_violation {
- public:
- uint_least32_t line_number() const noexcept;
- string_view file_name() const noexcept;
- string_view function_name() const noexcept;
- string_view comment() const noexcept;
- string_view assertion_level() const noexcept;
- };
-}
-
-
-
概要
-
contract_violation
クラスは、発生した契約違反に関する情報を提供する。
-
契約違反が発生したとき、このクラスのオブジェクトが処理系定義の方法により構築され、違反ハンドラーに渡される。
-
違反ハンドラーはvoid(const std::contract_violation&) noexcept
またはvoid(const std::contract_violation&)
の型を持つ関数であり、
-処理系定義の方法によって指定される。
-
メンバ関数
-
-
-
-名前 |
-説明 |
-対応バージョン |
-
-
-
-
-line_number |
-契約違反が発生したソースコード上の行番号 |
-C++ (将来) |
-
-
-file_name |
-契約違反が発生したソースコードのファイル名 |
-C++ (将来) |
-
-
-function_name |
-契約違反が発生した関数の名前 |
-C++ (将来) |
-
-
-comment |
-契約違反の原因となった述語を説明する処理系定義のテキスト |
-C++ (将来) |
-
-
-assertion_level |
-違反した契約のアサーションレベル |
-C++ (将来) |
-
-
-
-
例
-
(執筆中)
-
出力
-
(執筆中)
-
バージョン
-
言語
-
-
処理系
-
-
関連項目
-
-
参照
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/reference/contract.html b/reference/contracts.html
similarity index 72%
rename from reference/contract.html
rename to reference/contracts.html
index 1549c502a3a..fb329a155fd 100644
--- a/reference/contract.html
+++ b/reference/contracts.html
@@ -16,23 +16,23 @@
- contract - cpprefjp C++日本語リファレンス
+ contracts - cpprefjp C++日本語リファレンス
-
-
-
-
+
+
+
+
-
+
-
-
-
+
+
+
@@ -68,7 +68,7 @@
-