
Ben Hutchings wrote:
John Torjo <john.lists@torjo.com> wrote:
Ben Hutchings wrote: <snip>
expired() may read the count as still being 1 and so return false, but I believe the wnd_shared_ptr constructor will catch the fact that the pointer really has expired. Unfortunately I can't yet see the code to confirm this!
By looking at the code, I would think not. But I may be wrong. Anyway, I've posted the code in my other post.
Thanks for that. Supposing that expired() wrongly returns false because use_count is really 0 but it gets an old non-zero value. Then lock() attempts to construct a shared_ptr: [...]
It is also worth noting that no matter how you fiddle with the implementation of atomic_read() that is indirectly invoked by expired(), it would still be possible for the use_count to drop to zero _after_ expired() has returned.