[cfe-dev] discriminating explicit boolean expressions from implicit boolean expressions in the AST

Richard legalize at xmission.com
Thu Mar 26 10:42:31 PDT 2015


In article <CAENS6EsAsF0NYiZkb2x_cbLm2HWH_m73Jd5rkAGGNkZnCLv1tw at mail.gmail.com>,
    David Blaikie <dblaikie at gmail.com> writes:

> > AFAIK, all the smart pointer classes have bool conversion operators.
> >
> 
> They do, but they're explicit and my point was "return bool(sp);" is less
> good than "return sp != nullptr;" - so without knowing the domain-specific
> bool test it's probably hard to pick/suggest the best fix.

I think this is where the wording in the standard allows you to write:

if (sp) { ... } else { ... }

without having to write an explicit conversion to bool.  I didn't look
up the language of how the ternary expression interprets the
conditional expression.  I will do that and see what it says.
-- 
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
     The Computer Graphics Museum <http://ComputerGraphicsMuseum.org>
         The Terminals Wiki <http://terminals.classiccmp.org>
  Legalize Adulthood! (my blog) <http://LegalizeAdulthood.wordpress.com>



More information about the cfe-dev mailing list