tmp/tmpd0da7hfm/{from.md → to.md}
RENAMED
|
@@ -20,11 +20,11 @@ templates and non-template functions [[dcl.fct]] in the same
|
|
| 20 |
scope. — *end note*]
|
| 21 |
|
| 22 |
A non-template function is not related to a function template (i.e., it
|
| 23 |
is never considered to be a specialization), even if it has the same
|
| 24 |
name and type as a potentially generated function template
|
| 25 |
-
specialization.[^
|
| 26 |
|
| 27 |
#### Function template overloading <a id="temp.over.link">[[temp.over.link]]</a>
|
| 28 |
|
| 29 |
It is possible to overload function templates so that two different
|
| 30 |
function template specializations have the same type.
|
|
@@ -90,11 +90,11 @@ template <int K, int L> A<K+L> f(A<K>, A<L>); // same as #1
|
|
| 90 |
template <int I, int J> A<I-J> f(A<I>, A<J>); // different from #1
|
| 91 |
```
|
| 92 |
|
| 93 |
— *end example*]
|
| 94 |
|
| 95 |
-
[*Note 2*: Most expressions that use template parameters use
|
| 96 |
template parameters, but it is possible for an expression to reference a
|
| 97 |
type parameter. For example, a template type parameter can be used in
|
| 98 |
the `sizeof` operator. — *end note*]
|
| 99 |
|
| 100 |
Two expressions involving template parameters are considered
|
|
@@ -121,12 +121,12 @@ signature of a function template with external linkage. — *end note*]
|
|
| 121 |
|
| 122 |
For determining whether two dependent names [[temp.dep]] are equivalent,
|
| 123 |
only the name itself is considered, not the result of name lookup.
|
| 124 |
|
| 125 |
[*Note 5*: If such a dependent name is unqualified, it is looked up
|
| 126 |
-
from
|
| 127 |
-
[[temp.
|
| 128 |
|
| 129 |
[*Example 3*:
|
| 130 |
|
| 131 |
``` cpp
|
| 132 |
template <int I, int J> void f(A<I+J>); // #1
|
|
@@ -182,34 +182,35 @@ declared with a *type-constraint*, and if either *template-head* has a
|
|
| 182 |
corresponding *constraint-expression*s are equivalent. Two
|
| 183 |
*template-parameter*s are *equivalent* under the following conditions:
|
| 184 |
|
| 185 |
- they declare template parameters of the same kind,
|
| 186 |
- if either declares a template parameter pack, they both do,
|
| 187 |
-
- if they declare
|
| 188 |
types ignoring the use of *type-constraint*s for placeholder types,
|
| 189 |
and
|
| 190 |
-
- if they declare template template parameters, their template
|
| 191 |
-
|
| 192 |
|
| 193 |
When determining whether types or *type-constraint*s are equivalent, the
|
| 194 |
rules above are used to compare expressions involving template
|
| 195 |
parameters. Two *template-head*s are *functionally equivalent* if they
|
| 196 |
accept and are satisfied by [[temp.constr.constr]] the same set of
|
| 197 |
template argument lists.
|
| 198 |
|
| 199 |
If the validity or meaning of the program depends on whether two
|
| 200 |
constructs are equivalent, and they are functionally equivalent but not
|
| 201 |
equivalent, the program is ill-formed, no diagnostic required.
|
| 202 |
-
Furthermore, if two
|
| 203 |
|
| 204 |
-
-
|
| 205 |
- have corresponding signatures [[basic.scope.scope]],
|
| 206 |
-
- would declare the same entity
|
| 207 |
-
|
| 208 |
- accept and are satisfied by the same set of template argument lists,
|
| 209 |
|
| 210 |
-
the program is ill-formed, no diagnostic
|
|
|
|
| 211 |
|
| 212 |
[*Note 7*:
|
| 213 |
|
| 214 |
This rule guarantees that equivalent declarations will be linked with
|
| 215 |
one another, while not requiring implementations to use heroic efforts
|
|
@@ -259,20 +260,24 @@ function type. The deduction process determines whether one of the
|
|
| 259 |
templates is more specialized than the other. If so, the more
|
| 260 |
specialized template is the one chosen by the partial ordering process.
|
| 261 |
If both deductions succeed, the partial ordering selects the more
|
| 262 |
constrained template (if one exists) as determined below.
|
| 263 |
|
| 264 |
-
To produce the transformed template, for each type,
|
| 265 |
-
template template
|
| 266 |
-
[[temp.variadic]] thereof) synthesize a unique
|
| 267 |
-
|
| 268 |
-
|
|
|
|
| 269 |
|
| 270 |
[*Note 1*: The type replacing the placeholder in the type of the value
|
| 271 |
-
synthesized for a
|
| 272 |
synthesized type. — *end note*]
|
| 273 |
|
|
|
|
|
|
|
|
|
|
| 274 |
Each function template M that is a member function is considered to have
|
| 275 |
a new first parameter of type X(M), described below, inserted in its
|
| 276 |
function parameter list. If exactly one of the function templates was
|
| 277 |
considered by overload resolution via a rewritten candidate
|
| 278 |
[[over.match.oper]] with a reversed order of parameters, then the order
|
|
|
|
| 20 |
scope. — *end note*]
|
| 21 |
|
| 22 |
A non-template function is not related to a function template (i.e., it
|
| 23 |
is never considered to be a specialization), even if it has the same
|
| 24 |
name and type as a potentially generated function template
|
| 25 |
+
specialization.[^8]
|
| 26 |
|
| 27 |
#### Function template overloading <a id="temp.over.link">[[temp.over.link]]</a>
|
| 28 |
|
| 29 |
It is possible to overload function templates so that two different
|
| 30 |
function template specializations have the same type.
|
|
|
|
| 90 |
template <int I, int J> A<I-J> f(A<I>, A<J>); // different from #1
|
| 91 |
```
|
| 92 |
|
| 93 |
— *end example*]
|
| 94 |
|
| 95 |
+
[*Note 2*: Most expressions that use template parameters use constant
|
| 96 |
template parameters, but it is possible for an expression to reference a
|
| 97 |
type parameter. For example, a template type parameter can be used in
|
| 98 |
the `sizeof` operator. — *end note*]
|
| 99 |
|
| 100 |
Two expressions involving template parameters are considered
|
|
|
|
| 121 |
|
| 122 |
For determining whether two dependent names [[temp.dep]] are equivalent,
|
| 123 |
only the name itself is considered, not the result of name lookup.
|
| 124 |
|
| 125 |
[*Note 5*: If such a dependent name is unqualified, it is looked up
|
| 126 |
+
from a first declaration of the function template
|
| 127 |
+
[[temp.res.general]]. — *end note*]
|
| 128 |
|
| 129 |
[*Example 3*:
|
| 130 |
|
| 131 |
``` cpp
|
| 132 |
template <int I, int J> void f(A<I+J>); // #1
|
|
|
|
| 182 |
corresponding *constraint-expression*s are equivalent. Two
|
| 183 |
*template-parameter*s are *equivalent* under the following conditions:
|
| 184 |
|
| 185 |
- they declare template parameters of the same kind,
|
| 186 |
- if either declares a template parameter pack, they both do,
|
| 187 |
+
- if they declare constant template parameters, they have equivalent
|
| 188 |
types ignoring the use of *type-constraint*s for placeholder types,
|
| 189 |
and
|
| 190 |
+
- if they declare template template parameters, their *template-head*s
|
| 191 |
+
are equivalent.
|
| 192 |
|
| 193 |
When determining whether types or *type-constraint*s are equivalent, the
|
| 194 |
rules above are used to compare expressions involving template
|
| 195 |
parameters. Two *template-head*s are *functionally equivalent* if they
|
| 196 |
accept and are satisfied by [[temp.constr.constr]] the same set of
|
| 197 |
template argument lists.
|
| 198 |
|
| 199 |
If the validity or meaning of the program depends on whether two
|
| 200 |
constructs are equivalent, and they are functionally equivalent but not
|
| 201 |
equivalent, the program is ill-formed, no diagnostic required.
|
| 202 |
+
Furthermore, if two declarations A and B of function templates
|
| 203 |
|
| 204 |
+
- introduce the same name,
|
| 205 |
- have corresponding signatures [[basic.scope.scope]],
|
| 206 |
+
- would declare the same entity, when considering A and B to correspond
|
| 207 |
+
in that determination [[basic.link]], and
|
| 208 |
- accept and are satisfied by the same set of template argument lists,
|
| 209 |
|
| 210 |
+
but do not correspond, the program is ill-formed, no diagnostic
|
| 211 |
+
required.
|
| 212 |
|
| 213 |
[*Note 7*:
|
| 214 |
|
| 215 |
This rule guarantees that equivalent declarations will be linked with
|
| 216 |
one another, while not requiring implementations to use heroic efforts
|
|
|
|
| 260 |
templates is more specialized than the other. If so, the more
|
| 261 |
specialized template is the one chosen by the partial ordering process.
|
| 262 |
If both deductions succeed, the partial ordering selects the more
|
| 263 |
constrained template (if one exists) as determined below.
|
| 264 |
|
| 265 |
+
To produce the transformed template, for each type, constant, type
|
| 266 |
+
template, variable template, or concept template parameter (including
|
| 267 |
+
template parameter packs [[temp.variadic]] thereof) synthesize a unique
|
| 268 |
+
type, value, class template, variable template, or concept,
|
| 269 |
+
respectively, and substitute it for each occurrence of that parameter in
|
| 270 |
+
the function type of the template.
|
| 271 |
|
| 272 |
[*Note 1*: The type replacing the placeholder in the type of the value
|
| 273 |
+
synthesized for a constant template parameter is also a unique
|
| 274 |
synthesized type. — *end note*]
|
| 275 |
|
| 276 |
+
A synthesized template has the same *template-head* as its corresponding
|
| 277 |
+
template template parameter.
|
| 278 |
+
|
| 279 |
Each function template M that is a member function is considered to have
|
| 280 |
a new first parameter of type X(M), described below, inserted in its
|
| 281 |
function parameter list. If exactly one of the function templates was
|
| 282 |
considered by overload resolution via a rewritten candidate
|
| 283 |
[[over.match.oper]] with a reversed order of parameters, then the order
|