Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Typically, you'd just `using namespace std` on top of you file. Afterwards calls to `format` have the exact same length as `printf`.


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.


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?


This is not widely considered a good practice, please don't "using namespace std".


I know it's not recommended but I use it for main().

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




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: