3 ms·
Right, I'm just questioning whether this consistency buys you anything. Either way you're checking the docs to see how to print an object.
by ambrice 11y ago
Right, I'm just questioning whether this consistency buys you anything. Either way you're checking the docs to see how to print an object.
- simoncion 11y ago> ...I'm just questioning whether this consistency buys you anything. It buys you the same thing that API consistency always buys you: reduced cognitive overhead when dealing with a given API. :) Edit: As GFK_of_xmaspast mentions [0] instances of non-trivial classes are not compatible with the default implementations of "operator <<" in ostream. So, you can try "ostream << instanceOfNonTrivial". If it passes the compiler, then you know that operator << is defined for that class. So, no need to check the docs... just ask the compiler. :) [0] https://news.ycombinator.com/item?id=10775022 https://news.ycombinator.com/item?id=10775022