@jmuk タイパ!
C++のweak_ptrは典型的にはshared_ptrと実装が混ざってるのかな。shared_ptrの側から見たらカウンタ一個分大きくなりそう?
https://en.cppreference.com/w/cpp/memory/weak_ptr
Like std::shared_ptr, a typical implementation of weak_ptr stores two pointers:
a pointer to the control block; and
the stored pointer of the shared_ptr it was constructed from.
A separate stored pointer is necessary to ensure that converting a shared_ptr to weak_ptr and then back works correctly, even for aliased shared_ptrs. It is not possible to access the stored pointer in a weak_ptr without locking it into a shared_ptr.
コントローラの中にポインタ埋め込むとメモリが節約できそうだけど、間接参照が一段深くなって遅くなったりするんだろうか?