From Jason Turner

[temp.arg.template]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpsvv1bpuc/{from.md → to.md} +39 -29
tmp/tmpsvv1bpuc/{from.md → to.md} RENAMED
@@ -1,18 +1,20 @@
1
  ### Template template arguments <a id="temp.arg.template">[[temp.arg.template]]</a>
2
 
3
- A *template-argument* for a template *template-parameter* shall be the
4
- name of a class template or an alias template, expressed as
5
- *id-expression*. Only primary templates are considered when matching the
6
- template template argument with the corresponding parameter; partial
7
- specializations are not considered even if their parameter lists match
8
- that of the template template parameter.
 
 
9
 
10
  Any partial specializations [[temp.spec.partial]] associated with the
11
  primary template are considered when a specialization based on the
12
- template *template-parameter* is instantiated. If a specialization is
13
- not reachable from the point of instantiation, and it would have been
14
  selected had it been reachable, the program is ill-formed, no diagnostic
15
  required.
16
 
17
  [*Example 1*:
18
 
@@ -31,26 +33,34 @@ C<A> c; // V<int> within C<A> uses the primary template, so c.y.x ha
31
  // V<int*> within C<A> uses the partial specialization, so c.z.x has type long
32
  ```
33
 
34
  — *end example*]
35
 
36
- A *template-argument* matches a template *template-parameter* `P` when
37
- `P` is at least as specialized as the *template-argument* `A`. In this
38
- comparison, if `P` is unconstrained, the constraints on `A` are not
39
- considered. If `P` contains a template parameter pack, then `A` also
40
- matches `P` if each of `A`’s template parameters matches the
41
- corresponding template parameter in the *template-head* of `P`. Two
42
- template parameters match if they are of the same kind (type, non-type,
43
- template), for non-type *template-parameter*s, their types are
44
- equivalent [[temp.over.link]], and for template *template-parameter*s,
45
- each of their corresponding *template-parameter*s matches, recursively.
46
- When `P`’s *template-head* contains a template parameter pack
47
- [[temp.variadic]], the template parameter pack will match zero or more
48
- template parameters or template parameter packs in the *template-head*
49
- of `A` with the same type and form as the template parameter pack in `P`
50
- (ignoring whether those template parameters are template parameter
51
- packs).
 
 
 
 
 
 
 
 
52
 
53
  [*Example 2*:
54
 
55
  ``` cpp
56
  template<class T> class A { ... };
@@ -112,11 +122,11 @@ S<Y> s2; // error: P is not at least as specialized as Y
112
  S<Z> s3; // OK, P is at least as specialized as Z
113
  ```
114
 
115
  — *end example*]
116
 
117
- A template *template-parameter* `P` is at least as specialized as a
118
  template *template-argument* `A` if, given the following rewrite to two
119
  function templates, the function template corresponding to `P` is at
120
  least as specialized as the function template corresponding to `A`
121
  according to the partial ordering rules for function templates
122
  [[temp.func.order]]. Given an invented class template `X` with the
@@ -126,14 +136,14 @@ according to the partial ordering rules for function templates
126
  - Each of the two function templates has the same template parameters
127
  and *requires-clause* (if any), respectively, as `P` or `A`.
128
  - Each function template has a single function parameter whose type is a
129
  specialization of `X` with template arguments corresponding to the
130
  template parameters from the respective function template where, for
131
- each template parameter `PP` in the *template-head* of the function
132
- template, a corresponding template argument `AA` is formed. If `PP`
133
  declares a template parameter pack, then `AA` is the pack expansion
134
- `PP...` [[temp.variadic]]; otherwise, `AA` is the *id-expression*
135
- `PP`.
136
 
137
  If the rewrite produces an invalid type, then `P` is not at least as
138
  specialized as `A`.
139
 
 
1
  ### Template template arguments <a id="temp.arg.template">[[temp.arg.template]]</a>
2
 
3
+ A *template-argument* for a template template parameter shall be the
4
+ name of a template. For a *type-tt-parameter*, the name shall denote a
5
+ class template or alias template. For a *variable-tt-parameter*, the
6
+ name shall denote a variable template. For a *concept-tt-parameter*, the
7
+ name shall denote a concept. Only primary templates are considered when
8
+ matching the template template argument with the corresponding
9
+ parameter; partial specializations are not considered even if their
10
+ parameter lists match that of the template template parameter.
11
 
12
  Any partial specializations [[temp.spec.partial]] associated with the
13
  primary template are considered when a specialization based on the
14
+ template template parameter is instantiated. If a specialization is not
15
+ reachable from the point of instantiation, and it would have been
16
  selected had it been reachable, the program is ill-formed, no diagnostic
17
  required.
18
 
19
  [*Example 1*:
20
 
 
33
  // V<int*> within C<A> uses the partial specialization, so c.z.x has type long
34
  ```
35
 
36
  — *end example*]
37
 
38
+ A template template parameter `P` and a *template-argument* `A` are
39
+ *compatible* if
40
+
41
+ - `A` denotes a class template or an alias template and `P` is a type
42
+ template template parameter,
43
+ - `A` denotes a variable template and `P` is a variable template
44
+ template parameter, or
45
+ - `A` denotes a concept and `P` is a concept template parameter.
46
+
47
+ A template *template-argument* `A` matches a template template parameter
48
+ `P` when `A` and `P` are compatible and `P` is at least as specialized
49
+ as `A`, ignoring constraints on `A` if `P` is unconstrained. If `P`
50
+ contains a template parameter pack, then `A` also matches `P` if each of
51
+ `A`’s template parameters matches the corresponding template parameter
52
+ declared in the *template-head* of `P`. Two template parameters match if
53
+ they are of the same kind, for constant template parameters, their types
54
+ are equivalent [[temp.over.link]], and for template template parameters,
55
+ each of their corresponding template parameters matches, recursively.
56
+ When `P`’s *template-head* contains a *template-parameter* that declares
57
+ a template parameter pack [[temp.variadic]], the template parameter pack
58
+ will match zero or more template parameters or template parameter packs
59
+ declared in the *template-head* of `A` with the same type and form as
60
+ the template parameter pack declared in `P` (ignoring whether those
61
+ template parameters are template parameter packs).
62
 
63
  [*Example 2*:
64
 
65
  ``` cpp
66
  template<class T> class A { ... };
 
122
  S<Z> s3; // OK, P is at least as specialized as Z
123
  ```
124
 
125
  — *end example*]
126
 
127
+ A template template parameter `P` is at least as specialized as a
128
  template *template-argument* `A` if, given the following rewrite to two
129
  function templates, the function template corresponding to `P` is at
130
  least as specialized as the function template corresponding to `A`
131
  according to the partial ordering rules for function templates
132
  [[temp.func.order]]. Given an invented class template `X` with the
 
136
  - Each of the two function templates has the same template parameters
137
  and *requires-clause* (if any), respectively, as `P` or `A`.
138
  - Each function template has a single function parameter whose type is a
139
  specialization of `X` with template arguments corresponding to the
140
  template parameters from the respective function template where, for
141
+ each *template-parameter* `PP` in the *template-head* of the function
142
+ template, a corresponding *template-argument* `AA` is formed. If `PP`
143
  declares a template parameter pack, then `AA` is the pack expansion
144
+ `PP...` [[temp.variadic]]; otherwise, `AA` is an *id-expression*
145
+ denoting `PP`.
146
 
147
  If the rewrite produces an invalid type, then `P` is not at least as
148
  specialized as `A`.
149