4 ms·
That's a very good question. My understanding is that the main motivation behind the introduction of iostream was to make a type-safe variant of printf. So wi
by kazuho 12y ago
That's a very good question.
My understanding is that the main motivation behind the introduction of iostream was to make a type-safe variant of printf. So with iostreams the _type_ of the value is determined at compile-time, but the representation (e.g. should it be stringified as dec or hex? should it be left-align or right?) needs to be determined at run-time.
In other words, the design issue is only partially solved with iostreams in terms of performance.
- PythonicAlpha 12y agoThanks for the answer. Yes, I was aware, that the focus of iostreams was not on performance. But at least I would have some hope, that since less runtime-parsing would be needed (at least in standard cases), a performance benefit could arise. One of the disadvantages of printf is that even in simple cases (e.g. "%s: %d") rather much parsing is needed.