Look at this snippet:
namespace A {
int fn();
}
namespace B {
int fn();
}
// namespace Ns {
using namespace A;
using namespace B;
using A::fn;
int z = fn(
See [namespace.udir]/2
A using-directive specifies that the names in the nominated namespace can be used in the scope in which the using-directive appears after the using-directive. During unqualified name lookup (3.4.1), the names appear as if they were declared in the nearest enclosing namespace which contains both the using-directive and the nominated namespace.
Thus, when you have the namespace Ns
, the directives using namespace A;
and using namespace B
make A::fn
and B::fn
appear in the global namespace, whereas using A::fn;
makes fn
appear in Ns
. The latter declaration "wins" during name lookup.