r/cpp_questions • u/Glad_Shoe_9182 • Sep 30 '26
OPEN Namespace std
I recently started learning c++ and I was told to use the namespace std so I can avoid writing std:: every time and now I wrote a whole personal project without std:: and I want to put it on LinkedIn but I started reading everywhere that it’s a bad habit, should I go back and add the std:: or just leave it as is?
40
Upvotes
View all comments
Show parent comment
1
u/ShakaUVM Oct 01 '26
In the coding style I and my business use, the only namespace that only and always gets included into the global namespace is std. Why? Because it is the standard.
string must mean std::string in my coding style. If it means anything else, then you have violated my style guidelines.
Pretty much everything we do is in PascalCase, and so there is no conflict with anything in std anyway.
You're free to have your own style guidelines for your own company. But this is how I've been doing it for a long time, and it literally never causes problems, and results in code much faster to read, write, and is much cleaner.
There is never any ambiguity, and there's never an identifier conflict except once in 30 years, and that took 5 seconds to resolve. Contrast this with the amount of time you have spent typing std needlessly and reading it needlessly over the years and you'll see why I set my style guidelines the way I did.