Namespaces
Variants
Views
Actions

Talk:cpp/language/operator logical

From cppreference.com

On bool operands, exactly what operators are allowed?

I guess the assignment operator is allowed.

bool a; bool b = a;


What is the case for example with the equality operator? (==)

bool a; bool b; bool c = (a == b); // VALID (AND SAFE) OR NOT? bool d = (a != b); // VALID (AND SAFE) OR NOT?


How to test (write) properly if boolean a is equivalent to boolean b?

bool c = (a && b || !a && !b); //?

or

bool c = (a ? b : !b); //?

62.201.102.190 10:06, 6 February 2020 (PST)