3 ms·
Yup, cppformat is nice. I could also have a nice type-safe wrapper around libc functions. It doesn't change the fact that the API in the language is tedious. W
by oppositelock 11y ago
Yup, cppformat is nice. I could also have a nice type-safe wrapper around libc functions. It doesn't change the fact that the API in the language is tedious.
When you're doing internationalization, a common thing you might do is something along these lines:
fprintf(fd, translate_string(context, "Result %d of %d"), num1, num2);
The translation may be "%d of %d results" in another language. It's really difficult to map that into streams.
Yes, I'm over-simplifying, since you can't have arbitrary placeholders due to order differences between languages, but it's _much_ harder to write simple code with streams than libc, and I stand by that!
As for user-defined data, I've added .toString() functions on objects which I can call whenever needed, either from the ostream operator or pass the result to libc.