icon

@jmuk タイパ!

icon

hackernewsの記事がタイムラインに流れなくなったぞ

icon

そもそも、weakrefってどうやって実装されてるんだろう?

icon

やっぱり、ウイークポインタ自体は、リファレンスカウントするしかないよね。

icon

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.

コントローラの中にポインタ埋め込むとメモリが節約できそうだけど、間接参照が一段深くなって遅くなったりするんだろうか?

std::weak_ptr - cppreference.com
icon

@tadd 別に定義されてるね。

icon

@tadd weak_ptrを実装するために、shared_ptrのメモリフットプリントが大きくなってる」と言いたかった

icon

あれ、いつの間にか世の中では引用RTできるのか

icon

あれ、南栗橋行きなのに新しい車両だ