多相アロケータ アロケータおさらい 45 アロケータの rebind ⇓ 要素型が T 型のアロケータ型 A から、 要素型が U 型のアロケータ型 B を生成 (std::allocator ⇒ std::allocator みたいな感じ) using B = typename A::rebind::other; ホントは using B = std::allocator_traits::rebind_alloc
多相アロケータ アロケータおさらい 69 ただし、アロケータが自分を要素に伝搬させたい場合でも ① そもそも要素がアロケータを使う必要が無い(int とか) ② アロケータは使用するけど型が違っている ③ コンストラクタでアロケータを指定できない などの場合があるので、その場合は普通に構築したい。 そこで、std::uses_allocator と言う型トレイツで 伝搬させるかどうかを制御できるようにする。
多相アロケータ 参考資料 153 [email protected]++11 by Cryolite 先生 C++11 でのアロケータ機能拡充に関する神スライド https://www.slideshare.net/Cryolite/allocator11final A visitor’s guide to C++ allocators by Thomas Köppe アロケータの詳細がまとめられた非常に良い記事 カスタムアロケータやオフセットポインターのサンプル実装へのリンクもある https://rawgit.com/google/cxx-std-draft/allocator-paper/allocator_user_guide.html D0773R1 Towards meaningful fancy pointers ファンシーポインタとその適用限界について考察した非常に良い記事 https://quuxplusone.github.io/draft/fancy-pointers.html 勉強会後に 追記
多相アロケータ 参考資料 154 CppCon 2017 でのアロケータに関する講演 Pablo Halpern “Allocators: The Good Parts” https://www.youtube.com/watch?v=v3dz-AKOVL8 Alisdair Meredith “An allocator model for std2” https://www.youtube.com/watch?v=oCi_QZ6K_qk John Lakos “Local ('Arena') Memory Allocators (part 1 of 2)” https://www.youtube.com/watch?v=nZNd5FjSquk John Lakos “Local ('Arena') Memory Allocators (part 2 of 2)” https://www.youtube.com/watch?v=CFzuFNSpycI Bob Steagall “How to Write a Custom Allocator” https://www.youtube.com/watch?v=kSWfushlvB8 勉強会後に 追記