Hacker News new | ask | show | jobs
by LaLaLand122 1124 days 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
1 comments

That'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! ;-)

Agreed with you on both counts - cout was an abomination and that std::println looks great (I'd never seen it before, either)
I 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/ . I do use it in a C++11-only codebase.