From: "Petr Ferschmann"
Thank you for your answer.
I know that intrusive_ptr is not documented yet.
But in documentation of weak_ptr is written that when all shared_ptr are destroyed all weak_ptr are set to 0. And it of course works in that style for normal shared pointer.
If you test the weak_ptr, you'll see that it will properly report that it's expired(); use_count() will be zero; and if you try to construct a shared_ptr from it, the construction will fail.
But when I am using weak_ptr with intrusive_ptr it know works like normal pointer?
I think I missed something. Is it bug or feature?
It is a "feature". The reference count is contained in counted_base, and it's embedded into the object. It is not possible to destroy the object without also destroying the counted_base, and this cannot happen while there are still weak pointers to that counted_base. That's why counted_base::dispose() is invoked when the last shared_ptr is destroyed, to let you release the resources contained in your object.