There is one (though somewhat unusual) situation in which the form you use can really make a difference, and the form you want to use is using namespace foo , and it most often applies to the std (i.e., where you write using namespace std;
The most obvious example is that you are writing sorting for a custom type. Perhaps this will apply to the type for which the user has also defined his own swap .
You are stuck in a situation where you want to use your swap if they defined it, but use std :: swap if they did not define it. If you use std::swap directly in your code, you end up using std::swap , even if the type has a swap of its own definition. Conversely, your code will not be able to compile if you directly specify swap specifically for this type, and none of them were provided.
To get around this, you do something like:
using namespace std; template <class Iter> void my_sort(Iter first, Iter last) {
This will find swap specifically for the type being compared (i.e. a swap defined in the same namespace as this type) if there is one (via an argument-dependent search) and std::swap if none are defined for type (via using namespace std; ).
This can affect performance - if they wrote a swap specifically for their type, you can generally expect this, because by doing this they can provide better performance. This means std::swap explicitly may work, but is likely to result in poor performance.
Otherwise, it is almost entirely a matter of convenience and readability - I prefer to give full names (for example, std::swap ), except for the situation described above, where (at the time I'm writing code) at least two are preferable possibilities, and I want to give the compiler enough freedom to choose the right one.
At the time when I find the use of useful declarations / directives, when the namespace is really heavily nested. Boost (for one obvious example) has some names that would be too long for convenient use if you used the full name every time. This is especially true for the (now, fortunately, mostly obsolete) Boost Lambda library, where you used placeholders like _1 , which would be something like boost::lambda::placeholders::_1 (but I'm going from memory, so which is probably at least partially wrong) if you insisted on using the full name. This, first of all, would do great harm to the purpose of using the lambda library.