From Jason Turner

[temp.deduct.general]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpbt8m_htu/{from.md → to.md} +25 -17
tmp/tmpbt8m_htu/{from.md → to.md} RENAMED
@@ -24,13 +24,14 @@ void g(double d) {
24
  ```
25
 
26
  — *end example*]
27
 
28
  When an explicit template argument list is specified, if the given
29
- *template-id* is not valid [[temp.names]], type deduction fails.
30
- Otherwise, the specified template argument values are substituted for
31
- the corresponding template parameters as specified below.
 
32
 
33
  After this substitution is performed, the function parameter type
34
  adjustments described in  [[dcl.fct]] are performed.
35
 
36
  [*Example 2*: A parameter type of “`void (const int, int[5])`” becomes
@@ -155,29 +156,33 @@ when any template arguments that were deduced or obtained from default
155
  arguments are substituted.
156
 
157
  The *deduction substitution loci* are
158
 
159
  - the function type outside of the *noexcept-specifier*,
160
- - the *explicit-specifier*, and
161
- - the template parameter declarations.
 
 
162
 
163
  The substitution occurs in all types and expressions that are used in
164
  the deduction substitution loci. The expressions include not only
165
  constant expressions such as those that appear in array bounds or as
166
- nontype template arguments but also general expressions (i.e.,
167
  non-constant expressions) inside `sizeof`, `decltype`, and other
168
  contexts that allow non-constant expressions. The substitution proceeds
169
  in lexical order and stops when a condition that causes deduction to
170
  fail is encountered. If substitution into different declarations of the
171
  same function template would cause template instantiations to occur in a
172
  different order or not at all, the program is ill-formed; no diagnostic
173
  required.
174
 
175
- [*Note 4*: The equivalent substitution in exception specifications is
176
- done only when the *noexcept-specifier* is instantiated, at which point
177
- a program is ill-formed if the substitution results in an invalid type
178
- or expression. *end note*]
 
 
179
 
180
  [*Example 6*:
181
 
182
  ``` cpp
183
  template <class T> struct A { using X = typename T::X; };
@@ -215,13 +220,12 @@ effects such as the instantiation of class template specializations
215
  and/or function template specializations, the generation of
216
  implicitly-defined functions, etc. Such effects are not in the
217
  “immediate context” and can result in the program being
218
  ill-formed. — *end note*]
219
 
220
- A *lambda-expression* appearing in a function type or a template
221
- parameter is not considered part of the immediate context for the
222
- purposes of template argument deduction.
223
 
224
  [*Note 7*:
225
 
226
  The intent is to avoid requiring implementations to deal with
227
  substitution failure involving arbitrary statements.
@@ -306,11 +310,12 @@ Type deduction can fail for the following reasons:
306
  *qualified-id* when that type does not contain the specified member,
307
  or
308
  - the specified member is not a type where a type is required, or
309
  - the specified member is not a template where a template is required,
310
  or
311
- - the specified member is not a non-type where a non-type is required.
 
312
 
313
  \[*Example 11*:
314
  ``` cpp
315
  template <int I> struct X { };
316
  template <template <class T> class> struct Z { };
@@ -328,11 +333,11 @@ Type deduction can fail for the following reasons:
328
 
329
  int main() {
330
  // Deduction fails in each of these cases:
331
  f<A>(0); // A does not contain a member Y
332
  f<B>(0); // The Y member of B is not a type
333
- g<C>(0); // The N member of C is not a non-type
334
  h<D>(0); // The TT member of D is not a template
335
  }
336
  ```
337
 
338
  — *end example*]
@@ -345,19 +350,19 @@ Type deduction can fail for the following reasons:
345
  template <class T> int f(int T::*);
346
  int i = f<int>(0);
347
  ```
348
 
349
  — *end example*]
350
- - Attempting to give an invalid type to a non-type template parameter.
351
  \[*Example 13*:
352
  ``` cpp
353
  template <class T, T> struct S {};
354
  template <class T> int f(S<T, T{}>*); // #1
355
  class X {
356
  int m;
357
  };
358
- int i0 = f<X>(0); // #1 uses a value of non-structural type X as a non-type template argument
359
  ```
360
 
361
  — *end example*]
362
  - Attempting to perform an invalid conversion in either a template
363
  argument expression, or an expression used in the function
@@ -370,10 +375,13 @@ Type deduction can fail for the following reasons:
370
 
371
  — *end example*]
372
  - Attempting to create a function type in which a parameter has a type
373
  of `void`, or in which the return type is a function type or array
374
  type.
 
 
 
375
 
376
  — *end note*]
377
 
378
  [*Example 15*:
379
 
 
24
  ```
25
 
26
  — *end example*]
