|
Boost : |
From: AlisdairM (alisdair.meredith_at_[hidden])
Date: 2007-06-05 08:28:48
Attached is the test file for a proposed new defect macro,
BOOST_NO_IMPLICIT_BOOL_CONVERSION.
This identifies compilers (such as Borland) that do not always convert
expressions to bool as required by 5.14/5.15 and elsewhere. The
workaround is fairly simple - detect the bad compiler and add an
additional static_cast<bool>( ) around the (sub)expression.
This only really catches classes relying on the
convertible-to-unspecified-bool-type idiom.
The test results I am posting have applied this workaround in a number
of places, and obviously I would prefer to post those patches with a
defect macro rather than compiler (and version) specific workarounds.
Note: the tests checks all 'boolean contexts', not just the two or
three that fail with Borland. I don't know if this will catch any
other compilers.
As ever, I am open to suggestions for a better name.
-- AlisdairM
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk