Subject: Re: [boost] [signals2] Test failure in C++11 (trivial fix for incorrect usage of boost::optional)
From: Peter Dimov (lists_at_[hidden])
Date: 2014-02-28 11:26:58
Frank Mori Hess wrote:
> Nothing is a problem once you get used to it. I apologize for using a
> bit of hyperbole, let me try again. I consider the following obvious:
> given two expressions like "!x" and "x==false" we have:
> desirable behavior: they both compile and mean the same thing.
> neutral behavior: only one compiles.
> undesirable behavior: they both compile and mean completely different
This is obviously a matter of stylistic preference, but still, mine runs
contrary to yours. x == false is an anti-pattern and should never be
preferred to !x, even when x is bool; similarly, x == true is an
anti-pattern and should never be preferred to plain x. Boolean logic doesn't
have ==. Nobody prefers ( x == y ) == false to !( x == y ) or x != y, let
alone ( x == y ) == true to x == y.
And when our original x is not bool but, say, a pointer, x == false is just
silly, even though it works.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk