I realized recently that you can use the ternary operator in GCC and clang without a middle (?:
or ? :
works) and it will insert the first expression into the middle:
// outputs 2
cout << (2 ?: 4);
// outputs 3
cout << (0 ? : 3);
Where is this in the standard? I looked and didn't see anything about it.
See Question&Answers more detail:os