3 ms·
I will never type this: printf("You have %d items of type %s.\n", itemCount, itemType.c_str()); When I could do this: std::println("You have {} items
by LaLaLand122 3y ago
I will never type this:
printf("You have %d items of type %s.\n", itemCount, itemType.c_str());
When I could do this:
std::println("You have {} items of type {}.", itemCount, itemType);
https://en.cppreference.com/w/cpp/io/print
- khazhoux 3y agoThat's perfect -- as easy to write and to read as printf. I feel like an idiot for not using it all these years. Edit: Oh, it's in C++23 standard. Only took them 38 years! ;-)
- peterashford 3y agoAgreed with you on both counts - cout was an abomination and that std::println looks great (I'd never seen it before, either)
- LaLaLand122 3y agoI doubt it's yet implemented in any standard library. But it has been in the fmt namespace for close to a decade: https://fmt.dev/ https://fmt.dev/ . I do use it in a C++11-only codebase.