3 ms·
There are numerous shortcoming of the previous (iostreams) approach: 1. Incompatible with dynamically-generated format strings, in which the order of arguments
by einpoklum 3y ago
There are numerous shortcoming of the previous (iostreams) approach:
1. Incompatible with dynamically-generated format strings, in which the order of arguments is different. Example:
std::cout << month << '/' << day << '/' << year
... but you now want to adapt that for a non-US locale, e.g. a European one where it's
std::cout << day << '/' << month << '/' << year
with iostreams, you have to change the code. With C-style printf, you don't (but it's not typeafe and not flexible. But with std::print it could be:
std::printf(my_format_str, day, month, year);
and `my_format_str` could be either "{0}/{1}/{2}" or "{1}/{0}/{2}".
2. The string allocations which other have mentioned.
3. A lot more typing that is easy to confuse: " << ".
4. The iostreams implementation is super-baroque, with buffer classes nobody uses.
and maybe I'm forgetting things.
- AtlasBarfed 3y agoStd:so std:you std:mix std:iosteam std:and std:printf? Std:seems std:confusing