From Jason Turner

[temp.res.general]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpvra8vl9m/{from.md → to.md} +40 -19
tmp/tmpvra8vl9m/{from.md → to.md} RENAMED
@@ -85,11 +85,11 @@ specialization [[temp.point]] but is not found by lookup for the
85
  specialization, the program is ill-formed, no diagnostic required.
86
 
87
  ``` bnf
88
  typename-specifier:
89
  typename nested-name-specifier identifier
90
- typename nested-name-specifier 'templateₒₚₜ ' simple-template-id
91
  ```
92
 
93
  The component names of a *typename-specifier* are its *identifier* (if
94
  any) and those of its *nested-name-specifier* and *simple-template-id*
95
  (if any). A *typename-specifier* denotes the type or class template
@@ -120,48 +120,60 @@ void foo() {
120
  }
121
  ```
122
 
123
  — *end example*]
124
 
125
- A qualified or unqualified name is said to be in a *type-only context*
126
- if it is the terminal name of
127
 
128
- - a *typename-specifier*, *nested-name-specifier*,
129
- *elaborated-type-specifier*, *class-or-decltype*, or
 
 
130
  - a *type-specifier* of a
131
  - *new-type-id*,
132
  - *defining-type-id*,
133
  - *conversion-type-id*,
134
  - *trailing-return-type*,
135
  - default argument of a *type-parameter*, or
136
  - *type-id* of a `static_cast`, `const_cast`, `reinterpret_cast`, or
137
  `dynamic_cast`, or
138
  - a *decl-specifier* of the *decl-specifier-seq* of a
139
- - *simple-declaration* or a *function-definition* in namespace scope,
140
  - *member-declaration*,
141
- - *parameter-declaration* in a *member-declaration*,[^10] unless that
142
  *parameter-declaration* appears in a default argument,
143
  - *parameter-declaration* in a *declarator* of a function or function
144
  template declaration whose *declarator-id* is qualified, unless that
145
  *parameter-declaration* appears in a default argument,
146
  - *parameter-declaration* in a *lambda-declarator* or
147
  *requirement-parameter-list*, unless that *parameter-declaration*
148
  appears in a default argument, or
149
- - *parameter-declaration* of a (non-type) *template-parameter*.
 
 
 
 
 
 
150
 
151
  [*Example 5*:
152
 
153
  ``` cpp
154
  template<class T> T::R f(); // OK, return type of a function declaration at global scope
155
  template<class T> void f(T::R); // ill-formed, no diagnostic required: attempt to declare
156
  // a void variable template
 
157
  template<class T> struct S {
158
  using Ptr = PtrTraits<T>::Ptr; // OK, in a defining-type-id
 
159
  T::R f(T::P p) { // OK, class scope
160
  return static_cast<T::R>(p); // OK, type-id of a static_cast
161
  }
162
  auto g() -> S<T*>::Ptr; // OK, trailing-return-type
 
 
163
  };
164
  template<typename T> void f() {
165
  void (*pf)(T::X); // variable pf of type void* initialized with T::X
166
  void g(T::X); // error: T::X at block scope does not denote a type
167
  // (attempt to declare a void variable)
@@ -196,33 +208,45 @@ int main() {
196
  }
197
  ```
198
 
199
  — *end example*]
200
 
201
- The validity of a template may be checked prior to any instantiation.
 
202
 
203
  [*Note 3*: Knowing which names are type names allows the syntax of
204
  every template to be checked in this way. — *end note*]
205
 
206
- The program is ill-formed, no diagnostic required, if:
207
 
208
  - no valid specialization, ignoring *static_assert-declaration*s that
209
- fail, can be generated for a template or a substatement of a constexpr
210
- if statement [[stmt.if]] within a template and the template is not
 
211
  instantiated, or
 
 
 
 
 
 
 
 
212
  - any *constraint-expression* in the program, introduced or otherwise,
213
  has (in its normal form) an atomic constraint A where no satisfaction
214
  check of A could be well-formed and no satisfaction check of A is
215
  performed, or
216
  - every valid specialization of a variadic template requires an empty
217
  template parameter pack, or
218
- - a hypothetical instantiation of a template immediately following its
219
- definition would be ill-formed due to a construct that does not depend
220
- on a template parameter, or
 
221
  - the interpretation of such a construct in the hypothetical
222
  instantiation is different from the interpretation of the
223
- corresponding construct in any actual instantiation of the template.
 
224
 
225
  [*Note 4*:
226
 
227
  This can happen in situations including the following:
228
 
@@ -253,13 +277,10 @@ This can happen in situations including the following:
253
  it names an explicit specialization that was not declared when the
254
  template was defined.
255
 
256
  — *end note*]
257
 
258
- Otherwise, no diagnostic shall be issued for a template for which a
259
- valid specialization can be generated.
260
-
261
  [*Note 5*: If a template is instantiated, errors will be diagnosed
262
  according to the other rules in this document. Exactly when these errors
263
  are diagnosed is a quality of implementation issue. — *end note*]
264
 
265
  [*Example 7*:
 
85
  specialization, the program is ill-formed, no diagnostic required.
86
 
87
  ``` bnf
88
  typename-specifier:
89
  typename nested-name-specifier identifier
90
+ typename nested-name-specifier templateₒₚₜ simple-template-id
91
  ```
92
 
93
  The component names of a *typename-specifier* are its *identifier* (if
94
  any) and those of its *nested-name-specifier* and *simple-template-id*
95
  (if any). A *typename-specifier* denotes the type or class template
 
120
  }
121
  ```
122
 
123
  — *end example*]
