I understood, that I should not use this in a header file:
using namespace foo;
Because it brings the namespace foo in the global scope for anyone who uses my header file.
Can I prevent this from happening, if I do it in my own namespace? For example like this:
namespace my_lib
{
using namespace foo;
// my stuff
// ...
}
Now the using namespace foo should be restricted to the scope of the namespace my_lib, right?
foointo namespacemy_lib. Is this really what you want for your users? It may be better than polluting the global namespace, but you're still polluting a namespace...foo::bar::box::action()you wantmy_lib::action()In this situation what you want is namespace aliasnamespace my_lib = foo::bar::box;