justinhj/astar-algorithm-cpp

C++ headers shouldn't do `using namespace std;`

sylveon opened this issue · 1 comments

Using namespaces in headers is considered bad practice because they unconditionally and irreversibly pollute the global namespace of every consumer.

This leads to conflicts especially since the std namespace uses a lot of general terms that someone might want to use elsewhere, for example function and copy. The user in microsoft/STL#1881 was having issues with a library conflicting with the standard library specifically because of this line (the library is in the endian namespace while C++20 has an std::endian enum now):

using namespace std;

The source .cpp files, however, can keep doing using namespace std since it won't affect any other files.

Thanks for pointing this out, have fixed.