I need single ownership for an object because I need to be able to destroy it on demand (this makes sense sometimes; in this case the object represents a logged-in session that, for security reasons, the user wants to close). Let's call this object session. Other client objects keep references to session, but, of course, it may be dead when the clients access the reference.
What I'm after is a 'safe reference' that is notified when the original object is destroyed and reports this gracefully (exception, boolean) to the client, instead of a segfault.
Does anything like this exist? Preferable using what's available in standard C++/Boost. Preferably C++03. shared_ptr with weak_ptr is almost what I'm after, if only the shared_ptrs didn't extend the lifetime of session. I need to guarantee that session has been destroyed and a stray shared_ptr would prevent that.