From Jason Turner

[dcl.meaning.general]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp6qea2_8_/{from.md → to.md} +177 -0
tmp/tmp6qea2_8_/{from.md → to.md} RENAMED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### General <a id="dcl.meaning.general">[[dcl.meaning.general]]</a>
2
+
3
+ A declarator contains exactly one *declarator-id*; it names the entity
4
+ that is declared. If the *unqualified-id* occurring in a *declarator-id*
5
+ is a *template-id*, the declarator shall appear in the *declaration* of
6
+ a *template-declaration* [[temp.decls]], *explicit-specialization*
7
+ [[temp.expl.spec]], or *explicit-instantiation* [[temp.explicit]].
8
+
9
+ [*Note 1*: An *unqualified-id* that is not an *identifier* is used to
10
+ declare certain functions
11
+ [[class.conv.fct]], [[class.dtor]], [[over.oper]], [[over.literal]]. — *end note*]
12
+
13
+ The optional *attribute-specifier-seq* following a *declarator-id*
14
+ appertains to the entity that is declared.
15
+
16
+ If the declaration is a friend declaration:
17
+
18
+ - The *declarator* does not bind a name.
19
+ - If the *id-expression* E in the *declarator-id* of the *declarator* is
20
+ a *qualified-id* or a *template-id*:
21
+ - If the friend declaration is not a template declaration, then in the
22
+ lookup for the terminal name of E:
23
+ - if the *unqualified-id* in E is a *template-id*, all function
24
+ declarations are discarded;
25
+ - otherwise, if the *declarator* corresponds [[basic.scope.scope]]
26
+ to any declaration found of a non-template function, all function
27
+ template declarations are discarded;
28
+ - each remaining function template is replaced with the
29
+ specialization chosen by deduction from the friend declaration
30
+ [[temp.deduct.decl]] or discarded if deduction fails.
31
+ - The *declarator* shall correspond to one or more declarations found
32
+ by the lookup; they shall all have the same target scope, and the
33
+ target scope of the *declarator* is that scope.
34
+ - Otherwise, the terminal name of E is not looked up. The declaration’s
35
+ target scope is the innermost enclosing namespace scope; if the
36
+ declaration is contained by a block scope, the declaration shall
37
+ correspond to a reachable [[module.reach]] declaration that inhabits
38
+ the innermost block scope.
39
+
40
+ Otherwise:
41
+
42
+ - If the *id-expression* in the *declarator-id* of the *declarator* is a
43
+ *qualified-id* Q, let S be its lookup context [[basic.lookup.qual]];
44
+ the declaration shall inhabit a namespace scope.
45
+ - Otherwise, let S be the entity associated with the scope inhabited by
46
+ the *declarator*.
47
+ - If the *declarator* declares an explicit instantiation or a partial or
48
+ explicit specialization, the *declarator* does not bind a name. If it
49
+ declares a class member, the terminal name of the *declarator-id* is
50
+ not looked up; otherwise, only those lookup results that are nominable
51
+ in S are considered when identifying any function template
52
+ specialization being declared [[temp.deduct.decl]].
53
+ \[*Example 1*:
54
+ ``` cpp
55
+ namespace N {
56
+ inline namespace O {
57
+ template<class T> void f(T); // #1
58
+ template<class T> void g(T) {}
59
+ }
60
+ namespace P {
61
+ template<class T> void f(T*); // #2, more specialized than #1
62
+ template<class> int g;
63
+ }
64
+ using P::f,P::g;
65
+ }
66
+ template<> void N::f(int*) {} // OK, #2 is not nominable
67
+ template void N::g(int); // error: lookup is ambiguous
68
+ ```
69
+
70
+ — *end example*]
71
+ - Otherwise, the terminal name of the *declarator-id* is not looked up.
72
+ If it is a qualified name, the *declarator* shall correspond to one or
73
+ more declarations nominable in S; all the declarations shall have the
74
+ same target scope and the target scope of the *declarator* is that
75
+ scope.
76
+ \[*Example 2*:
77
+ ``` cpp
78
+ namespace Q {
79
+ namespace V {
80
+ void f();
81
+ }
82
+ void V::f() { ... } // OK
83
+ void V::g() { ... } // error: g() is not yet a member of V
84
+ namespace V {
85
+ void g();
86
+ }
87
+ }
88
+
89
+ namespace R {
90
+ void Q::V::g() { ... } // error: R doesn't enclose Q
91
+ }
92
+ ```
93
+
94
+ — *end example*]
95
+ - If the declaration inhabits a block scope S and declares a function
96
+ [[dcl.fct]] or uses the `extern` specifier, the declaration shall not
97
+ be attached to a named module [[module.unit]]; its target scope is the
98
+ innermost enclosing namespace scope, but the name is bound in S.
99
+ \[*Example 3*:
100
+ ``` cpp
101
+ namespace X {
102
+ void p() {
103
+ q(); // error: q not yet declared
104
+ extern void q(); // q is a member of namespace X
105
+ extern void r(); // r is a member of namespace X
106
+ }
107
+
108
+ void middle() {
109
+ q(); // error: q not found
110
+ }
111
+
112
+ void q() { ... } // definition of X::q
113
+ }
114
+
115
+ void q() { ... } // some other, unrelated q
116
+ void X::r() { ... } // error: r cannot be declared by qualified-id
117
+ ```
118
+
119
+ — *end example*]
120
+
121
+ A `static`, `thread_local`, `extern`, `mutable`, `friend`, `inline`,
122
+ `virtual`, `constexpr`, `consteval`, `constinit`, or `typedef` specifier
123
+ or an *explicit-specifier* applies directly to each *declarator-id* in a
124
+ declaration; the type specified for each *declarator-id* depends on both
125
+ the *decl-specifier-seq* and its *declarator*.
126
+
127
+ Thus, (for each *declarator*) a declaration has the form
128
+
129
+ ``` cpp
130
+ T D
131
+ ```
132
+
133
+ where `T` is of the form *attribute-specifier-seq*ₒₚₜ
134
+ *decl-specifier-seq* and `D` is a declarator. Following is a recursive
135
+ procedure for determining the type specified for the contained
136
+ *declarator-id* by such a declaration.
137
+
138
+ First, the *decl-specifier-seq* determines a type. In a declaration
139
+
140
+ ``` cpp
141
+ T D
142
+ ```
143
+
144
+ the *decl-specifier-seq* `T` determines the type `T`.
145
+
146
+ [*Example 4*:
147
+
148
+ In the declaration
149
+
150
+ ``` cpp
151
+ int unsigned i;
152
+ ```
153
+
154
+ the type specifiers `int` `unsigned` determine the type “`unsigned int`”
155
+ [[dcl.type.simple]].
156
+
157
+ — *end example*]
158
+
159
+ In a declaration *attribute-specifier-seq*ₒₚₜ `T` `D` where `D` is an
160
+ unadorned name, the type of the declared entity is “`T`”.
161
+
162
+ In a declaration `T` `D` where `D` has the form
163
+
164
+ ``` bnf
165
+ '(' 'D1' ')'
166
+ ```
167
+
168
+ the type of the contained *declarator-id* is the same as that of the
169
+ contained *declarator-id* in the declaration
170
+
171
+ ``` cpp
172
+ T D1
173
+ ```
174
+
175
+ Parentheses do not alter the type of the embedded *declarator-id*, but
176
+ they can alter the binding of complex declarators.
177
+