A using-directive is
active in a scope S at a program point P
if it precedes P and inhabits either S or
the scope of a namespace nominated by a using-directive
that is active in S at P.
for any scope U that contains P and is or is contained by S,
each namespace contained by S that is nominated by
a using-directive that is active in U at P.
If no declarations are found,
the results of the unqualified search are
the results of an unqualified search in the parent scope of S, if any,
from P.
If that lookup finds nothing, it undergoes unqualified name lookup;
in each case, only names
that denote types or templates whose specializations are types are considered.
[Example 1: struct T1 {struct U {int i; }; };
struct T2 {};
struct U1 {};
struct U2 {};
struct B {using T = T1;
using U = U1;
operator U1 T1::*();
operator U1 T2::*();
operator U2 T1::*();
operator U2 T2::*();
};
template<class X, class T>int g(){using U = U2;
X().operator U T::*(); // #1, searches for T in the scope of X first
X().operator U decltype(T())::*(); // #2return0;
}int x = g<B, T2>(); // #1 calls B::operator U1 T1::*// #2 calls B::operator U1 T2::* — end example]
If that lookup finds nothing, it undergoes unqualified name lookup.
[Example 2: using I =int;
using D =double;
namespace A {inlinenamespace N {using C =char; }using F =float;
void f(I);
void f(D);
void f(C);
void f(F);
}struct X0 {using F =float; };
struct W {using D =void;
struct X : X0 {void g(I);
void g(::D);
void g(F);
};
};
namespace B {typedefshort I, F;
class Y {friendvoid A::f(I); // error: no void A::f(short)friendvoid A::f(D); // OKfriendvoid A::f(C); // error: A::N::C not foundfriendvoid A::f(F); // OKfriendvoid W::X::g(I); // error: no void X::g(short)friendvoid W::X::g(D); // OKfriendvoid W::X::g(F); // OK};
} — end example]