This is the mail archive of the
mailing list for the GCC project.
Re: [bool wrapping] Request for warnings on implicit bool to int conversions
On Wed, Mar 28, 2012 at 20:30, mathog <email@example.com> wrote:
> Since b-- is equivalent to [assigning] !b,
> and b++ is equivalent to [assigning] 1, if
> that action is intended, there is no reason
> to use either the increment or decrement
> operators on a bool.
However, it seems to me that toggling the value with the idiom:
is aesthetically preferable to the more elaborate:
b = !b;
In fact, I've seen at least one person make this complaint in
freenode's ##c++ IRC channel.
Given the potential usefulness of `--b' and the relative uselessness
of `++b', it would seem more practical for the C++ standard to have
deprecated (if not allowed) `--b' and instead forbidden `++b' (rather
than the other way around).