It is true that the ?:
operator has no clearly defined priority. But the example in question does not really illustrate that. The relative priorities of <<
and ?:
are rather unambiguous. All your example shows is that the priority of <<
is higher than the priority of ?:
.
As for the more general issue of the priority of ?:
operator... ?:
operator has relatively convoluted format, compared to other operators: it has three non-uniform operands. Because of that non-uniformity the part before ?
has different syntactic grouping properties than the parts after ?
.
After all, "priorities" are a derivative trick invented to simplify visualization and memorization of syntactic groupings defined by the grammar. Not all C++ operators conform to that trick though. The ?:
operator happens to be the one that does not, which is why a properly written priority table will typically have a side note for ?:
operator, explaining its unusual properties. Again, the part before the ?
has different priority than the parts after the ?
, which is why it is impossible to properly place the ?:
operator into a linear table of priorities.
Unless I'm forgetting something, the ?:
operator is the only operator without a straightforwardly definable priority.
P.S. Things with ?:
operator were even worse in C. C++-related changes to the grammar made ?:
to conform better to the idea of linear priority.