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`.
[ Parent
| on HN ]
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.