From Jason Turner

[basic.lookup.general]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp2nce8dui/{from.md → to.md} +92 -0
tmp/tmp2nce8dui/{from.md → to.md} RENAMED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### General <a id="basic.lookup.general">[[basic.lookup.general]]</a>
2
+
3
+ The name lookup rules apply uniformly to all names (including
4
+ *typedef-name*s [[dcl.typedef]], *namespace-name*s [[basic.namespace]],
5
+ and *class-name*s [[class.name]]) wherever the grammar allows such names
6
+ in the context discussed by a particular rule. Name lookup associates
7
+ the use of a name with a set of declarations [[basic.def]] of that name.
8
+ Unless otherwise specified, the program is ill-formed if no declarations
9
+ are found. If the declarations found by name lookup all denote functions
10
+ or function templates, the declarations are said to form an *overload
11
+ set*. Otherwise, if the declarations found by name lookup do not all
12
+ denote the same entity, they are *ambiguous* and the program is
13
+ ill-formed. Overload resolution [[over.match]], [[over.over]] takes
14
+ place after name lookup has succeeded. The access rules [[class.access]]
15
+ are considered only once name lookup and function overload resolution
16
+ (if applicable) have succeeded. Only after name lookup, function
17
+ overload resolution (if applicable) and access checking have succeeded
18
+ are the semantic properties introduced by the declarations used in
19
+ further processing.
20
+
21
+ A program point P is said to follow any declaration in the same
22
+ translation unit whose locus [[basic.scope.pdecl]] is before P.
23
+
24
+ [*Note 1*: The declaration might appear in a scope that does not
25
+ contain P. — *end note*]
26
+
27
+ A declaration X *precedes* a program point P in a translation unit L if
28
+ P follows X, X inhabits a class scope and is reachable from P, or else X
29
+ appears in a translation unit D and
30
+
31
+ - P follows a *module-import-declaration* or *module-declaration* that
32
+ imports D (directly or indirectly), and
33
+ - X appears after the *module-declaration* in D (if any) and before the
34
+ *private-module-fragment* in D (if any), and
35
+ - either X is exported or else D and L are part of the same module and X
36
+ does not inhabit a namespace with internal linkage or declare a name
37
+ with internal linkage. \[*Note 2*: Names declared by a
38
+ *using-declaration* have no linkage. — *end note*]
39
+
40
+ [*Note 3*:
41
+
42
+ A *module-import-declaration* imports both the named translation unit(s)
43
+ and any modules named by exported *module-import-declaration*s within
44
+ them, recursively.
45
+
46
+ [*Example 1*:
47
+
48
+ Translation unit #1
49
+
50
+ ``` cpp
51
+ export module Q;
52
+ export int sq(int i) { return i*i; }
53
+ ```
54
+
55
+ Translation unit #2
56
+
57
+ ``` cpp
58
+ export module R;
59
+ export import Q;
60
+ ```
61
+
62
+ Translation unit #3
63
+
64
+ ``` cpp
65
+ import R;
66
+ int main() { return sq(9); } // OK, sq from module Q
67
+ ```
68
+
69
+ — *end example*]
70
+
71
+ — *end note*]
72
+
73
+ A *single search* in a scope S for a name N from a program point P finds
74
+ all declarations that precede P to which any name that is the same as N
75
+ [[basic.pre]] is bound in S. If any such declaration is a
76
+ *using-declarator* whose terminal name [[expr.prim.id.unqual]] is not
77
+ dependent [[temp.dep.type]], it is replaced by the declarations named by
78
+ the *using-declarator* [[namespace.udecl]].
79
+
80
+ In certain contexts, only certain kinds of declarations are included.
81
+ After any such restriction, any declarations of classes or enumerations
82
+ are discarded if any other declarations are found.
83
+
84
+ [*Note 4*: A type (but not a *typedef-name* or template) is therefore
85
+ hidden by any other entity in its scope. — *end note*]
86
+
87
+ However, if a lookup is *type-only*, only declarations of types and
88
+ templates whose specializations are types are considered; furthermore,
89
+ if declarations of a *typedef-name* and of the type to which it refers
90
+ are found, the declaration of the *typedef-name* is discarded instead of
91
+ the type declaration.
92
+