3 ms·
> However, in C++, '<<' can also mean 'write to standard output'. This is where I shake off the cobwebs and ancient dust and lost memories from my childhood to
by Igelau 5y ago
> However, in C++, '<<' can also mean 'write to standard output'.
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%3C%3C/ https://www.cplusplus.com/reference/ostream/ostream/operator...
- tialaramex 5y agoHowever, 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.