101 lines
5.8 KiB
Markdown
101 lines
5.8 KiB
Markdown
[basic.lookup.unqual]
|
||
|
||
# 6 Basics [[basic]](./#basic)
|
||
|
||
## 6.5 Name lookup [[basic.lookup]](basic.lookup#unqual)
|
||
|
||
### 6.5.3 Unqualified name lookup [basic.lookup.unqual]
|
||
|
||
[1](#1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L1972)
|
||
|
||
A [*using-directive*](namespace.udir#nt:using-directive "9.9.4 Using namespace directive [namespace.udir]") is[*active*](#def: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*](namespace.udir#nt:using-directive "9.9.4 Using namespace directive [namespace.udir]") that is active in S at P[.](#1.sentence-1)
|
||
|
||
[2](#2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L1979)
|
||
|
||
An [*unqualified search*](#def:unqualified_search) in a scope S from a program point P includes the results of searches from P in
|
||
|
||
- [(2.1)](#2.1)
|
||
|
||
S, and
|
||
|
||
- [(2.2)](#2.2)
|
||
|
||
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*](namespace.udir#nt:using-directive "9.9.4 Using namespace directive [namespace.udir]") that is active in U at P[.](#2.sentence-1)
|
||
|
||
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[.](#2.sentence-2)
|
||
|
||
[*Note [1](#note-1)*:
|
||
|
||
When a class scope is searched,
|
||
the scopes of its base classes are also searched ([[class.member.lookup]](class.member.lookup "6.5.2 Member name lookup"))[.](#2.sentence-3)
|
||
|
||
If it inherits from a single base,
|
||
it is as if the scope of the base immediately contains
|
||
the scope of the derived class[.](#2.sentence-4)
|
||
|
||
Template parameter scopes
|
||
that are associated with one scope in the chain of parents
|
||
are also considered ([[temp.local]](temp.local "13.8.2 Locally declared names"))[.](#2.sentence-5)
|
||
|
||
â *end note*]
|
||
|
||
[3](#3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L2005)
|
||
|
||
[*Unqualified name lookup*](#def:lookup,unqualified_name "6.5.3 Unqualified name lookup [basic.lookup.unqual]") from a program point performs an unqualified search in its immediate scope[.](#3.sentence-1)
|
||
|
||
[4](#4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L2009)
|
||
|
||
An [*unqualified name*](#def:name,unqualified "6.5.3 Unqualified name lookup [basic.lookup.unqual]") is a name
|
||
that does not immediately follow a [*nested-name-specifier*](expr.prim.id.qual#nt:nested-name-specifier "7.5.5.3 Qualified names [expr.prim.id.qual]") or
|
||
the . or -> in a class member access expression ([[expr.ref]](expr.ref "7.6.1.5 Class member access")),
|
||
possibly after a template keyword or ~[.](#4.sentence-1)
|
||
|
||
Unless otherwise specified,
|
||
such a name undergoes unqualified name lookup from the point where it appears[.](#4.sentence-2)
|
||
|
||
[5](#5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L2017)
|
||
|
||
An unqualified name that is a component name ([[expr.prim.id.unqual]](expr.prim.id.unqual "7.5.5.2 Unqualified names")) of
|
||
a [*type-specifier*](dcl.type.general#nt:type-specifier "9.2.9.1 General [dcl.type.general]") or [*ptr-operator*](dcl.decl.general#nt:ptr-operator "9.3.1 General [dcl.decl.general]") of
|
||
a [*conversion-type-id*](class.conv.fct#nt:conversion-type-id "11.4.8.3 Conversion functions [class.conv.fct]") is looked up in the same fashion
|
||
as the [*conversion-function-id*](class.conv.fct#nt:conversion-function-id "11.4.8.3 Conversion functions [class.conv.fct]") in which it appears[.](#5.sentence-1)
|
||
|
||
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[.](#5.sentence-2)
|
||
|
||
[*Example [1](#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())::*(); // #2return 0;}int x = g<B, T2>(); // #1 calls B::operator U1 T1::*// #2 calls B::operator U1 T2::* â *end example*]
|
||
|
||
[6](#6)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L2053)
|
||
|
||
In a friend declaration [*declarator*](dcl.decl.general#nt:declarator "9.3.1 General [dcl.decl.general]") whose [*declarator-id*](dcl.decl.general#nt:declarator-id "9.3.1 General [dcl.decl.general]") is a [*qualified-id*](expr.prim.id.qual#nt:qualified-id "7.5.5.3 Qualified names [expr.prim.id.qual]") whose lookup context ([[basic.lookup.qual]](basic.lookup.qual "6.5.5 Qualified name lookup")) is a class or namespace S,
|
||
lookup for an unqualified name
|
||
that appears after the [*declarator-id*](dcl.decl.general#nt:declarator-id "9.3.1 General [dcl.decl.general]") performs a search in the scope associated with S[.](#6.sentence-1)
|
||
|
||
If that lookup finds nothing, it undergoes unqualified name lookup[.](#6.sentence-2)
|
||
|
||
[*Example [2](#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); // error: no void A::f(short)friend void A::f(D); // OKfriend void A::f(C); // error: A::N::C not foundfriend void A::f(F); // OKfriend void W::X::g(I); // error: no void X::g(short)friend void W::X::g(D); // OKfriend void W::X::g(F); // OK};} â *end example*]
|