bool
is not a basic type. Generally, it relies on int
or char
with 1 as true
and 0 as false
, but it is not a standard."
If x and y are both bool
, bitwise AND (&) and logical AND (&&) will lead to the same result with this implementation. However, MSVC just says that :
!false == true
!true == false
So you may have different results. It's bad design using bitwise operators with booleans. For example, casting an int
to a bool
will generate a warning C4800
(MSVC). The problem is that the conversion from bool
to int
is always implicit and you're allowed to use any arithmetic operator on them.
auto s = true + true + true; // = 3
// std::is_same<decltype(s), int>::value is True
Edit : mea culpa