News for hackers. Stuff that matters.
Re:Formatting Text in C++: The Old and the New Ways by f1refly on Saturday September 16, 2023 @05:58PM (#37539150)
Typically, you'd just `using namespace std` on top of you file. Afterwards calls to `format` have the exact same length as `printf`.
Re:Formatting Text in C++: The Old and the New Ways by nuancebydefault on Saturday September 16, 2023 @06:18PM (#37539348)
I don't understand. I genuinely thought that using using namespace std is considered bad practice because of possible arising conflicts. Also you still need to write the word format (though you could alias it to one character, with same namespace conflict possibilities). Am i pedantic?
Re:Formatting Text in C++: The Old and the New Ways by Quekid5 on Saturday September 16, 2023 @06:28PM (#37539425)
This is questionable advice. In header files 'using namespace' should never be used, in implementation files it opens up some weird edge cases. Instead, do

   using fmt = std::format
and then use fmt(...) as the function call.

... at least that the current advice AIUI.

Re:Formatting Text in C++: The Old and the New Ways by gavinray on Saturday September 16, 2023 @07:09PM (#37539738)
This is not widely considered a good practice, please don't "using namespace std".
Re:Formatting Text in C++: The Old and the New Ways by emmelaich on Saturday September 16, 2023 @07:59PM (#37540077)
I know it's not recommended but I use it for main().

And extensive formatting and/or output should be minimised outside main(), imho.