3 ms·
I never said io*stream support was universal, [0] I said that it provided a _consistent_ mechanism. :) [0] I mean, it's obvious that anything that you don't ge
by simoncion 11y ago
I never said io*stream support was universal, [0] I said that it provided a _consistent_ mechanism. :)
[0] I mean, it's obvious that anything that you don't get for free out of the box is bound to _not_ be universal. Edit: Actually, the thing you get out of the box when you present an instance of a non-trivial user-defined class to both printf and ostream is equally useless... unless you're debugging and are interested in the address of the instance of an object.
- ambrice 11y agoRight, 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