XOR in C++

Final Recommendation:

  1. // 'a' and 'b' are some sort of integer type.
  2. // the double NOTs coerce to a standard boolean type
  3. // (compiler dependent)
  4. !!a ^ !!b

Thankfully Java is easier
http://www.sap-img.com/java/java-boolean-logical-operators.htm

  1. // 'a' and 'b' are of boolean type
  2. // yay, no coercion necessary!
  3. a ^ b

I didn’t know that the ^ operator was overloaded to handle Booleans, until I needed it a few weeks ago.