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.
This is where I shake off the cobwebs and ancient dust and lost memories from my childhood to point out that I somehow still know that << is the insertion operator. It does more than just write, and it can write to more than just the standard output stream.
https://www.cplusplus.com/reference/ostream/ostream/operator...