[basic.lookup.unqual] (original) (raw)

6 Basics [basic]

6.5 Name lookup [basic.lookup]

6.5.3 Unqualified name lookup [basic.lookup.unqual]

A using-directive isactive in a scope S at a program point Pif it precedes P and inhabits either S or the scope of a namespace nominated by a using-directivethat is active in S at P.

An unqualified search in a scope S from a program point Pincludes the results of searches from P in

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.

[Note 1:

When a class scope is searched, the scopes of its base classes are also searched ([class.member.lookup]).

If it inherits from a single base, it is as if the scope of the base immediately contains the scope of the derived class.

Template parameter scopes that are associated with one scope in the chain of parents are also considered ([temp.local]).

— _end note_]

Unqualified name lookupfrom a program point performs an unqualified search in its immediate scope.

An unqualified name is a name that does not immediately follow a nested-name-specifier or the . or -> in a class member access expression ([expr.ref]), possibly after a template keyword or ~.

Unless otherwise specified, such a name undergoes unqualified name lookup from the point where it appears.

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::*(); X().operator U decltype(T())::*(); return 0;} int x = g<B, T2>(); — _end example_]

If that lookup finds nothing, it undergoes unqualified name lookup.

[Example 2: using I = int;using D = double;namespace A { inline namespace 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 { typedef short I, F;class Y { friend void A::f(I); friend void A::f(D); friend void A::f(C); friend void A::f(F); friend void W::X::g(I); friend void W::X::g(D); friend void W::X::g(F); };} — _end example_]