From: Greg Colvin (gcolvin_at_[hidden])
Date: 1999-12-28 15:24:31
From: Ed Brey <brey_at_[hidden]>
> > From: Greg Colvin [mailto:gcolvin_at_[hidden]]
> > So define BOOST_SMART_PTR_CONVERSION and use "if(!p)",
> > else use "if(!&*p)".
> The latter results in undefined behavior if p is null, so if get() has got
> your goat, your stuck with BOOST_SMART_PTR_CONVERSION and "if (!p)".
Undefined behavior? Even though you never actually dereference the
pointer? Yes, I think you are right.
> Here's a safe option to avoid having to choose between using the implicit
> pointer conversion and get(): define operator! and use "if (!p)" to test for
> null and "if (!!p)" to test for non-null. I don't like the looks of it,
> either, but that would change over time, and even better, I'd love to see how
> long before people start referring to the "test for non-null operator". :-)
I like the looks of it, but I'm unregenerate that way. I like "if(p)" even
better, so I'd still prefer to make BOOST_SMART_PTR_CONVERSION the default.
Yes, I know it's "considered harmful", but so are raw pointers, and I like
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk