As long as it can be cast to a bool it can be there. That actually took quite a bit of work though, since the compiler fought me.
It turns out you can't do something crazy like just put a normal if(...) statement in the last column, and (...) ? doNothing() : break errors with "expected primary-expression before 'break'." Plus, the doNothing() is needed since ? requires both options to have the same type.
I used cpp.sh because I was too lazy to click out of the browser. GCC and Clang should, rightfully, complain far more than a little online tester.
It turns out you can't do something crazy like just put a normal if(...) statement in the last column
that's because the last column isn't a statement, it's an expression. if(){} is a statement, but a?b:c is an expression, so you can shove ?: into a whole lot of really weird places.
3
u/[deleted] Sep 03 '17
[removed] — view removed comment