Re:C++ Fun with(out) keyword explicit
by blub on Thursday December 10, 2015 @06:55AM
(#10710177)
Sure, << has these problems and for more advanced use cases one can use Boost or the library you mentioned.
For localization one has to use a non-STL solution anyway, because the supporty is rudimentary in the standard lib.
On the other hand, there's nothing easier than using << for logging and concatenating + optionally converting strings and other types.
All in all the only real problem caused by << being an operator instead of a function is the precedence one; the rest are API design issues I would argue. Luckily it's a compiler warning (unused value) and if one adds another output op to the chain it will most likely be a compile error or still a warnig. So I still don't see why we have to condemn operator overloading because of <<.
On the other hand, there's nothing easier than using << for logging and concatenating + optionally converting strings and other types.
All in all the only real problem caused by << being an operator instead of a function is the precedence one; the rest are API design issues I would argue. Luckily it's a compiler warning (unused value) and if one adds another output op to the chain it will most likely be a compile error or still a warnig. So I still don't see why we have to condemn operator overloading because of <<.