Re:Much less than, Much greater than symbols
by tialaramex on Sunday September 12, 2021 @03:47AM
(#28499344)
However, despite having doubled down on this particular oddity rather than abandoning it as a bad idea in the C++ 11 era, operator<< isn't really "the insertion operator" because you'd obviously give that a different precedence if it existed.
It's an overload for the left shift operator, and keeps the natural precedence of this operator (slightly lower than addition and subtraction) which leads to occasional surprises because something like:
out << x == y;
... is actually outputing x, and then comparing y to the out stream not to x, and then throwing away the result, even though that's clearly not what anybody intended.
It's an overload for the left shift operator, and keeps the natural precedence of this operator (slightly lower than addition and subtraction) which leads to occasional surprises because something like:
out << x == y;
... is actually outputing x, and then comparing y to the out stream not to x, and then throwing away the result, even though that's clearly not what anybody intended.