From 5dd1e3f12ed326f1f9800013d804ab21fd09ad2e Mon Sep 17 00:00:00 2001 From: I <1091761+wx257osn2@users.noreply.github.com> Date: Mon, 19 Feb 2024 20:48:17 +0900 Subject: [PATCH 1/2] change description about deprecation of std::allocator --- reference/memory/allocator.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/reference/memory/allocator.md b/reference/memory/allocator.md index b13fc7f282..81a64b3e56 100644 --- a/reference/memory/allocator.md +++ b/reference/memory/allocator.md @@ -75,7 +75,14 @@ C++11から: ## 非推奨・削除の詳細 -C++17から`void`の特殊化版が非推奨となり、C++20で削除された。代わりに[`std::allocator_traits`](allocator_traits.md)クラスの`rebind`機能を使用すること。 +`address`/`max_size`/`construct`/`destroy`/`pointer`/`const_pointer`/`reference`/`const_reference`/`rebind`メンバがC++17から非推奨となり、C++20で削除された。 +これらは特殊なアロケータの実装でない限り共通に定義できるものであるため、アロケータの中間インタフェースである[`std::allocator_traits`](/reference/memory/allocator_traits.md)クラスに、共通のデフォルト実装を定義することとなった。 +以後は[`std::allocator_traits`](allocator_traits.md)`>`クラスの各機能を代替として使用すること。 + +従来`void`の特殊化版は`allocate`/`deallocate`メンバ関数が存在せず、実際に確保するオブジェクトの型(`R`とする)を隠蔽しつつメモリアロケータとしては`std::allocator`を使うことを表明するためにのみ用いられた。 +この際`typename std::allocator::template rebind::other`型から実際に確保するオブジェクト型の`std::allocator`を再束縛していた。 +C++17から`void`の特殊化版が非推奨となり、C++20で削除されたが、これは`std::allocator`もプライマリテンプレートからインスタンス化されるようになったことを意味し、C++20以降も`std::allocator`の使用自体は問題なく可能であることに注意。 +なお、`allocate`/`deallocate`メンバは内部で`sizeof(void)`を要求するため引き続き使用不可能であり、`std::allocator`の使用用途としては従来と同じく再束縛を目的とすることになる(上述のように[`std::allocator_traits`](allocator_traits.md)の代替機能を用いて`typename` [`std::allocator_traits`](allocator_traits.md)`>::template rebind_alloc`のようにする)。 メンバ型の`size_type`と`difference_type`は、C++17で非推奨となったがC++20で非推奨が取り消された。 From 1d65e5e89f7bbbe8d45288ede2c6d7e7b059f53d Mon Sep 17 00:00:00 2001 From: I <1091761+wx257osn2@users.noreply.github.com> Date: Mon, 19 Feb 2024 21:18:12 +0900 Subject: [PATCH 2/2] itemize --- reference/memory/allocator.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/reference/memory/allocator.md b/reference/memory/allocator.md index 81a64b3e56..2c78db3210 100644 --- a/reference/memory/allocator.md +++ b/reference/memory/allocator.md @@ -75,16 +75,17 @@ C++11から: ## 非推奨・削除の詳細 -`address`/`max_size`/`construct`/`destroy`/`pointer`/`const_pointer`/`reference`/`const_reference`/`rebind`メンバがC++17から非推奨となり、C++20で削除された。 -これらは特殊なアロケータの実装でない限り共通に定義できるものであるため、アロケータの中間インタフェースである[`std::allocator_traits`](/reference/memory/allocator_traits.md)クラスに、共通のデフォルト実装を定義することとなった。 -以後は[`std::allocator_traits`](allocator_traits.md)`>`クラスの各機能を代替として使用すること。 +- `address`/`max_size`/`construct`/`destroy`/`pointer`/`const_pointer`/`reference`/`const_reference`/`rebind`メンバがC++17から非推奨となり、C++20で削除された。 + - これらは特殊なアロケータの実装でない限り共通に定義できるものであるため、アロケータの中間インタフェースである[`std::allocator_traits`](/reference/memory/allocator_traits.md)クラスに、共通のデフォルト実装を定義することとなった。 + - 以後は[`std::allocator_traits`](allocator_traits.md)`>`クラスの各機能を代替として使用すること。 -従来`void`の特殊化版は`allocate`/`deallocate`メンバ関数が存在せず、実際に確保するオブジェクトの型(`R`とする)を隠蔽しつつメモリアロケータとしては`std::allocator`を使うことを表明するためにのみ用いられた。 -この際`typename std::allocator::template rebind::other`型から実際に確保するオブジェクト型の`std::allocator`を再束縛していた。 -C++17から`void`の特殊化版が非推奨となり、C++20で削除されたが、これは`std::allocator`もプライマリテンプレートからインスタンス化されるようになったことを意味し、C++20以降も`std::allocator`の使用自体は問題なく可能であることに注意。 -なお、`allocate`/`deallocate`メンバは内部で`sizeof(void)`を要求するため引き続き使用不可能であり、`std::allocator`の使用用途としては従来と同じく再束縛を目的とすることになる(上述のように[`std::allocator_traits`](allocator_traits.md)の代替機能を用いて`typename` [`std::allocator_traits`](allocator_traits.md)`>::template rebind_alloc`のようにする)。 +- C++17から`void`の特殊化版が非推奨となり、C++20で削除された。 + - 従来`void`の特殊化版は`allocate`/`deallocate`メンバ関数が存在せず、実際に確保するオブジェクトの型(`R`とする)を隠蔽しつつメモリアロケータとしては`std::allocator`を使うことを表明するためにのみ用いられた。 + この際`typename std::allocator::template rebind::other`型から実際に確保するオブジェクト型の`std::allocator`を再束縛していた。 + - この非推奨・削除は`std::allocator`もプライマリテンプレートからインスタンス化されるようになったことを意味し、C++20以降も`std::allocator`の使用自体は問題なく可能であることに注意。 + - なお、プライマリテンプレートからインスタンス化されるようになっても`allocate`/`deallocate`メンバは内部で`sizeof(void)`を要求するため引き続き使用不可能であり、`std::allocator`の使用用途としては従来と同じく再束縛を目的とすることになる(上述のように[`std::allocator_traits`](allocator_traits.md)の代替機能を用いて`typename` [`std::allocator_traits`](allocator_traits.md)`>::template rebind_alloc`のようにする)。 -メンバ型の`size_type`と`difference_type`は、C++17で非推奨となったがC++20で非推奨が取り消された。 +- メンバ型の`size_type`と`difference_type`は、C++17で非推奨となったがC++20で非推奨が取り消された。 ## 例 ```cpp example