tmp/tmpfqji5v2h/{from.md → to.md}
RENAMED
|
@@ -1,15 +1,13 @@
|
|
| 1 |
### General <a id="temp.arg.general">[[temp.arg.general]]</a>
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
form
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
[[temp.variadic]], it will correspond to zero or more
|
| 10 |
-
*template-argument*s.
|
| 11 |
|
| 12 |
[*Example 1*:
|
| 13 |
|
| 14 |
``` cpp
|
| 15 |
template<class T> class Array {
|
|
@@ -41,11 +39,11 @@ is a template parameter pack [[temp.variadic]], the nᵗʰ template
|
|
| 41 |
argument is a pack expansion whose pattern is the name of the template
|
| 42 |
parameter pack.
|
| 43 |
|
| 44 |
In a *template-argument*, an ambiguity between a *type-id* and an
|
| 45 |
expression is resolved to a *type-id*, regardless of the form of the
|
| 46 |
-
corresponding *template-parameter*.[^
|
| 47 |
|
| 48 |
[*Example 2*:
|
| 49 |
|
| 50 |
``` cpp
|
| 51 |
template<class T> void f();
|
|
@@ -57,12 +55,13 @@ void g() {
|
|
| 57 |
```
|
| 58 |
|
| 59 |
— *end example*]
|
| 60 |
|
| 61 |
[*Note 1*: Names used in a *template-argument* are subject to access
|
| 62 |
-
control where they appear. Because a
|
| 63 |
-
member, no access control applies
|
|
|
|
| 64 |
|
| 65 |
[*Example 3*:
|
| 66 |
|
| 67 |
``` cpp
|
| 68 |
template<class T> class X {
|
|
@@ -80,13 +79,13 @@ private:
|
|
| 80 |
X<Y::S> y; // error: S not accessible
|
| 81 |
```
|
| 82 |
|
| 83 |
— *end example*]
|
| 84 |
|
| 85 |
-
For a
|
| 86 |
template definition has no special access rights to the members of the
|
| 87 |
-
|
| 88 |
|
| 89 |
[*Example 4*:
|
| 90 |
|
| 91 |
``` cpp
|
| 92 |
template <template <class TT> class T> class A {
|
|
@@ -101,11 +100,11 @@ private:
|
|
| 101 |
A<B> b; // error: A has no access to B::S
|
| 102 |
```
|
| 103 |
|
| 104 |
— *end example*]
|
| 105 |
|
| 106 |
-
When template argument packs or default
|
| 107 |
*template-argument* list can be empty. In that case the empty `<>`
|
| 108 |
brackets shall still be used as the *template-argument-list*.
|
| 109 |
|
| 110 |
[*Example 5*:
|
| 111 |
|
|
@@ -136,25 +135,26 @@ void f(A<int>* p, A<int>* q) {
|
|
| 136 |
}
|
| 137 |
```
|
| 138 |
|
| 139 |
— *end example*]
|
| 140 |
|
| 141 |
-
If the use of a
|
| 142 |
-
|
| 143 |
-
|
| 144 |
|
| 145 |
When name lookup for the component name of a *template-id* finds an
|
| 146 |
overload set, both non-template functions in the overload set and
|
| 147 |
function templates in the overload set for which the
|
| 148 |
*template-argument*s do not match the *template-parameter*s are ignored.
|
| 149 |
|
| 150 |
[*Note 2*: If none of the function templates have matching
|
| 151 |
*template-parameter*s, the program is ill-formed. — *end note*]
|
| 152 |
|
| 153 |
-
When a *simple-template-id*
|
| 154 |
-
*template-argument* is implicitly
|
| 155 |
-
value of that default argument is
|
|
|
|
| 156 |
|
| 157 |
[*Example 7*:
|
| 158 |
|
| 159 |
``` cpp
|
| 160 |
template<typename T, typename U = int> struct S { };
|
|
|
|
| 1 |
### General <a id="temp.arg.general">[[temp.arg.general]]</a>
|
| 2 |
|
| 3 |
+
The type and form of each *template-argument* specified in a
|
| 4 |
+
*template-id* or in a *splice-specialization-specifier* shall match the
|
| 5 |
+
type and form specified for the corresponding parameter declared by the
|
| 6 |
+
template in its *template-parameter-list*. When the parameter declared
|
| 7 |
+
by the template is a template parameter pack [[temp.variadic]], it will
|
| 8 |
+
correspond to zero or more *template-argument*s.
|
|
|
|
|
|
|
| 9 |
|
| 10 |
[*Example 1*:
|
| 11 |
|
| 12 |
``` cpp
|
| 13 |
template<class T> class Array {
|
|
|
|
| 39 |
argument is a pack expansion whose pattern is the name of the template
|
| 40 |
parameter pack.
|
| 41 |
|
| 42 |
In a *template-argument*, an ambiguity between a *type-id* and an
|
| 43 |
expression is resolved to a *type-id*, regardless of the form of the
|
| 44 |
+
corresponding *template-parameter*.[^2]
|
| 45 |
|
| 46 |
[*Example 2*:
|
| 47 |
|
| 48 |
``` cpp
|
| 49 |
template<class T> void f();
|
|
|
|
| 55 |
```
|
| 56 |
|
| 57 |
— *end example*]
|
| 58 |
|
| 59 |
[*Note 1*: Names used in a *template-argument* are subject to access
|
| 60 |
+
control where they appear. Because a template parameter is not a class
|
| 61 |
+
member, no access control applies where the template parameter is
|
| 62 |
+
used. — *end note*]
|
| 63 |
|
| 64 |
[*Example 3*:
|
| 65 |
|
| 66 |
``` cpp
|
| 67 |
template<class T> class X {
|
|
|
|
| 79 |
X<Y::S> y; // error: S not accessible
|
| 80 |
```
|
| 81 |
|
| 82 |
— *end example*]
|
| 83 |
|
| 84 |
+
For a template argument that is a class type or a class template, the
|
| 85 |
template definition has no special access rights to the members of the
|
| 86 |
+
template argument.
|
| 87 |
|
| 88 |
[*Example 4*:
|
| 89 |
|
| 90 |
``` cpp
|
| 91 |
template <template <class TT> class T> class A {
|
|
|
|
| 100 |
A<B> b; // error: A has no access to B::S
|
| 101 |
```
|
| 102 |
|
| 103 |
— *end example*]
|
| 104 |
|
| 105 |
+
When template argument packs or default template arguments are used, a
|
| 106 |
*template-argument* list can be empty. In that case the empty `<>`
|
| 107 |
brackets shall still be used as the *template-argument-list*.
|
| 108 |
|
| 109 |
[*Example 5*:
|
| 110 |
|
|
|
|
| 135 |
}
|
| 136 |
```
|
| 137 |
|
| 138 |
— *end example*]
|
| 139 |
|
| 140 |
+
If the use of a template argument gives rise to an ill-formed construct
|
| 141 |
+
in the instantiation of a template specialization, the program is
|
| 142 |
+
ill-formed.
|
| 143 |
|
| 144 |
When name lookup for the component name of a *template-id* finds an
|
| 145 |
overload set, both non-template functions in the overload set and
|
| 146 |
function templates in the overload set for which the
|
| 147 |
*template-argument*s do not match the *template-parameter*s are ignored.
|
| 148 |
|
| 149 |
[*Note 2*: If none of the function templates have matching
|
| 150 |
*template-parameter*s, the program is ill-formed. — *end note*]
|
| 151 |
|
| 152 |
+
When a *simple-template-id* or *splice-specialization-specifier* does
|
| 153 |
+
not designate a function, a default *template-argument* is implicitly
|
| 154 |
+
instantiated [[temp.inst]] when the value of that default argument is
|
| 155 |
+
needed.
|
| 156 |
|
| 157 |
[*Example 7*:
|
| 158 |
|
| 159 |
``` cpp
|
| 160 |
template<typename T, typename U = int> struct S { };
|