When using C++ namespaces, do you prefer to explicitly name them, like this:
std::cout << 'Hello, world!\n';
Or do you prefer using namespace:
using namespace std; cout << 'Hello, world!\n';
And if if you prefer the latter, do you declare your usings at file or function scope?
Personally I prefer to explicitly name them – it’s more typing but when using a mixture of namespaces (e.g. std and boost) I find it more readable.
I always use
using namespacefor std & boost. Everything else I tend to use an explicit namespace unless it is used so much that it would clutter up the code.In headers, I never use
using namespaceto avoid polluting the global namespace of the #including source.