
Since the MT issues had already been raised, both of my comments were concerning similar-but-different cases than what you proposed. passive_ptr<> would simply indicate non-ownership, without making any assertions about object lifetime or pointer validity. The comment about nonnull_ptr<> was just riffing on Joël's comment. It might be interesting to explore the possibility of templates which parameterize both the object lifetime management policy and pointer validity (or non-null-ness, at least). Whether it would be worthwhile is a separate question. It does seem to me that one solution you might use to solve the MT problems would be to put a shared_mutex in valid_target<> and hide some locking in accesses via valid_ptr<> (i.e. put a scoped_lock in a temporary object returned by valid_ptr<>'s operators). Then, valid_target<> acquires an exclusive lock, when it's directed to delete the referenced object. Unfortunately, I don't see how that would be better than weak_ptr<>. It certainly wouldn't be any faster or lighter-weight. I can see how it would solve certain shared-ownership scenarios where you don't know, a priori, who will delete a shared object or when. But the same thing could be accomplished by using weak pointers to an object whose refcount had been manually incremented by 1. When you want to kill it, one of the referers could then manually decrement the refcount, so that it gets killed when it goes back to idle. Matt -----Original Message----- From: boost-bounces@lists.boost.org on behalf of Dan Walters Sent: Wed 3/16/2011 9:19 PM To: boost@lists.boost.org Subject: Re: [boost] [valid_ptr] proposing a new type of pointer object that allows validity tracking without memory management and object ownership
Matt,
I am unsure if I follow your second post. Perhaps what I have mentioned above answers this?
Thank you again to all who have been kind enough to give feedback, it is much appreciated.
Best wishes,
Dan