Skip to content

Commit 5dd1e3f

Browse files
committed
change description about deprecation of std::allocator
1 parent 227e7c3 commit 5dd1e3f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

reference/memory/allocator.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,14 @@ C++11から:
7575

7676

7777
## 非推奨・削除の詳細
78-
C++17から`void`の特殊化版が非推奨となり、C++20で削除された。代わりに[`std::allocator_traits`](allocator_traits.md)クラスの`rebind`機能を使用すること。
78+
`address`/`max_size`/`construct`/`destroy`/`pointer`/`const_pointer`/`reference`/`const_reference`/`rebind<U>`メンバがC++17から非推奨となり、C++20で削除された。
79+
これらは特殊なアロケータの実装でない限り共通に定義できるものであるため、アロケータの中間インタフェースである[`std::allocator_traits`](/reference/memory/allocator_traits.md)クラスに、共通のデフォルト実装を定義することとなった。
80+
以後は[`std::allocator_traits`](allocator_traits.md)`<std::allocator<T>>`クラスの各機能を代替として使用すること。
81+
82+
従来`void`の特殊化版は`allocate`/`deallocate`メンバ関数が存在せず、実際に確保するオブジェクトの型(`R`とする)を隠蔽しつつメモリアロケータとしては`std::allocator`を使うことを表明するためにのみ用いられた。
83+
この際`typename std::allocator<void>::template rebind<R>::other`型から実際に確保するオブジェクト型の`std::allocator<R>`を再束縛していた。
84+
C++17から`void`の特殊化版が非推奨となり、C++20で削除されたが、これは`std::allocator<void>`もプライマリテンプレートからインスタンス化されるようになったことを意味し、C++20以降も`std::allocator<void>`の使用自体は問題なく可能であることに注意。
85+
なお、`allocate`/`deallocate`メンバは内部で`sizeof(void)`を要求するため引き続き使用不可能であり、`std::allocator<void>`の使用用途としては従来と同じく再束縛を目的とすることになる(上述のように[`std::allocator_traits`](allocator_traits.md)の代替機能を用いて`typename` [`std::allocator_traits`](allocator_traits.md)`<std::allocator<void>>::template rebind_alloc<R>`のようにする)。
7986

8087
メンバ型の`size_type``difference_type`は、C++17で非推奨となったがC++20で非推奨が取り消された。
8188

0 commit comments

Comments
 (0)