On Wed, 02 Oct 2013 12:09:56 -0700, Matt Calabrese
On Wed, Oct 2, 2013 at 4:18 AM, Luke Bradford
wrote: Thanks for the feedback, Matt - some quick thoughts:
[snip]
I also think that having a conversion to bool is misleading - in the use cases I've seen, it would lead to a lot of extraneous if( ptr ) statements, then essentially if( true ), which obscure the programmer's intentions and are easy to remove. I found the elimination of the default constructor and conversion to bool just as useful, if not more useful, than the runtime checks of the class, because they revealed places where we were default constructing or checking a shared_ptr that we expected to be valid at all times.
The point isn't for people to use them in new code written specifically for the type, it's both to transition from old code and to work fine with generic code. You can also think of it as how boost::variant has an "empty" function that just always returns false.
Maybe I'm just being thick, why can't you just cast it/wrap it as a shared_ptr obj before passing it to such generic code?