It seems to me that using unanchored namespaces is just asking for trouble later when someone puts in a new namespace that happens to have the same name as a root level name
Okay, you say that std
is only an example. But to me it appears your question is only applicable to a case where somebody does something as evil as overriding std
.
Let me provide another example:
namespace logging
{
// Logs to local file
}
namespace server
{
namespace logging
{
// Logs to remote destination
}
}
namespace client
{
namespace logging
{
// Logs to local file and to screen
}
}
In this case, not prepending ::
results in default behavior.
This is so much artificial:
namespace fred {
namespace std { // A standard fred component
class string { // Something rather unlike the ::std::string
// ...
};
} // namespace std
} // namespace fred
This Fred would not be able to explain why he did that to the whole team.
To answer your question: people omit first "::" because it is a habit, which saves time and because it is easier to expect that when namespace is used anywhere, then such name is absolute, not relative.