Talk:cpp/memory/shared ptr/use count

Zero use count
As far as I can tell, if a shared pointer is managing an object, its use count will always be at least one unlike a weak_ptr's use_count, since the current instance will be one "use". That means the only way for the use count to be zero is if there is no managed object / control block in the first place (e.g., a default constructed shared pointer or one made with the aliasing constructor). The point being that there is no deleter to be called or create a race if use count is zero, since there wasn't a deleter in the first place. Mital (talk) 09:50, 1 September 2022 (PDT)


 * we have an example in cpp/memory/shared_ptr/reset showing how shared_ptr use_count goes from 1 to 0. --Cubbi (talk) 20:51, 1 September 2022 (PDT)