From Jason Turner

[temp.fct.spec]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmplikwvhnk/{from.md → to.md} +190 -143
tmp/tmplikwvhnk/{from.md → to.md} RENAMED
@@ -120,14 +120,14 @@ int l = f<>(1); // uses #1
120
  ```
121
 
122
  — *end note*]
123
 
124
  Template arguments that are present shall be specified in the
125
- declaration order of their corresponding *template-parameter*s. The
126
  template argument list shall not specify more *template-argument*s than
127
  there are corresponding *template-parameter*s unless one of the
128
- *template-parameter*s is a template parameter pack.
129
 
130
  [*Example 3*:
131
 
132
  ``` cpp
133
  template<class X, class Y, class Z> X f(Y,Z);
@@ -143,11 +143,11 @@ void g() {
143
 
144
  — *end example*]
145
 
146
  Implicit conversions [[conv]] will be performed on a function argument
147
  to convert it to the type of the corresponding function parameter if the
148
- parameter type contains no *template-parameter*s that participate in
149
  template argument deduction.
150
 
151
  [*Note 3*:
152
 
153
  Template parameters do not participate in template argument deduction if
@@ -217,13 +217,14 @@ void g(double d) {
217
  ```
218
 
219
  — *end example*]
220
 
221
  When an explicit template argument list is specified, if the given
222
- *template-id* is not valid [[temp.names]], type deduction fails.
223
- Otherwise, the specified template argument values are substituted for
224
- the corresponding template parameters as specified below.
 
225
 
226
  After this substitution is performed, the function parameter type
227
  adjustments described in  [[dcl.fct]] are performed.
228
 
229
  [*Example 2*: A parameter type of “`void (const int, int[5])`” becomes
@@ -348,29 +349,33 @@ when any template arguments that were deduced or obtained from default
348
  arguments are substituted.
349
 
350
  The *deduction substitution loci* are
351
 
352
  - the function type outside of the *noexcept-specifier*,
353
- - the *explicit-specifier*, and
354
- - the template parameter declarations.
 
 
355
 
356
  The substitution occurs in all types and expressions that are used in
357
  the deduction substitution loci. The expressions include not only
358
  constant expressions such as those that appear in array bounds or as
359
- nontype template arguments but also general expressions (i.e.,
360
  non-constant expressions) inside `sizeof`, `decltype`, and other
361
  contexts that allow non-constant expressions. The substitution proceeds
362
  in lexical order and stops when a condition that causes deduction to
363
  fail is encountered. If substitution into different declarations of the
364
  same function template would cause template instantiations to occur in a
365
  different order or not at all, the program is ill-formed; no diagnostic
366
  required.
367
 
368
- [*Note 4*: The equivalent substitution in exception specifications is
369
- done only when the *noexcept-specifier* is instantiated, at which point
370
- a program is ill-formed if the substitution results in an invalid type
371
- or expression. *end note*]
 
 
372
 
373
  [*Example 6*:
374
 
375
  ``` cpp
376
  template <class T> struct A { using X = typename T::X; };
@@ -408,13 +413,12 @@ effects such as the instantiation of class template specializations
408
  and/or function template specializations, the generation of
409
  implicitly-defined functions, etc. Such effects are not in the
410
  “immediate context” and can result in the program being
411
  ill-formed. — *end note*]
412
 
413
- A *lambda-expression* appearing in a function type or a template
414
- parameter is not considered part of the immediate context for the
415
- purposes of template argument deduction.
416
 
417
  [*Note 7*:
418
 
419
  The intent is to avoid requiring implementations to deal with
420
  substitution failure involving arbitrary statements.
@@ -499,11 +503,12 @@ Type deduction can fail for the following reasons:
499
  *qualified-id* when that type does not contain the specified member,
500
  or
501
  - the specified member is not a type where a type is required, or
502
  - the specified member is not a template where a template is required,
503
  or
504
- - the specified member is not a non-type where a non-type is required.
 
505
 
506
  \[*Example 11*:
507
  ``` cpp
508
  template <int I> struct X { };
509
  template <template <class T> class> struct Z { };
@@ -521,11 +526,11 @@ Type deduction can fail for the following reasons:
521
 
522
  int main() {
523
  // Deduction fails in each of these cases:
524
  f<A>(0); // A does not contain a member Y
525
  f<B>(0); // The Y member of B is not a type
526
- g<C>(0); // The N member of C is not a non-type
527
  h<D>(0); // The TT member of D is not a template
528
  }
529
  ```
530
 
531
  — *end example*]
@@ -538,19 +543,19 @@ Type deduction can fail for the following reasons:
538
  template <class T> int f(int T::*);
539
  int i = f<int>(0);
540
  ```
541
 
542
  — *end example*]
543
- - Attempting to give an invalid type to a non-type template parameter.
544
  \[*Example 13*:
545
  ``` cpp
546
  template <class T, T> struct S {};
547
  template <class T> int f(S<T, T{}>*); // #1
548
  class X {
549
  int m;
550
  };
551
- int i0 = f<X>(0); // #1 uses a value of non-structural type X as a non-type template argument
552
  ```
553
 
554
  — *end example*]
555
  - Attempting to perform an invalid conversion in either a template
556
  argument expression, or an expression used in the function
@@ -563,10 +568,13 @@ Type deduction can fail for the following reasons:
563
 
564
  — *end example*]
565
  - Attempting to create a function type in which a parameter has a type
566
  of `void`, or in which the return type is a function type or array
567
  type.
 
 
 
568
 
569
  — *end note*]
570
 
571
  [*Example 15*:
572
 
@@ -586,23 +594,23 @@ int i2 = f<1>(0); // ambiguous; not narrowing
586
  — *end example*]
587
 
588
  #### Deducing template arguments from a function call <a id="temp.deduct.call">[[temp.deduct.call]]</a>
589
 
590
  Template argument deduction is done by comparing each function template
591
- parameter type (call it `P`) that contains *template-parameter*s that
592
  participate in template argument deduction with the type of the
593
  corresponding argument of the call (call it `A`) as described below. If
594
  removing references and cv-qualifiers from `P` gives
595
- `std::initializer_list<P^{\prime}>` or `P`'`[N]` for some `P`' and `N`
596
- and the argument is a non-empty initializer list [[dcl.init.list]], then
597
- deduction is performed instead for each element of the initializer list
598
- independently, taking `P`' as separate function template parameter types
599
- `P`'_i and the iᵗʰ initializer element as the corresponding argument. In
600
- the `P`'`[N]` case, if `N` is a non-type template parameter, `N` is
601
- deduced from the length of the initializer list. Otherwise, an
602
- initializer list argument causes the parameter to be considered a
603
- non-deduced context [[temp.deduct.type]].
604
 
605
  [*Example 1*:
606
 
607
  ``` cpp
608
  template<class T> void f(std::initializer_list<T>);
@@ -740,19 +748,20 @@ that allow a difference:
740
  transformed `A`.
741
  - The transformed `A` can be another pointer or pointer-to-member type
742
  that can be converted to the deduced `A` via a function pointer
743
  conversion [[conv.fctptr]] and/or qualification conversion
744
  [[conv.qual]].
745
- - If `P` is a class and `P` has the form *simple-template-id*, then the
746
- transformed `A` can be a derived class `D` of the deduced `A`.
747
- Likewise, if `P` is a pointer to a class of the form
748
- *simple-template-id*, the transformed `A` can be a pointer to a
749
- derived class `D` pointed to by the deduced `A`. However, if there is
750
- a class `C` that is a (direct or indirect) base class of `D` and
751
- derived (directly or indirectly) from a class `B` and that would be a
752
- valid deduced `A`, the deduced `A` cannot be `B` or pointer to `B`,
753
- respectively.
 
754
  \[*Example 5*:
755
  ``` cpp
756
  template <typename... T> struct X;
757
  template <> struct X<> {};
758
  template <typename T, typename... Ts>
@@ -771,11 +780,11 @@ that allow a difference:
771
 
772
  These alternatives are considered only if type deduction would otherwise
773
  fail. If they yield more than one possible deduced `A`, the type
774
  deduction fails.
775
 
776
- [*Note 1*: If a *template-parameter* is not used in any of the function
777
  parameters of a function template, or is used only in a non-deduced
778
  context, its corresponding *template-argument* cannot be deduced from a
779
  function call and the *template-argument* must be explicitly
780
  specified. — *end note*]
781
 
@@ -784,14 +793,14 @@ pointer-to-member-function type:
784
 
785
  - If the argument is an overload set containing one or more function
786
  templates, the parameter is treated as a non-deduced context.
787
  - If the argument is an overload set (not containing function
788
  templates), trial argument deduction is attempted using each of the
789
- members of the set. If deduction succeeds for only one of the overload
790
- set members, that member is used as the argument value for the
791
- deduction. If deduction succeeds for more than one member of the
792
- overload set the parameter is treated as a non-deduced context.
793
 
794
  [*Example 6*:
795
 
796
  ``` cpp
797
  // Only one function of an overload set matches the call so the function parameter is a deduced context.
@@ -825,10 +834,26 @@ template <class T> T g(T);
825
  int i = f(1, g); // calls f(int, int (*)(int))
826
  ```
827
 
828
  — *end example*]
829
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
830
  #### Deducing template arguments taking the address of a function template <a id="temp.deduct.funcaddr">[[temp.deduct.funcaddr]]</a>
831
 
832
  Template arguments can be deduced from the type specified when taking
833
  the address of an overload set [[over.over]]. If there is a target, the
834
  function template’s function type and the target type are used as the
@@ -908,11 +933,11 @@ as the parameter template.
908
 
909
  The types used to determine the ordering depend on the context in which
910
  the partial ordering is done:
911
 
912
  - In the context of a function call, the types used are those function
913
- parameter types for which the function call has arguments.[^13]
914
  - In the context of a call to a conversion function, the return types of
915
  the conversion function templates are used.
916
  - In other contexts [[temp.func.order]] the function template’s function
917
  type is used.
918
 
@@ -1035,13 +1060,13 @@ g(Tuple<int>()); // calls #3
1035
 
1036
  Template arguments can be deduced in several different contexts, but in
1037
  each case a type that is specified in terms of template parameters (call
1038
  it `P`) is compared with an actual type (call it `A`), and an attempt is
1039
  made to find template argument values (a type for a type parameter, a
1040
- value for a non-type parameter, or a template for a template parameter)
1041
- that will make `P`, after substitution of the deduced values (call it
1042
- the deduced `A`), compatible with `A`.
1043
 
1044
  In some cases, the deduction is done using a single set of types `P` and
1045
  `A`, in other cases, there will be a set of corresponding types `P` and
1046
  `A`. Type deduction is done independently for each `P/A` pair, and the
1047
  deduced template argument values are then combined. If type deduction
@@ -1051,52 +1076,57 @@ pairs yield different deduced values, or if any template argument
1051
  remains neither deduced nor explicitly specified, template argument
1052
  deduction fails. The type of a type parameter is only deduced from an
1053
  array bound if it is not otherwise deduced.
1054
 
1055
  A given type `P` can be composed from a number of other types,
1056
- templates, and non-type values:
1057
 
1058
  - A function type includes the types of each of the function parameters,
1059
  the return type, and its exception specification.
1060
  - A pointer-to-member type includes the type of the class object pointed
1061
  to and the type of the member pointed to.
1062
  - A type that is a specialization of a class template (e.g., `A<int>`)
1063
- includes the types, templates, and non-type values referenced by the
1064
- template argument list of the specialization.
1065
  - An array type includes the array element type and the value of the
1066
  array bound.
1067
 
1068
- In most cases, the types, templates, and non-type values that are used
1069
- to compose `P` participate in template argument deduction. That is, they
1070
- may be used to determine the value of a template argument, and template
1071
- argument deduction fails if the value so determined is not consistent
1072
- with the values determined elsewhere. In certain contexts, however, the
1073
- value does not participate in type deduction, but instead uses the
1074
- values of template arguments that were either deduced elsewhere or
1075
- explicitly specified. If a template parameter is used only in
1076
- non-deduced contexts and is not explicitly specified, template argument
1077
- deduction fails.
1078
 
1079
- [*Note 1*: Under [[temp.deduct.call]], if `P` contains no
1080
- *template-parameter*s that appear in deduced contexts, no deduction is
1081
- done, so `P` and `A` need not have the same form. — *end note*]
1082
 
1083
  The non-deduced contexts are:
1084
 
1085
  - The *nested-name-specifier* of a type that was specified using a
1086
  *qualified-id*.
 
 
1087
  - The *expression* of a *decltype-specifier*.
1088
- - A non-type template argument or an array bound in which a
 
1089
  subexpression references a template parameter.
1090
  - A template parameter used in the parameter type of a function
1091
  parameter that has a default argument that is being used in the call
1092
  for which argument deduction is being done.
1093
  - A function parameter for which the associated argument is an overload
1094
- set [[over.over]], and one or more of the following apply:
1095
- - more than one function matches the function parameter type
 
1096
  (resulting in an ambiguous deduction), or
1097
- - no function matches the function parameter type, or
 
1098
  - the overload set supplied as an argument contains one or more
1099
  function templates.
1100
  - A function parameter for which the associated argument is an
1101
  initializer list [[dcl.init.list]] but the parameter does not have a
1102
  type for which deduction from an initializer list is specified
@@ -1205,13 +1235,15 @@ void t() {
1205
  }
1206
  ```
1207
 
1208
  — *end example*]
1209
 
1210
- A template type argument `T`, a template template argument `TT`, or a
1211
- template non-type argument `i` can be deduced if `P` and `A` have one of
1212
- the following forms:
 
 
1213
 
1214
  ``` cpp
1215
  \opt{cv} T
1216
  T*
1217
  T&
@@ -1220,47 +1252,48 @@ T&&
1220
  \opt{T}(\opt{T}) noexcept(\opt{i})
1221
  \opt{T} \opt{T}::*
1222
  \opt{TT}<T>
1223
  \opt{TT}<i>
1224
  \opt{TT}<TT>
 
1225
  \opt{TT}<>
1226
  ```
1227
 
1228
  where
1229
 
1230
  - `\opt{T}` represents a type or parameter-type-list that either
1231
  satisfies these rules recursively, is a non-deduced context in `P` or
1232
  `A`, or is the same non-dependent type in `P` and `A`,
1233
- - `\opt{TT}` represents either a class template or a template template
1234
- parameter,
1235
  - `\opt{i}` represents an expression that either is an `i`, is
1236
  value-dependent in `P` or `A`, or has the same constant value in `P`
1237
- and `A`, and
 
 
1238
  - `noexcept(\opt{i})` represents an exception specification
1239
  [[except.spec]] in which the (possibly-implicit, see  [[dcl.fct]])
1240
  *noexcept-specifier*’s operand satisfies the rules for an `\opt{i}`
1241
  above.
1242
 
1243
  [*Note 2*: If a type matches such a form but contains no `T`s, `i`s, or
1244
  `TT`s, deduction is not possible. — *end note*]
1245
 
1246
- Similarly, `<T>` represents template argument lists where at least one
1247
- argument contains a `T`, `<i>` represents template argument lists where
1248
- at least one argument contains an `i` and `<>` represents template
1249
- argument lists where no argument contains a `T` or an `i`.
1250
 
1251
- If `P` has a form that contains `<T>` or `<i>`, then each argument Pᵢ of
1252
- the respective template argument list of `P` is compared with the
1253
- corresponding argument Aᵢ of the corresponding template argument list of
1254
- `A`. If the template argument list of `P` contains a pack expansion that
1255
- is not the last template argument, the entire template argument list is
1256
- a non-deduced context. If `Pᵢ` is a pack expansion, then the pattern of
1257
- `Pᵢ` is compared with each remaining argument in the template argument
1258
- list of `A`. Each comparison deduces template arguments for subsequent
1259
- positions in the template parameter packs expanded by `Pᵢ`. During
1260
- partial ordering [[temp.deduct.partial]], if `Aᵢ` was originally a pack
1261
- expansion:
1262
 
1263
  - if `P` does not contain a template argument corresponding to `Aᵢ` then
1264
  `Aᵢ` is ignored;
1265
  - otherwise, if `Pᵢ` is not a pack expansion, template argument
1266
  deduction fails.
@@ -1361,11 +1394,11 @@ where type is `X<int>` and `T` is `char[6]`.
1361
  — *end example*]
1362
 
1363
  Template arguments cannot be deduced from function arguments involving
1364
  constructs other than the ones specified above.
1365
 
1366
- When the value of the argument corresponding to a non-type template
1367
  parameter `P` that is declared with a dependent type is deduced from an
1368
  expression, the template parameters in the type of `P` are deduced from
1369
  the type of the value.
1370
 
1371
  [*Example 8*:
@@ -1452,12 +1485,12 @@ void g() {
1452
 
1453
  — *end note*]
1454
 
1455
  [*Note 5*:
1456
 
1457
- If, in the declaration of a function template with a non-type template
1458
- parameter, the non-type template parameter is used in a subexpression in
1459
  the function parameter list, the expression is a non-deduced context as
1460
  specified above.
1461
 
1462
  [*Example 12*:
1463
 
@@ -1498,13 +1531,14 @@ int x = deduce<77>(a.xm, 62, b.ym);
1498
 
1499
  — *end note*]
1500
 
1501
  If `P` has a form that contains `<i>`, and if the type of `i` differs
1502
  from the type of the corresponding template parameter of the template
1503
- named by the enclosing *simple-template-id*, deduction fails. If `P` has
1504
- a form that contains `[i]`, and if the type of `i` is not an integral
1505
- type, deduction fails.[^14]
 
1506
 
1507
  If `P` has a form that includes `noexcept(i)` and the type of `i` is not
1508
  `bool`, deduction fails.
1509
 
1510
  [*Example 13*:
@@ -1564,11 +1598,11 @@ void g() {
1564
  }
1565
  ```
1566
 
1567
  — *end example*]
1568
 
1569
- The *template-argument* corresponding to a template *template-parameter*
1570
  is deduced from the type of the *template-argument* of a class template
1571
  specialization used in the argument list of a function call.
1572
 
1573
  [*Example 16*:
1574
 
@@ -1636,23 +1670,26 @@ or implicitly using the operator notation), template argument deduction
1636
  [[temp.deduct]] and checking of any explicit template arguments
1637
  [[temp.arg]] are performed for each function template to find the
1638
  template argument values (if any) that can be used with that function
1639
  template to instantiate a function template specialization that can be
1640
  invoked with the call arguments or, for conversion function templates,
1641
- that can convert to the required type. For each function template, if
1642
- the argument deduction and checking succeeds, the *template-argument*s
1643
- (deduced and/or explicit) are used to synthesize the declaration of a
1644
- single function template specialization which is added to the candidate
1645
- functions set to be used in overload resolution. If, for a given
1646
- function template, argument deduction fails or the synthesized function
1647
- template specialization would be ill-formed, no such function is added
1648
- to the set of candidate functions for that template. The complete set of
1649
- candidate functions includes all the synthesized declarations and all of
1650
- the non-template functions found by name lookup. The synthesized
1651
- declarations are treated like any other functions in the remainder of
1652
- overload resolution, except as explicitly noted in 
1653
- [[over.match.best]].[^15]
 
 
 
1654
 
1655
  [*Example 1*:
1656
 
1657
  ``` cpp
1658
  template<class T> T max(T a, T b) { return a>b?a:b; }
@@ -1677,11 +1714,11 @@ conversion of `char` to `int` for `c`.
1677
  — *end example*]
1678
 
1679
  [*Example 2*:
1680
 
1681
  Here is an example involving conversions on a function argument involved
1682
- in *template-argument* deduction:
1683
 
1684
  ``` cpp
1685
  template<class T> struct B { ... };
1686
  template<class T> struct D : public B<T> { ... };
1687
  template<class T> void f(B<T>&);
@@ -1695,11 +1732,11 @@ void g(B<int>& bi, D<int>& di) {
1695
  — *end example*]
1696
 
1697
  [*Example 3*:
1698
 
1699
  Here is an example involving conversions on a function argument not
1700
- involved in *template-parameter* deduction:
1701
 
1702
  ``` cpp
1703
  template<class T> void f(T*,int); // #1
1704
  template<class T> void f(T,char); // #2
1705
 
@@ -1743,10 +1780,11 @@ in some translation unit [[temp.pre]].
1743
  [basic.lookup]: basic.md#basic.lookup
1744
  [basic.lookup.argdep]: basic.md#basic.lookup.argdep
1745
  [basic.lookup.qual]: basic.md#basic.lookup.qual
1746
  [basic.scope.namespace]: basic.md#basic.scope.namespace
1747
  [basic.scope.scope]: basic.md#basic.scope.scope
 
1748
  [basic.stc.dynamic.deallocation]: basic.md#basic.stc.dynamic.deallocation
1749
  [basic.types]: basic.md#basic.types
1750
  [class.access]: class.md#class.access
1751
  [class.base.init]: class.md#class.base.init
1752
  [class.conv.fct]: class.md#class.conv.fct
@@ -1754,10 +1792,11 @@ in some translation unit [[temp.pre]].
1754
  [class.default.ctor]: class.md#class.default.ctor
1755
  [class.derived]: class.md#class.derived
1756
  [class.dtor]: class.md#class.dtor
1757
  [class.local]: class.md#class.local
1758
  [class.mem]: class.md#class.mem
 
1759
  [class.member.lookup]: basic.md#class.member.lookup
1760
  [class.pre]: class.md#class.pre
1761
  [class.qual]: basic.md#class.qual
1762
  [class.temporary]: basic.md#class.temporary
1763
  [conv]: expr.md#conv
@@ -1766,28 +1805,33 @@ in some translation unit [[temp.pre]].
1766
  [conv.func]: expr.md#conv.func
1767
  [conv.lval]: expr.md#conv.lval
1768
  [conv.qual]: expr.md#conv.qual
1769
  [dcl.align]: dcl.md#dcl.align
1770
  [dcl.attr.grammar]: dcl.md#dcl.attr.grammar
 
 
 
1771
  [dcl.decl]: dcl.md#dcl.decl
1772
  [dcl.fct]: dcl.md#dcl.fct
1773
  [dcl.fct.def.general]: dcl.md#dcl.fct.def.general
1774
  [dcl.fct.default]: dcl.md#dcl.fct.default
1775
  [dcl.init]: dcl.md#dcl.init
1776
  [dcl.init.list]: dcl.md#dcl.init.list
1777
  [dcl.meaning]: dcl.md#dcl.meaning
1778
  [dcl.pre]: dcl.md#dcl.pre
1779
  [dcl.spec.auto]: dcl.md#dcl.spec.auto
 
1780
  [dcl.stc]: dcl.md#dcl.stc
1781
  [dcl.struct.bind]: dcl.md#dcl.struct.bind
1782
  [dcl.type.class.deduct]: dcl.md#dcl.type.class.deduct
1783
  [dcl.type.elab]: dcl.md#dcl.type.elab
1784
  [dcl.type.simple]: dcl.md#dcl.type.simple
1785
  [depr.template.template]: future.md#depr.template.template
1786
  [except.spec]: except.md#except.spec
1787
  [expr.const]: expr.md#expr.const
1788
  [expr.context]: expr.md#expr.context
 
1789
  [expr.log.and]: expr.md#expr.log.and
1790
  [expr.log.or]: expr.md#expr.log.or
1791
  [expr.new]: expr.md#expr.new
1792
  [expr.prim.fold]: expr.md#expr.prim.fold
1793
  [expr.prim.id]: expr.md#expr.prim.id
@@ -1798,13 +1842,15 @@ in some translation unit [[temp.pre]].
1798
  [expr.prim.this]: expr.md#expr.prim.this
1799
  [expr.ref]: expr.md#expr.ref
1800
  [expr.sizeof]: expr.md#expr.sizeof
1801
  [expr.type.conv]: expr.md#expr.type.conv
1802
  [expr.typeid]: expr.md#expr.typeid
 
1803
  [expr.unary.op]: expr.md#expr.unary.op
1804
  [implimits]: limits.md#implimits
1805
  [intro.defs]: intro.md#intro.defs
 
1806
  [intro.object]: basic.md#intro.object
1807
  [lex.string]: lex.md#lex.string
1808
  [module.unit]: module.md#module.unit
1809
  [namespace.udecl]: dcl.md#namespace.udecl
1810
  [over.match]: over.md#over.match
@@ -1813,10 +1859,11 @@ in some translation unit [[temp.pre]].
1813
  [over.match.funcs]: over.md#over.match.funcs
1814
  [over.match.oper]: over.md#over.match.oper
1815
  [over.match.viable]: over.md#over.match.viable
1816
  [over.over]: over.md#over.over
1817
  [special]: class.md#special
 
1818
  [stmt.if]: stmt.md#stmt.if
1819
  [support.types]: support.md#support.types
1820
  [temp]: #temp
1821
  [temp.alias]: #temp.alias
1822
  [temp.arg]: #temp.arg
@@ -1828,13 +1875,15 @@ in some translation unit [[temp.pre]].
1828
  [temp.class]: #temp.class
1829
  [temp.class.general]: #temp.class.general
1830
  [temp.concept]: #temp.concept
1831
  [temp.constr]: #temp.constr
1832
  [temp.constr.atomic]: #temp.constr.atomic
 
1833
  [temp.constr.constr]: #temp.constr.constr
1834
  [temp.constr.constr.general]: #temp.constr.constr.general
1835
  [temp.constr.decl]: #temp.constr.decl
 
1836
  [temp.constr.general]: #temp.constr.general
1837
  [temp.constr.normal]: #temp.constr.normal
1838
  [temp.constr.op]: #temp.constr.op
1839
  [temp.constr.order]: #temp.constr.order
1840
  [temp.decls]: #temp.decls
@@ -1851,11 +1900,13 @@ in some translation unit [[temp.pre]].
1851
  [temp.dep]: #temp.dep
1852
  [temp.dep.candidate]: #temp.dep.candidate
1853
  [temp.dep.constexpr]: #temp.dep.constexpr
1854
  [temp.dep.expr]: #temp.dep.expr
1855
  [temp.dep.general]: #temp.dep.general
 
1856
  [temp.dep.res]: #temp.dep.res
 
1857
  [temp.dep.temp]: #temp.dep.temp
1858
  [temp.dep.type]: #temp.dep.type
1859
  [temp.expl.spec]: #temp.expl.spec
1860
  [temp.explicit]: #temp.explicit
1861
  [temp.fct]: #temp.fct
@@ -1890,66 +1941,62 @@ in some translation unit [[temp.pre]].
1890
  [temp.type]: #temp.type
1891
  [temp.variadic]: #temp.variadic
1892
  [term.incomplete.type]: basic.md#term.incomplete.type
1893
  [term.odr.use]: basic.md#term.odr.use
1894
 
1895
- [^1]: Since template *template-parameter*s and template
1896
- *template-argument*s are treated as types for descriptive purposes,
1897
- the terms *non-type parameter* and *non-type argument* are used to
1898
- refer to non-type, non-template parameters and arguments.
1899
-
1900
- [^2]: A `>` that encloses the *type-id* of a `dynamic_cast`,
1901
  `static_cast`, `reinterpret_cast` or `const_cast`, or which encloses
1902
- the *template-argument*s of a subsequent *template-id*, is
1903
- considered nested for the purpose of this description.
 
1904
 
1905
- [^3]: There is no such ambiguity in a default *template-argument*
1906
  because the form of the *template-parameter* determines the
1907
  allowable forms of the *template-argument*.
1908
 
1909
- [^4]: A constraint is in disjunctive normal form when it is a
1910
- disjunction of clauses where each clause is a conjunction of atomic
1911
- constraints. For atomic constraints A, B, and C, the disjunctive
1912
- normal form of the constraint A ∧ (B ∨ C) is (A ∧ B) ∨ (A ∧ C). Its
1913
- disjunctive clauses are (A ∧ B) and (A ∧ C).
1914
 
1915
- [^5]: A constraint is in conjunctive normal form when it is a
1916
- conjunction of clauses where each clause is a disjunction of atomic
1917
- constraints. For atomic constraints A, B, and C, the constraint
1918
- A ∧ (B ∨ C) is in conjunctive normal form. Its conjunctive clauses
1919
- are A and (B ∨ C).
1920
 
1921
- [^6]: The identity of enumerators is not preserved.
1922
 
1923
- [^7]: An array as a *template-parameter* decays to a pointer.
1924
 
1925
- [^8]: There is no context in which they would be used.
1926
 
1927
- [^9]: That is, declarations of non-template functions do not merely
1928
  guide overload resolution of function template specializations with
1929
  the same name. If such a non-template function is odr-used
1930
  [[term.odr.use]] in a program, it must be defined; it will not be
1931
  implicitly instantiated using the function template definition.
1932
 
1933
- [^10]: This includes friend function declarations.
1934
 
1935
- [^11]: Every instantiation of a class template declares a different set
1936
  of assignment operators.
1937
 
1938
- [^12]: This includes an injected-class-name [[class.pre]] of a class
1939
  template used without a *template-argument-list*.
1940
 
1941
- [^13]: Default arguments are not considered to be arguments in this
1942
  context; they only become arguments after a function has been
1943
  selected.
1944
 
1945
- [^14]: Although the *template-argument* corresponding to a
1946
- *template-parameter* of type `bool` can be deduced from an array
1947
- bound, the resulting value will always be `true` because the array
1948
- bound will be nonzero.
1949
 
1950
- [^15]: The parameters of function template specializations contain no
1951
  template parameter types. The set of conversions allowed on deduced
1952
  arguments is limited, because the argument deduction process
1953
  produces function templates with parameters that either match the
1954
  call arguments exactly or differ only in ways that can be bridged by
1955
  the allowed limited conversions. Non-deduced arguments allow the
 
120
  ```
121
 
122
  — *end note*]
123
 
124
  Template arguments that are present shall be specified in the
125
+ declaration order of their corresponding template parameters. The
126
  template argument list shall not specify more *template-argument*s than
127
  there are corresponding *template-parameter*s unless one of the
128
+ *template-parameter*s declares a template parameter pack.
129
 
130
  [*Example 3*:
131
 
132
  ``` cpp
133
  template<class X, class Y, class Z> X f(Y,Z);
 
143
 
144
  — *end example*]
145
 
146
  Implicit conversions [[conv]] will be performed on a function argument
147
  to convert it to the type of the corresponding function parameter if the
148
+ parameter type contains no template parameters that participate in
149
  template argument deduction.
150
 
151
  [*Note 3*:
152
 
153
  Template parameters do not participate in template argument deduction if
 
217
  ```
218
 
219
  — *end example*]
220
 
221
  When an explicit template argument list is specified, if the given
222
+ *template-id* or *splice-specialization-specifier* is not valid
223
+ [[temp.names]], type deduction fails. Otherwise, the specified template
224
+ argument values are substituted for the corresponding template
225
+ parameters as specified below.
226
 
227
  After this substitution is performed, the function parameter type
228
  adjustments described in  [[dcl.fct]] are performed.
229
 
230
  [*Example 2*: A parameter type of “`void (const int, int[5])`” becomes
 
349
  arguments are substituted.
350
 
351
  The *deduction substitution loci* are
352
 
353
  - the function type outside of the *noexcept-specifier*,
354
+ - the *explicit-specifier*,
355
+ - the template parameter declarations, and
356
+ - the template argument list of a partial specialization
357
+ [[temp.spec.partial.general]].
358
 
359
  The substitution occurs in all types and expressions that are used in
360
  the deduction substitution loci. The expressions include not only
361
  constant expressions such as those that appear in array bounds or as
362
+ constant template arguments but also general expressions (i.e.,
363
  non-constant expressions) inside `sizeof`, `decltype`, and other
364
  contexts that allow non-constant expressions. The substitution proceeds
365
  in lexical order and stops when a condition that causes deduction to
366
  fail is encountered. If substitution into different declarations of the
367
  same function template would cause template instantiations to occur in a
368
  different order or not at all, the program is ill-formed; no diagnostic
369
  required.
370
 
371
+ [*Note 4*: The equivalent substitution in exception specifications
372
+ [[except.spec]] and function contract assertions [[dcl.contract.func]]
373
+ is done only when the *noexcept-specifier* or
374
+ *function-contract-specifier*, respectively, is instantiated, at which
375
+ point a program is ill-formed if the substitution results in an invalid
376
+ type or expression. — *end note*]
377
 
378
  [*Example 6*:
379
 
380
  ``` cpp
381
  template <class T> struct A { using X = typename T::X; };
 
413
  and/or function template specializations, the generation of
414
  implicitly-defined functions, etc. Such effects are not in the
415
  “immediate context” and can result in the program being
416
  ill-formed. — *end note*]
417
 
418
+ When substituting into a *lambda-expression*, substitution into its body
419
+ is not in the immediate context.
 
420
 
421
  [*Note 7*:
422
 
423
  The intent is to avoid requiring implementations to deal with
424
  substitution failure involving arbitrary statements.
 
503
  *qualified-id* when that type does not contain the specified member,
504
  or
505
  - the specified member is not a type where a type is required, or
506
  - the specified member is not a template where a template is required,
507
  or
508
+ - the specified member is not a non-type, non-template where a
509
+ non-type, non-template is required.
510
 
511
  \[*Example 11*:
512
  ``` cpp
513
  template <int I> struct X { };
514
  template <template <class T> class> struct Z { };
 
526
 
527
  int main() {
528
  // Deduction fails in each of these cases:
529
  f<A>(0); // A does not contain a member Y
530
  f<B>(0); // The Y member of B is not a type
531
+ g<C>(0); // The N member of C is not a non-type, non-template name
532
  h<D>(0); // The TT member of D is not a template
533
  }
534
  ```
535
 
536
  — *end example*]
 
543
  template <class T> int f(int T::*);
544
  int i = f<int>(0);
545
  ```
546
 
547
  — *end example*]
548
+ - Attempting to give an invalid type to a constant template parameter.
549
  \[*Example 13*:
550
  ``` cpp
551
  template <class T, T> struct S {};
552
  template <class T> int f(S<T, T{}>*); // #1
553
  class X {
554
  int m;
555
  };
556
+ int i0 = f<X>(0); // #1 uses a value of non-structural type X as a constant template argument
557
  ```
558
 
559
  — *end example*]
560
  - Attempting to perform an invalid conversion in either a template
561
  argument expression, or an expression used in the function
 
568
 
569
  — *end example*]
570
  - Attempting to create a function type in which a parameter has a type
571
  of `void`, or in which the return type is a function type or array
572
  type.
573
+ - Attempting to give to an explicit object parameter of a lambda’s
574
+ function call operator a type not permitted for such
575
+ [[expr.prim.lambda.closure]].
576
 
577
  — *end note*]
578
 
579
  [*Example 15*:
580
 
 
594
  — *end example*]
595
 
596
  #### Deducing template arguments from a function call <a id="temp.deduct.call">[[temp.deduct.call]]</a>
597
 
598
  Template argument deduction is done by comparing each function template
599
+ parameter type (call it `P`) that contains template parameters that
600
  participate in template argument deduction with the type of the
601
  corresponding argument of the call (call it `A`) as described below. If
602
  removing references and cv-qualifiers from `P` gives
603
+ $\tcode{std::initializer_list<P}^{\prime}\tcode{>}$ or `P`'`[N]` for
604
+ some `P`' and `N` and the argument is a non-empty initializer list
605
+ [[dcl.init.list]], then deduction is performed instead for each element
606
+ of the initializer list independently, taking `P`' as separate function
607
+ template parameter types `P`'_i and the iᵗʰ initializer element as the
608
+ corresponding argument. In the `P`'`[N]` case, if `N` is a constant
609
+ template parameter, `N` is deduced from the length of the initializer
610
+ list. Otherwise, an initializer list argument causes the parameter to be
611
+ considered a non-deduced context [[temp.deduct.type]].
612
 
613
  [*Example 1*:
614
 
615
  ``` cpp
616
  template<class T> void f(std::initializer_list<T>);
 
748
  transformed `A`.
749
  - The transformed `A` can be another pointer or pointer-to-member type
750
  that can be converted to the deduced `A` via a function pointer
751
  conversion [[conv.fctptr]] and/or qualification conversion
752
  [[conv.qual]].
753
+ - If `P` is a class and `P` has the form *simple-template-id* or
754
+ `typename`ₒₚₜ *splice-specialization-specifier*, then the transformed
755
+ `A` can be a derived class `D` of the deduced `A`. Likewise, if `P` is
756
+ a pointer to a class of the form *simple-template-id* or
757
+ `typename`ₒₚₜ *splice-specialization-specifier*, the transformed `A`
758
+ can be a pointer to a derived class `D` of the class pointed to by the
759
+ deduced `A`. However, if there is a class `C` that is a (direct or
760
+ indirect) base class of `D` and derived (directly or indirectly) from
761
+ a class `B` and that would be a valid deduced `A`, the deduced `A`
762
+ cannot be `B` or pointer to `B`, respectively.
763
  \[*Example 5*:
764
  ``` cpp
765
  template <typename... T> struct X;
766
  template <> struct X<> {};
767
  template <typename T, typename... Ts>
 
780
 
781
  These alternatives are considered only if type deduction would otherwise
782
  fail. If they yield more than one possible deduced `A`, the type
783
  deduction fails.
784
 
785
+ [*Note 1*: If a template parameter is not used in any of the function
786
  parameters of a function template, or is used only in a non-deduced
787
  context, its corresponding *template-argument* cannot be deduced from a
788
  function call and the *template-argument* must be explicitly
789
  specified. — *end note*]
790
 
 
793
 
794
  - If the argument is an overload set containing one or more function
795
  templates, the parameter is treated as a non-deduced context.
796
  - If the argument is an overload set (not containing function
797
  templates), trial argument deduction is attempted using each of the
798
+ members of the set whose associated constraints [[temp.constr.constr]]
799
+ are satisfied. If all successful deductions yield the same deduced
800
+ `A`, that deduced `A` is the result of deduction; otherwise, the
801
+ parameter is treated as a non-deduced context.
802
 
803
  [*Example 6*:
804
 
805
  ``` cpp
806
  // Only one function of an overload set matches the call so the function parameter is a deduced context.
 
834
  int i = f(1, g); // calls f(int, int (*)(int))
835
  ```
836
 
837
  — *end example*]
838
 
839
+ [*Example 9*:
840
+
841
+ ``` cpp
842
+ // All arguments for placeholder type deduction[dcl.type.auto.deduct] yield the same deduced type.
843
+ template<bool B> struct X {
844
+ static void f(short) requires B; // #1
845
+ static void f(short); // #2
846
+ };
847
+ void test() {
848
+ auto x = &X<true>::f; // OK, deduces void(*)(short), selects #1
849
+ auto y = &X<false>::f; // OK, deduces void(*)(short), selects #2
850
+ }
851
+ ```
852
+
853
+ — *end example*]
854
+
855
  #### Deducing template arguments taking the address of a function template <a id="temp.deduct.funcaddr">[[temp.deduct.funcaddr]]</a>
856
 
857
  Template arguments can be deduced from the type specified when taking
858
  the address of an overload set [[over.over]]. If there is a target, the
859
  function template’s function type and the target type are used as the
 
933
 
934
  The types used to determine the ordering depend on the context in which
935
  the partial ordering is done:
936
 
937
  - In the context of a function call, the types used are those function
938
+ parameter types for which the function call has arguments.[^12]
939
  - In the context of a call to a conversion function, the return types of
940
  the conversion function templates are used.
941
  - In other contexts [[temp.func.order]] the function template’s function
942
  type is used.
943
 
 
1060
 
1061
  Template arguments can be deduced in several different contexts, but in
1062
  each case a type that is specified in terms of template parameters (call
1063
  it `P`) is compared with an actual type (call it `A`), and an attempt is
1064
  made to find template argument values (a type for a type parameter, a
1065
+ value for a constant template parameter, or a template for a template
1066
+ template parameter) that will make `P`, after substitution of the
1067
+ deduced values (call it the deduced `A`), compatible with `A`.
1068
 
1069
  In some cases, the deduction is done using a single set of types `P` and
1070
  `A`, in other cases, there will be a set of corresponding types `P` and
1071
  `A`. Type deduction is done independently for each `P/A` pair, and the
1072
  deduced template argument values are then combined. If type deduction
 
1076
  remains neither deduced nor explicitly specified, template argument
1077
  deduction fails. The type of a type parameter is only deduced from an
1078
  array bound if it is not otherwise deduced.
1079
 
1080
  A given type `P` can be composed from a number of other types,
1081
+ templates, and constant template argument values:
1082
 
1083
  - A function type includes the types of each of the function parameters,
1084
  the return type, and its exception specification.
1085
  - A pointer-to-member type includes the type of the class object pointed
1086
  to and the type of the member pointed to.
1087
  - A type that is a specialization of a class template (e.g., `A<int>`)
1088
+ includes the types, templates, and constant template argument values
1089
+ referenced by the template argument list of the specialization.
1090
  - An array type includes the array element type and the value of the
1091
  array bound.
1092
 
1093
+ In most cases, the types, templates, and constant template argument
1094
+ values that are used to compose `P` participate in template argument
1095
+ deduction. That is, they may be used to determine the value of a
1096
+ template argument, and template argument deduction fails if the value so
1097
+ determined is not consistent with the values determined elsewhere. In
1098
+ certain contexts, however, the value does not participate in type
1099
+ deduction, but instead uses the values of template arguments that were
1100
+ either deduced elsewhere or explicitly specified. If a template
1101
+ parameter is used only in non-deduced contexts and is not explicitly
1102
+ specified, template argument deduction fails.
1103
 
1104
+ [*Note 1*: Under [[temp.deduct.call]], if `P` contains no template
1105
+ parameters that appear in deduced contexts, no deduction is done, so `P`
1106
+ and `A` need not have the same form. — *end note*]
1107
 
1108
  The non-deduced contexts are:
1109
 
1110
  - The *nested-name-specifier* of a type that was specified using a
1111
  *qualified-id*.
1112
+ - A *pack-index-specifier* or a *pack-index-expression*.
1113
+ - A *type-constraint*.
1114
  - The *expression* of a *decltype-specifier*.
1115
+ - The *constant-expression* of a *splice-specifier*.
1116
+ - A constant template argument or an array bound in which a
1117
  subexpression references a template parameter.
1118
  - A template parameter used in the parameter type of a function
1119
  parameter that has a default argument that is being used in the call
1120
  for which argument deduction is being done.
1121
  - A function parameter for which the associated argument is an overload
1122
+ set such that one or more of the following apply:
1123
+ - functions whose associated constraints are satisfied and that do not
1124
+ all have the same function type match the function parameter type
1125
  (resulting in an ambiguous deduction), or
1126
+ - no function whose associated constraints are satisfied matches the
1127
+ function parameter type, or
1128
  - the overload set supplied as an argument contains one or more
1129
  function templates.
1130
  - A function parameter for which the associated argument is an
1131
  initializer list [[dcl.init.list]] but the parameter does not have a
1132
  type for which deduction from an initializer list is specified
 
1235
  }
1236
  ```
1237
 
1238
  — *end example*]
1239
 
1240
+ A type template argument `T`, a constant template argument `i`, a
1241
+ template template argument `TT` denoting a class template or an alias
1242
+ template, or a template template argument `VV` denoting a variable
1243
+ template or a concept can be deduced if `P` and `A` have one of the
1244
+ following forms:
1245
 
1246
  ``` cpp
1247
  \opt{cv} T
1248
  T*
1249
  T&
 
1252
  \opt{T}(\opt{T}) noexcept(\opt{i})
1253
  \opt{T} \opt{T}::*
1254
  \opt{TT}<T>
1255
  \opt{TT}<i>
1256
  \opt{TT}<TT>
1257
+ \opt{TT}<VV>
1258
  \opt{TT}<>
1259
  ```
1260
 
1261
  where
1262
 
1263
  - `\opt{T}` represents a type or parameter-type-list that either
1264
  satisfies these rules recursively, is a non-deduced context in `P` or
1265
  `A`, or is the same non-dependent type in `P` and `A`,
 
 
1266
  - `\opt{i}` represents an expression that either is an `i`, is
1267
  value-dependent in `P` or `A`, or has the same constant value in `P`
1268
+ and `A`,
1269
+ - `\opt{TT}` represents either a class template or a template template
1270
+ parameter, and
1271
  - `noexcept(\opt{i})` represents an exception specification
1272
  [[except.spec]] in which the (possibly-implicit, see  [[dcl.fct]])
1273
  *noexcept-specifier*’s operand satisfies the rules for an `\opt{i}`
1274
  above.
1275
 
1276
  [*Note 2*: If a type matches such a form but contains no `T`s, `i`s, or
1277
  `TT`s, deduction is not possible. — *end note*]
1278
 
1279
+ Similarly, `<X>` represents template argument lists where at least one
1280
+ argument contains an X, where X is one of `T`, `i`, `TT`, or `VV`; and
1281
+ `<>` represents template argument lists where no argument contains a
1282
+ `T`, an `i`, a `TT`, or a `VV`.
1283
 
1284
+ If `P` has a form that contains `<T>`, `<i>`, `<TT>`, or `<VV>`, then
1285
+ each argument Pᵢ of the respective template argument list of `P` is
1286
+ compared with the corresponding argument Aᵢ of the corresponding
1287
+ template argument list of `A`. If the template argument list of `P`
1288
+ contains a pack expansion that is not the last template argument, the
1289
+ entire template argument list is a non-deduced context. If `Pᵢ` is a
1290
+ pack expansion, then the pattern of `Pᵢ` is compared with each remaining
1291
+ argument in the template argument list of `A`. Each comparison deduces
1292
+ template arguments for subsequent positions in the template parameter
1293
+ packs expanded by `Pᵢ`. During partial ordering [[temp.deduct.partial]],
1294
+ if `Aᵢ` was originally a pack expansion:
1295
 
1296
  - if `P` does not contain a template argument corresponding to `Aᵢ` then
1297
  `Aᵢ` is ignored;
1298
  - otherwise, if `Pᵢ` is not a pack expansion, template argument
1299
  deduction fails.
 
1394
  — *end example*]
1395
 
1396
  Template arguments cannot be deduced from function arguments involving
1397
  constructs other than the ones specified above.
1398
 
1399
+ When the value of the argument corresponding to a constant template
1400
  parameter `P` that is declared with a dependent type is deduced from an
1401
  expression, the template parameters in the type of `P` are deduced from
1402
  the type of the value.
1403
 
1404
  [*Example 8*:
 
1485
 
1486
  — *end note*]
1487
 
1488
  [*Note 5*:
1489
 
1490
+ If, in the declaration of a function template with a constant template
1491
+ parameter, the constant template parameter is used in a subexpression in
1492
  the function parameter list, the expression is a non-deduced context as
1493
  specified above.
1494
 
1495
  [*Example 12*:
1496
 
 
1531
 
1532
  — *end note*]
1533
 
1534
  If `P` has a form that contains `<i>`, and if the type of `i` differs
1535
  from the type of the corresponding template parameter of the template
1536
+ named by the enclosing *simple-template-id* or
1537
+ *splice-specialization-specifier*, deduction fails. If `P` has a form
1538
+ that contains `[i]`, and if the type of `i` is not an integral type,
1539
+ deduction fails.[^13]
1540
 
1541
  If `P` has a form that includes `noexcept(i)` and the type of `i` is not
1542
  `bool`, deduction fails.
1543
 
1544
  [*Example 13*:
 
1598
  }
1599
  ```
1600
 
1601
  — *end example*]
1602
 
1603
+ The *template-argument* corresponding to a template template parameter
1604
  is deduced from the type of the *template-argument* of a class template
1605
  specialization used in the argument list of a function call.
1606
 
1607
  [*Example 16*:
1608
 
 
1670
  [[temp.deduct]] and checking of any explicit template arguments
1671
  [[temp.arg]] are performed for each function template to find the
1672
  template argument values (if any) that can be used with that function
1673
  template to instantiate a function template specialization that can be
1674
  invoked with the call arguments or, for conversion function templates,
1675
+ that can convert to the required type. For each function template:
1676
+
1677
+ - If the argument deduction and checking succeeds, the
1678
+ *template-argument*s (deduced and/or explicit) are used to synthesize
1679
+ the declaration of a single function template specialization which is
1680
+ added to the candidate functions set to be used in overload
1681
+ resolution.
1682
+ - If the argument deduction fails or the synthesized function template
1683
+ specialization would be ill-formed, no such function is added to the
1684
+ set of candidate functions for that template.
1685
+
1686
+ The complete set of candidate functions includes all the synthesized
1687
+ declarations and all of the non-template functions found by name lookup.
1688
+ The synthesized declarations are treated like any other functions in the
1689
+ remainder of overload resolution, except as explicitly noted in 
1690
+ [[over.match.best]].[^14]
1691
 
1692
  [*Example 1*:
1693
 
1694
  ``` cpp
1695
  template<class T> T max(T a, T b) { return a>b?a:b; }
 
1714
  — *end example*]
1715
 
1716
  [*Example 2*:
1717
 
1718
  Here is an example involving conversions on a function argument involved
1719
+ in template argument deduction:
1720
 
1721
  ``` cpp
1722
  template<class T> struct B { ... };
1723
  template<class T> struct D : public B<T> { ... };
1724
  template<class T> void f(B<T>&);
 
1732
  — *end example*]
1733
 
1734
  [*Example 3*:
1735
 
1736
  Here is an example involving conversions on a function argument not
1737
+ involved in template argument deduction:
1738
 
1739
  ``` cpp
1740
  template<class T> void f(T*,int); // #1
1741
  template<class T> void f(T,char); // #2
1742
 
 
1780
  [basic.lookup]: basic.md#basic.lookup
1781
  [basic.lookup.argdep]: basic.md#basic.lookup.argdep
1782
  [basic.lookup.qual]: basic.md#basic.lookup.qual
1783
  [basic.scope.namespace]: basic.md#basic.scope.namespace
1784
  [basic.scope.scope]: basic.md#basic.scope.scope
1785
+ [basic.splice]: basic.md#basic.splice
1786
  [basic.stc.dynamic.deallocation]: basic.md#basic.stc.dynamic.deallocation
1787
  [basic.types]: basic.md#basic.types
1788
  [class.access]: class.md#class.access
1789
  [class.base.init]: class.md#class.base.init
1790
  [class.conv.fct]: class.md#class.conv.fct
 
1792
  [class.default.ctor]: class.md#class.default.ctor
1793
  [class.derived]: class.md#class.derived
1794
  [class.dtor]: class.md#class.dtor
1795
  [class.local]: class.md#class.local
1796
  [class.mem]: class.md#class.mem
1797
+ [class.mem.general]: class.md#class.mem.general
1798
  [class.member.lookup]: basic.md#class.member.lookup
1799
  [class.pre]: class.md#class.pre
1800
  [class.qual]: basic.md#class.qual
1801
  [class.temporary]: basic.md#class.temporary
1802
  [conv]: expr.md#conv
 
1805
  [conv.func]: expr.md#conv.func
1806
  [conv.lval]: expr.md#conv.lval
1807
  [conv.qual]: expr.md#conv.qual
1808
  [dcl.align]: dcl.md#dcl.align
1809
  [dcl.attr.grammar]: dcl.md#dcl.attr.grammar
1810
+ [dcl.constexpr]: dcl.md#dcl.constexpr
1811
+ [dcl.contract.func]: dcl.md#dcl.contract.func
1812
+ [dcl.contract.res]: dcl.md#dcl.contract.res
1813
  [dcl.decl]: dcl.md#dcl.decl
1814
  [dcl.fct]: dcl.md#dcl.fct
1815
  [dcl.fct.def.general]: dcl.md#dcl.fct.def.general
1816
  [dcl.fct.default]: dcl.md#dcl.fct.default
1817
  [dcl.init]: dcl.md#dcl.init
1818
  [dcl.init.list]: dcl.md#dcl.init.list
1819
  [dcl.meaning]: dcl.md#dcl.meaning
1820
  [dcl.pre]: dcl.md#dcl.pre
1821
  [dcl.spec.auto]: dcl.md#dcl.spec.auto
1822
+ [dcl.spec.auto.general]: dcl.md#dcl.spec.auto.general
1823
  [dcl.stc]: dcl.md#dcl.stc
1824
  [dcl.struct.bind]: dcl.md#dcl.struct.bind
1825
  [dcl.type.class.deduct]: dcl.md#dcl.type.class.deduct
1826
  [dcl.type.elab]: dcl.md#dcl.type.elab
1827
  [dcl.type.simple]: dcl.md#dcl.type.simple
1828
  [depr.template.template]: future.md#depr.template.template
1829
  [except.spec]: except.md#except.spec
1830
  [expr.const]: expr.md#expr.const
1831
  [expr.context]: expr.md#expr.context
1832
+ [expr.eq]: expr.md#expr.eq
1833
  [expr.log.and]: expr.md#expr.log.and
1834
  [expr.log.or]: expr.md#expr.log.or
1835
  [expr.new]: expr.md#expr.new
1836
  [expr.prim.fold]: expr.md#expr.prim.fold
1837
  [expr.prim.id]: expr.md#expr.prim.id
 
1842
  [expr.prim.this]: expr.md#expr.prim.this
1843
  [expr.ref]: expr.md#expr.ref
1844
  [expr.sizeof]: expr.md#expr.sizeof
1845
  [expr.type.conv]: expr.md#expr.type.conv
1846
  [expr.typeid]: expr.md#expr.typeid
1847
+ [expr.unary.noexcept]: expr.md#expr.unary.noexcept
1848
  [expr.unary.op]: expr.md#expr.unary.op
1849
  [implimits]: limits.md#implimits
1850
  [intro.defs]: intro.md#intro.defs
1851
+ [intro.execution]: basic.md#intro.execution
1852
  [intro.object]: basic.md#intro.object
1853
  [lex.string]: lex.md#lex.string
1854
  [module.unit]: module.md#module.unit
1855
  [namespace.udecl]: dcl.md#namespace.udecl
1856
  [over.match]: over.md#over.match
 
1859
  [over.match.funcs]: over.md#over.match.funcs
1860
  [over.match.oper]: over.md#over.match.oper
1861
  [over.match.viable]: over.md#over.match.viable
1862
  [over.over]: over.md#over.over
1863
  [special]: class.md#special
1864
+ [stmt.expand]: stmt.md#stmt.expand
1865
  [stmt.if]: stmt.md#stmt.if
1866
  [support.types]: support.md#support.types
1867
  [temp]: #temp
1868
  [temp.alias]: #temp.alias
1869
  [temp.arg]: #temp.arg
 
1875
  [temp.class]: #temp.class
1876
  [temp.class.general]: #temp.class.general
1877
  [temp.concept]: #temp.concept
1878
  [temp.constr]: #temp.constr
1879
  [temp.constr.atomic]: #temp.constr.atomic
1880
+ [temp.constr.concept]: #temp.constr.concept
1881
  [temp.constr.constr]: #temp.constr.constr
1882
  [temp.constr.constr.general]: #temp.constr.constr.general
1883
  [temp.constr.decl]: #temp.constr.decl
1884
+ [temp.constr.fold]: #temp.constr.fold
1885
  [temp.constr.general]: #temp.constr.general
1886
  [temp.constr.normal]: #temp.constr.normal
1887
  [temp.constr.op]: #temp.constr.op
1888
  [temp.constr.order]: #temp.constr.order
1889
  [temp.decls]: #temp.decls
 
1900
  [temp.dep]: #temp.dep
1901
  [temp.dep.candidate]: #temp.dep.candidate
1902
  [temp.dep.constexpr]: #temp.dep.constexpr
1903
  [temp.dep.expr]: #temp.dep.expr
1904
  [temp.dep.general]: #temp.dep.general
1905
+ [temp.dep.namespace]: #temp.dep.namespace
1906
  [temp.dep.res]: #temp.dep.res
1907
+ [temp.dep.splice]: #temp.dep.splice
1908
  [temp.dep.temp]: #temp.dep.temp
1909
  [temp.dep.type]: #temp.dep.type
1910
  [temp.expl.spec]: #temp.expl.spec
1911
  [temp.explicit]: #temp.explicit
1912
  [temp.fct]: #temp.fct
 
1941
  [temp.type]: #temp.type
1942
  [temp.variadic]: #temp.variadic
1943
  [term.incomplete.type]: basic.md#term.incomplete.type
1944
  [term.odr.use]: basic.md#term.odr.use
1945
 
1946
+ [^1]: A `>` that encloses the *type-id* of a `dynamic_cast`,
 
 
 
 
 
1947
  `static_cast`, `reinterpret_cast` or `const_cast`, or which encloses
1948
+ the *template-argument*s of a subsequent *template-id* or
1949
+ *splice-specialization-specifier*, is considered nested for the
1950
+ purpose of this description.
1951
 
1952
+ [^2]: There is no such ambiguity in a default *template-argument*
1953
  because the form of the *template-parameter* determines the
1954
  allowable forms of the *template-argument*.
1955
 
1956
+ [^3]: A constraint is in disjunctive normal form when it is a
1957
+ disjunction of clauses where each clause is a conjunction of fold
1958
+ expanded or atomic constraints. For atomic constraints A, B, and C,
1959
+ the disjunctive normal form of the constraint A ∧ (B ∨ C) is
1960
+ (A ∧ B) ∨ (A ∧ C). Its disjunctive clauses are (A ∧ B) and (A ∧ C).
1961
 
1962
+ [^4]: A constraint is in conjunctive normal form when it is a
1963
+ conjunction of clauses where each clause is a disjunction of fold
1964
+ expanded or atomic constraints. For atomic constraints A, B, and C,
1965
+ the constraint A ∧ (B ∨ C) is in conjunctive normal form. Its
1966
+ conjunctive clauses are A and (B ∨ C).
1967
 
1968
+ [^5]: The identity of enumerators is not preserved.
1969
 
1970
+ [^6]: An array as a *template-parameter* decays to a pointer.
1971
 
1972
+ [^7]: There is no context in which they would be used.
1973
 
1974
+ [^8]: That is, declarations of non-template functions do not merely
1975
  guide overload resolution of function template specializations with
1976
  the same name. If such a non-template function is odr-used
1977
  [[term.odr.use]] in a program, it must be defined; it will not be
1978
  implicitly instantiated using the function template definition.
1979
 
1980
+ [^9]: This includes friend function declarations.
1981
 
1982
+ [^10]: Every instantiation of a class template declares a different set
1983
  of assignment operators.
1984
 
1985
+ [^11]: This includes an injected-class-name [[class.pre]] of a class
1986
  template used without a *template-argument-list*.
1987
 
1988
+ [^12]: Default arguments are not considered to be arguments in this
1989
  context; they only become arguments after a function has been
1990
  selected.
1991
 
1992
+ [^13]: Although the *template-argument* corresponding to a template
1993
+ parameter of type `bool` can be deduced from an array bound, the
1994
+ resulting value will always be `true` because the array bound will
1995
+ be nonzero.
1996
 
1997
+ [^14]: The parameters of function template specializations contain no
1998
  template parameter types. The set of conversions allowed on deduced
1999
  arguments is limited, because the argument deduction process
2000
  produces function templates with parameters that either match the
2001
  call arguments exactly or differ only in ways that can be bridged by
2002
  the allowed limited conversions. Non-deduced arguments allow the