Koenig(ADL) lookup: If you supply a function argument of class type (here
x, of type A::X), then to look up the correct function name the compiler
considers matching names in the namespace (here A) containing the
argument’s type.
ADL can bring name loopup ambiguous problem. When you call
f(parm) f is in global scope, So number 2 is in the searching scope
default. But ADL bring namesapce NS scope into searching scope.
In searching scope, there are two options, so compiler will stop.
Just like previous example, g is in the namespace B, with help of ADL,
searching scope is namespace A+ namespace B. there are tow f in the
searching scope.
For a class X, all functions, including free functions, that both "Mention" X
and "supplied with" X are logically part of X, because they form part of the
interface of X.
Keep a type and its nonmember function interface in the same namespace,
1) in logic, these nonmember function can be regarded as type interface, 2)
avoid name ambigous problem in the future.