Boost logo

Boost :

From: Greg Colvin (greg_at_[hidden])
Date: 2002-05-08 10:47:49


At 07:13 AM 05/08/2002, Fernando wrote:
>In addition to the safe bool included in the latest CVS version,
>shared_ptr<> supports operator !.
>
>Whenever a given class supports operator ! for boolan testing, you can
>always use the 'double bang' idiom for testing 'true':
>
>instead of: if (p) ...
>write: if ( !! p ) ...
>
>Using this, of course, might be contrary to the user's religion :-) since
>it looks akward to the unaware eye; but it can be handy to know about it.

It's actually a minor tenet of my religion, and Max calls it the
"boolean conversion operator". But then I prefer &*p to p->get()
because it works with raw pointers as well as smart pointers.

Pearls-before-swine-or-preaching-to-the-choir-ly yours, Greg


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk