Talk:cpp/memory/weak ptr/expired

The documentation, as written, presumes that weak_ptr only becomes expired because the thing it is pointing to has been or is about to deleted.

For example:

"The destructor for the managed object may not yet have been called, but this object's destruction is imminent (or may have already happened)."

"Return value: true if the managed object has already been deleted, false otherwise."

But, a weak_ptr can be expired simply because it was constructed empty or was assigned from an empty one.

Also, the "Return value" statement about "already been deleted" seems to be inconsistent with the warning in the summary that says the destructor might not have been called yet.

Perhaps at least the "Return value" section can be adjusted to deal with both of these details. Perhaps:

"Return value: true if the weak_ptr is empty, false otherwise."

BTW, the use_count page makes a similar assumption about the managed object's deletion being the only way to get to zero.

Brad Spencer 208.93.79.183 06:26, 14 September 2022 (PDT)