124
 
125
+ A *type-only context* is defined as follows: A qualified or unqualified
126
+ name is said to be in a type-only context if it is the terminal name of
127
 
128
+ - a *typename-specifier*, *type-requirement*, *nested-name-specifier*,
129
+ *elaborated-type-specifier*, *class-or-decltype*,
130
+ *using-enum-declarator*, or
131
+ - a *simple-type-specifier* of a *friend-type-specifier*, or
132
  - a *type-specifier* of a
133
  - *new-type-id*,
134
  - *defining-type-id*,
135
  - *conversion-type-id*,
136
  - *trailing-return-type*,
137
  - default argument of a *type-parameter*, or
138
  - *type-id* of a `static_cast`, `const_cast`, `reinterpret_cast`, or
139
  `dynamic_cast`, or
140
  - a *decl-specifier* of the *decl-specifier-seq* of a
141
+ - *simple-declaration* or *function-definition* in namespace scope,
142
  - *member-declaration*,
143
+ - *parameter-declaration* in a *member-declaration*,[^9] unless that
144
  *parameter-declaration* appears in a default argument,
145
  - *parameter-declaration* in a *declarator* of a function or function
146
  template declaration whose *declarator-id* is qualified, unless that
147
  *parameter-declaration* appears in a default argument,
148
  - *parameter-declaration* in a *lambda-declarator* or
149
  *requirement-parameter-list*, unless that *parameter-declaration*
150
  appears in a default argument, or
151
+ - *parameter-declaration* of a *template-parameter* (which necessarily
152
+ declares a constant template parameter).
153
+
154
+ A *splice-specifier* or *splice-specialization-specifier*
155
+ [[basic.splice]] is said to be in a type-only context if a hypothetical
156
+ qualified name appearing in the same position would be in a type-only
157
+ context.
158
 
159
  [*Example 5*:
160
 
161
  ``` cpp
162
  template<class T> T::R f(); // OK, return type of a function declaration at global scope
163
  template<class T> void f(T::R); // ill-formed, no diagnostic required: attempt to declare
164
  // a void variable template
165
+ enum class Enum { A, B, C };
166
  template<class T> struct S {
167
  using Ptr = PtrTraits<T>::Ptr; // OK, in a defining-type-id
168
+ using Alias = [:^^int:]; // OK, in a defining-type-id
169
  T::R f(T::P p) { // OK, class scope
170
  return static_cast<T::R>(p); // OK, type-id of a static_cast
171
  }
172
  auto g() -> S<T*>::Ptr; // OK, trailing-return-type
173
+ auto h() -> [:^^S:]<T*>; // OK, trailing-return-type
174
+ using enum [:^^Enum:]; // OK, using-enum-declarator
175
  };
176
  template<typename T> void f() {
177
  void (*pf)(T::X); // variable pf of type void* initialized with T::X
178
  void g(T::X); // error: T::X at block scope does not denote a type
179
  // (attempt to declare a void variable)
 
208
  }
209
  ```
210
 
211
  — *end example*]
212
 
213
+ The validity of a templated entity may be checked prior to any
214
+ instantiation.
215
 
216
  [*Note 3*: Knowing which names are type names allows the syntax of
217
  every template to be checked in this way. — *end note*]
218
 
219
+ The program is ill-formed, no diagnostic required, if
220
 
221
  - no valid specialization, ignoring *static_assert-declaration*s that
222
+ fail [[dcl.pre]], can be generated for a templated entity or a
223
+ substatement of a constexpr if statement [[stmt.if]] within a
224
+ templated entity and the innermost enclosing template is not
225
  instantiated, or
226
+ - no valid specialization, ignoring *static_assert-declaration*s that
227
+ fail, can be generated for the *compound-statement* of an
228
+ *expansion-statement* and there is no instantiation of it, or
229
+ - no valid specialization, ignoring *static_assert-declaration*s that
230
+ fail, can be generated for a default *template-argument* and the
231
+ default *template-argument* is not used in any instantiation, or
232
+ - no specialization of an alias template [[temp.alias]] is valid and no
233
+ specialization of the alias template is named in the program, or
234
  - any *constraint-expression* in the program, introduced or otherwise,
235
  has (in its normal form) an atomic constraint A where no satisfaction
236
  check of A could be well-formed and no satisfaction check of A is
237
  performed, or
238
  - every valid specialization of a variadic template requires an empty
239
  template parameter pack, or
240
+ - a hypothetical instantiation of a templated entity immediately
241
+ following its definition would be ill-formed due to a construct (other
242
+ than a *static_assert-declaration* that fails) that does not depend on
243
+ a template parameter, or
244
  - the interpretation of such a construct in the hypothetical
245
  instantiation is different from the interpretation of the
246
+ corresponding construct in any actual instantiation of the templated
247
+ entity.
248
 
249
  [*Note 4*:
250
 
251
  This can happen in situations including the following:
252
 
 
277
  it names an explicit specialization that was not declared when the
278
  template was defined.
279
 
280
  — *end note*]
281
 
 
 
 
282
  [*Note 5*: If a template is instantiated, errors will be diagnosed
283
  according to the other rules in this document. Exactly when these errors
284
  are diagnosed is a quality of implementation issue. — *end note*]
285
 
286
  [*Example 7*: