Skip to content

Commit 4e37c0f

Browse files
committed
C++20 / C++26 : 組み込み配列の比較の非推奨・削除を追加 (close #1375)
1 parent 786b39a commit 4e37c0f

File tree

5 files changed

+72
-5
lines changed

5 files changed

+72
-5
lines changed

lang/cpp20.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ C++20とは、2020年中に改訂され、ISO/IEC 14882:2020で標準規格化
3131
| 言語機能 | 説明 |
3232
|----------|------|
3333
| [スコープ付き列挙型のusing宣言](cpp20/using_enum.md) | `using enum EnumType;`もしくは`using EnumType::enumerator`とすることで、列挙値のスコープ指定を省略できるようにする |
34-
| [列挙値から算術型への暗黙変換を非推奨化](cpp20/deprecate_arithmetic_conversion_on_enumerations.md) | 列挙値への算術演算で算術型に暗黙変換される仕様を非推奨とする |
3534

3635

3736
### 変数
@@ -43,7 +42,6 @@ C++20とは、2020年中に改訂され、ISO/IEC 14882:2020で標準規格化
4342
| [丸カッコの値リストからの集成体初期化を許可](cpp20/allow_initializing_aggregates_from_a_parenthesized_list_of_values.md) | `T x{1, 2, 3};`と同様に`T x(1, 2, 3);`でも集成体初期化できるようにする |
4443
| [`new`式での配列要素数の推論](cpp20/array_size_deduction_in_new-expressions.md) | `double* p = new double[]{1,2,3};`を許可 |
4544
| [要素数不明の配列への変換を許可](cpp20/permit_conversions_to_arrays_of_unknown_bound.md) | 要素数が判明している配列から、要素数が不明の配列への変換を許可 |
46-
| [ほとんどの`volatile`を非推奨化](cpp20/deprecating_volatile.md) | `volatile`の有用な機能のみを残し、効果が疑わしい、または壊れている機能を非推奨化する |
4745
| [ポインタから`bool`への変換を縮小変換とする](cpp20/converting_from_pointer_to_bool_should_be_considered_narrowing.md) | ポインタから`bool`値への変換を縮小変換と規定することで、意図しない変換を防止する |
4846

4947

@@ -114,7 +112,6 @@ C++20とは、2020年中に改訂され、ISO/IEC 14882:2020で標準規格化
114112
|----------|------|
115113
| [ジェネリックラムダのテンプレート構文](cpp20/familiar_template_syntax_for_generic_lambdas.md) | ジェネリックラムダでテンプレートパラメータを定義できるようにする |
116114
| [ラムダ式のキャプチャとして`[=, this]`を許可する](cpp20/allow_lambda_capture_equal_this.md) | デフォルトコピーキャプチャと`this`ポインタのコピーキャプチャを両方指定できるようにする |
117-
| [`[=]`による`this`の暗黙のキャプチャを非推奨化](cpp20/deprecate_implicit_capture_of_this_via_defcopy.md) | コピーのデフォルトキャプチャでは、`this`ポインタをキャプチャされなくする |
118115
| [暗黙のラムダキャプチャを簡略化](cpp20/simplifying_implicit_lambda_capture.md) | ラムダ式のキャプチャに関する仕様整理 |
119116
| [状態を持たないラムダ式を、デフォルト構築可能、代入可能とする](cpp20/default_constructible_and_assignable_stateless_lambdas.md) | キャプチャしていないラムダ式をデフォルト構築・代入可能にする |
120117
| [評価されない文脈でのラムダ式](cpp20/wording_for_lambdas_in_unevaluated_contexts.md) | 評価されない文脈でもラムダ式を書くことができるようにする |
@@ -155,9 +152,12 @@ C++20とは、2020年中に改訂され、ISO/IEC 14882:2020で標準規格化
155152

156153
| 言語機能 | 説明 |
157154
|----------|------|
155+
| [ほとんどの`volatile`を非推奨化](cpp20/deprecating_volatile.md) | `volatile`の有用な機能のみを残し、効果が疑わしい、または壊れている機能を非推奨化する |
158156
| [PODを非推奨化](cpp20/deprecate_pod.md) | PODという用語を非推奨化する |
159157
| [`[=]`による`this`の暗黙のキャプチャを非推奨化](cpp20/deprecate_implicit_capture_of_this_via_defcopy.md) | コピーのデフォルトキャプチャでは、`this`ポインタのキャプチャを非推奨化する |
160158
| [添字演算子内でのカンマ演算子の使用を非推奨化](cpp20/deprecate_uses_of_the_comma_operator_in_subscripting_expressions.md) | `ar[i, j]`を非推奨化。`ar[(i, j)]`はOK |
159+
| [列挙値から算術型への暗黙変換を非推奨化](cpp20/deprecate_arithmetic_conversion_on_enumerations.md) | 列挙値への算術演算で算術型に暗黙変換される仕様を非推奨とする |
160+
| [組み込み配列の比較を非推奨化](cpp20/deprecate_array_comparisons.md) | 組み込み配列同士の比較演算を非推奨とする |
161161

162162

163163
### 機能の削除

lang/cpp20/consistent_comparison.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,9 @@ struct has_vector {
803803
- [`<algorithm>`](/reference/algorithm.md)
804804
- [`lexicographical_compare_three_way`](/reference/algorithm/lexicographical_compare_three_way.md)
805805
- [C++20 列挙値から算術型への暗黙変換を非推奨化](deprecate_arithmetic_conversion_on_enumerations.md)
806-
- [C++26 非推奨となっていた列挙値から算術型への暗黙変換を削除](/lang/cpp26/remove_deprecated_arithmetic_conversion_on_enumerations.md)
806+
- [C++26 非推奨となっていた列挙値から算術型への暗黙変換を削除](/lang/cpp26/remove_deprecated_arithmetic_conversion_on_enumerations.md)
807+
- [C++20 組み込み配列の比較を非推奨化](/lang/cpp20/deprecate_array_comparisons.md)
808+
- [C++26 非推奨だった組み込み配列の比較を削除](/lang/cpp26/remove_deprecated_array_comparisons.md)
807809

808810

809811
## 参照
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# 組み込み配列の比較を非推奨化 [P1120R0]
2+
* cpp20[meta cpp]
3+
4+
<!-- start lang caution -->
5+
6+
このページはC++20に採用された言語機能の変更を解説しています。
7+
8+
のちのC++規格でさらに変更される場合があるため[関連項目](#relative-page)を参照してください。
9+
10+
<!-- last lang caution -->
11+
12+
## 概要
13+
[三方比較演算子](consistent_comparison.md)の導入にともない、組み込み配列の等値比較および関係比較は非推奨となる。
14+
15+
組み込み配列同士の三方比較は不適格である。
16+
17+
```cpp
18+
int arr1[5];
19+
int arr2[5];
20+
bool same = arr1 == arr2; // C++20で非推奨。&arr[0] == &arr[1]と同じ。
21+
// 配列の要素は比較されない
22+
auto cmp = arr1 <=> arr2; // エラー!
23+
```
24+
25+
26+
## <a id="relative-page" href="#relative-page">関連項目</a>
27+
- [C++20 `<=>`/`==`による比較演算子の自動定義](consistent_comparison.md)
28+
- [C++26 非推奨だった組み込み配列の比較を削除](/lang/cpp26/remove_deprecated_array_comparisons.md)
29+
30+
31+
## 参照
32+
- [P1120R0 Consistency improvements for `<=>` and other comparison operators](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1120r0.html)

lang/cpp26.md

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

109109
| 言語機能 | 説明 |
110110
|----------|------|
111-
| [非推奨だった配列の比較を削除](/lang/cpp26/remove_deprecated_array_comparisons.md.nolink) | C++20で非推奨となっていた配列比較を削除 |
111+
| [非推奨だった組み込み配列の比較を削除](/lang/cpp26/remove_deprecated_array_comparisons.md) | C++20で非推奨となっていた配列比較を削除 |
112112
| [先行するカンマのない省略記号を非推奨化](/lang/cpp26/the_oxford_variadic_comma.md) | `void f(int, ...);`はOK。`void f(int...);`は非推奨 |
113113

114114

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# 非推奨だった組み込み配列の比較を削除 [P2865R6]
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++20での[三方比較演算子](consistent_comparison.md)の導入にともない、組み込み配列の等値比較および関係比較は非推奨となっていたが、これを削除する。
14+
15+
組み込み配列同士の三方比較はC++20時点で不適格である。
16+
17+
```cpp
18+
int arr1[5];
19+
int arr2[5];
20+
bool same = arr1 == arr2; // C++20: 非推奨、C++26: エラー。
21+
// &arr[0] == &arr[1]と同じ。
22+
// 配列の要素は比較されない
23+
auto cmp = arr1 <=> arr2; // エラー!
24+
```
25+
26+
27+
## <a id="relative-page" href="#relative-page">関連項目</a>
28+
- [C++20 `<=>`/`==`による比較演算子の自動定義](/lang/cpp20/consistent_comparison.md)
29+
- [C++20 組み込み配列の比較を非推奨化](/lang/cpp20/deprecate_array_comparisons.md)
30+
31+
32+
## 参照
33+
- [P2865R6 Remove Deprecated Array Comparisons from C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2865r6.pdf)

0 commit comments

Comments
 (0)