27
 
28
  When an explicit template argument list is specified, if the given
29
+ *template-id* or *splice-specialization-specifier* is not valid
30
+ [[temp.names]], type deduction fails. Otherwise, the specified template
31
+ argument values are substituted for the corresponding template
32
+ parameters as specified below.
33
 
34
  After this substitution is performed, the function parameter type
35
  adjustments described in  [[dcl.fct]] are performed.
36
 
37
  [*Example 2*: A parameter type of “`void (const int, int[5])`” becomes
 
156
  arguments are substituted.
157
 
158
  The *deduction substitution loci* are
159
 
160
  - the function type outside of the *noexcept-specifier*,
161
+ - the *explicit-specifier*,
162
+ - the template parameter declarations, and
163
+ - the template argument list of a partial specialization
164
+ [[temp.spec.partial.general]].
165
 
166
  The substitution occurs in all types and expressions that are used in
167
  the deduction substitution loci. The expressions include not only
168
  constant expressions such as those that appear in array bounds or as
169
+ constant template arguments but also general expressions (i.e.,
170
  non-constant expressions) inside `sizeof`, `decltype`, and other
171
  contexts that allow non-constant expressions. The substitution proceeds
172
  in lexical order and stops when a condition that causes deduction to
173
  fail is encountered. If substitution into different declarations of the
174
  same function template would cause template instantiations to occur in a
175
  different order or not at all, the program is ill-formed; no diagnostic
176
  required.
177
 
178
+ [*Note 4*: The equivalent substitution in exception specifications
179
+ [[except.spec]] and function contract assertions [[dcl.contract.func]]
180
+ is done only when the *noexcept-specifier* or
181
+ *function-contract-specifier*, respectively, is instantiated, at which
182
+ point a program is ill-formed if the substitution results in an invalid
183
+ type or expression. — *end note*]
184
 
185
  [*Example 6*:
186
 
187
  ``` cpp
188
  template <class T> struct A { using X = typename T::X; };
 
220
  and/or function template specializations, the generation of
221
  implicitly-defined functions, etc. Such effects are not in the
222
  “immediate context” and can result in the program being
223
  ill-formed. — *end note*]
224
 
225
+ When substituting into a *lambda-expression*, substitution into its body
226
+ is not in the immediate context.
 
227
 
228
  [*Note 7*:
229
 
230
  The intent is to avoid requiring implementations to deal with
231
  substitution failure involving arbitrary statements.
 
310
  *qualified-id* when that type does not contain the specified member,
311
  or
312
  - the specified member is not a type where a type is required, or
313
  - the specified member is not a template where a template is required,
314
  or
315
+ - the specified member is not a non-type, non-template where a
316
+ non-type, non-template is required.
317
 
318
  \[*Example 11*:
319
  ``` cpp
320
  template <int I> struct X { };
321
  template <template <class T> class> struct Z { };
 
333
 
334
  int main() {
335
  // Deduction fails in each of these cases:
336
  f<A>(0); // A does not contain a member Y
337
  f<B>(0); // The Y member of B is not a type
338
+ g<C>(0); // The N member of C is not a non-type, non-template name
339
  h<D>(0); // The TT member of D is not a template
340
  }
341
  ```
342
 
343
  — *end example*]
 
350
  template <class T> int f(int T::*);
351
  int i = f<int>(0);
352
  ```
353
 
354
  — *end example*]
355
+ - Attempting to give an invalid type to a constant template parameter.
356
  \[*Example 13*:
357
  ``` cpp
358
  template <class T, T> struct S {};
359
  template <class T> int f(S<T, T{}>*); // #1
360
  class X {
361
  int m;
362
  };
363
+ int i0 = f<X>(0); // #1 uses a value of non-structural type X as a constant template argument
364
  ```
365
 
366
  — *end example*]
367
  - Attempting to perform an invalid conversion in either a template
368
  argument expression, or an expression used in the function
 
375
 
376
  — *end example*]
377
  - Attempting to create a function type in which a parameter has a type
378
  of `void`, or in which the return type is a function type or array
379
  type.
380
+ - Attempting to give to an explicit object parameter of a lambda’s
381
+ function call operator a type not permitted for such
382
+ [[expr.prim.lambda.closure]].
383
 
384
  — *end note*]
385
 
386
  [*Example 15*:
387