Interesting snippets - broyda/cp-lib GitHub Wiki

Flip flop between two numbers say, 1 and 2 (or 19 and 20)

So you don't have to write convoluted logic.

 int c = 12;
 int x = c^1;
 int y = x^1;
 int z = y^1;
 cout << x << "\n";
 cout << y << "\n";
 cout << z << "\n";
 /*Outputs
 13
 12
 13
 */