tmp/tmpwri8455i/{from.md → to.md}
RENAMED
|
@@ -46,10 +46,11 @@ The *declaration* in a *template-declaration* (if any) shall
|
|
| 46 |
- declare or define a function, a class, or a variable, or
|
| 47 |
- define a member function, a member class, a member enumeration, or a
|
| 48 |
static data member of a class template or of a class nested within a
|
| 49 |
class template, or
|
| 50 |
- define a member template of a class or class template, or
|
|
|
|
| 51 |
- be a *deduction-guide*, or
|
| 52 |
- be an *alias-declaration*.
|
| 53 |
|
| 54 |
A *template-declaration* is a *declaration*. A declaration introduced by
|
| 55 |
a template declaration of a variable is a *variable template*. A
|
|
@@ -88,11 +89,11 @@ be a name.
|
|
| 88 |
[*Note 3*: A class or variable template declaration of a
|
| 89 |
*simple-template-id* declares a partial specialization
|
| 90 |
[[temp.spec.partial]]. — *end note*]
|
| 91 |
|
| 92 |
In a *template-declaration*, explicit specialization, or explicit
|
| 93 |
-
instantiation the *init-declarator-list* in the declaration shall
|
| 94 |
contain at most one declarator. When such a declaration is used to
|
| 95 |
declare a class template, no declarator is permitted.
|
| 96 |
|
| 97 |
A specialization (explicit or implicit) of one template is distinct from
|
| 98 |
all specializations of any other template. A template, an explicit
|
|
@@ -102,24 +103,46 @@ not have C language linkage.
|
|
| 102 |
[*Note 4*: Default arguments for function templates and for member
|
| 103 |
functions of class templates are considered definitions for the purpose
|
| 104 |
of template instantiation [[temp.decls]] and must obey the
|
| 105 |
one-definition rule [[basic.def.odr]]. — *end note*]
|
| 106 |
|
| 107 |
-
[*Note 5*:
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
|
| 116 |
An entity is *templated* if it is
|
| 117 |
|
| 118 |
- a template,
|
| 119 |
-
- an entity defined [[basic.def]] or created [[class.temporary]]
|
| 120 |
-
|
|
|
|
| 121 |
- a member of a templated entity,
|
| 122 |
- an enumerator for an enumeration that is a templated entity, or
|
| 123 |
- the closure type of a *lambda-expression* [[expr.prim.lambda.closure]]
|
| 124 |
appearing in the declaration of a templated entity.
|
| 125 |
|
|
@@ -145,11 +168,11 @@ unevaluated operand [[expr.context]].
|
|
| 145 |
|
| 146 |
The expression in a *requires-clause* uses a restricted grammar to avoid
|
| 147 |
ambiguities. Parentheses can be used to specify arbitrary expressions in
|
| 148 |
a *requires-clause*.
|
| 149 |
|
| 150 |
-
[*Example
|
| 151 |
|
| 152 |
``` cpp
|
| 153 |
template<int N> requires N == sizeof new unsigned short
|
| 154 |
int f(); // error: parentheses required around == expression
|
| 155 |
```
|
|
|
|
| 46 |
- declare or define a function, a class, or a variable, or
|
| 47 |
- define a member function, a member class, a member enumeration, or a
|
| 48 |
static data member of a class template or of a class nested within a
|
| 49 |
class template, or
|
| 50 |
- define a member template of a class or class template, or
|
| 51 |
+
- be a *friend-type-declaration*, or
|
| 52 |
- be a *deduction-guide*, or
|
| 53 |
- be an *alias-declaration*.
|
| 54 |
|
| 55 |
A *template-declaration* is a *declaration*. A declaration introduced by
|
| 56 |
a template declaration of a variable is a *variable template*. A
|
|
|
|
| 89 |
[*Note 3*: A class or variable template declaration of a
|
| 90 |
*simple-template-id* declares a partial specialization
|
| 91 |
[[temp.spec.partial]]. — *end note*]
|
| 92 |
|
| 93 |
In a *template-declaration*, explicit specialization, or explicit
|
| 94 |
+
instantiation, the *init-declarator-list* in the declaration shall
|
| 95 |
contain at most one declarator. When such a declaration is used to
|
| 96 |
declare a class template, no declarator is permitted.
|
| 97 |
|
| 98 |
A specialization (explicit or implicit) of one template is distinct from
|
| 99 |
all specializations of any other template. A template, an explicit
|
|
|
|
| 103 |
[*Note 4*: Default arguments for function templates and for member
|
| 104 |
functions of class templates are considered definitions for the purpose
|
| 105 |
of template instantiation [[temp.decls]] and must obey the
|
| 106 |
one-definition rule [[basic.def.odr]]. — *end note*]
|
| 107 |
|
| 108 |
+
[*Note 5*:
|
| 109 |
+
|
| 110 |
+
A template cannot have the same name as any other name bound in the same
|
| 111 |
+
scope [[basic.scope.scope]], except that a function template can share a
|
| 112 |
+
name with *using-declarator*s, a type, non-template functions
|
| 113 |
+
[[dcl.fct]] and/or function templates [[temp.over]]. Specializations,
|
| 114 |
+
including partial specializations [[temp.spec.partial]], do not
|
| 115 |
+
reintroduce or bind names. Their target scope is the target scope of the
|
| 116 |
+
primary template, so all specializations of a template belong to the
|
| 117 |
+
same scope as it does.
|
| 118 |
+
|
| 119 |
+
[*Example 2*:
|
| 120 |
+
|
| 121 |
+
``` cpp
|
| 122 |
+
void f() {}
|
| 123 |
+
class f {}; // OK
|
| 124 |
+
namespace N {
|
| 125 |
+
void f(int) {}
|
| 126 |
+
}
|
| 127 |
+
using N::f; // OK
|
| 128 |
+
template<typename> void f(long) {} // #1, OK
|
| 129 |
+
template<typename> void f(long) {} // error: redefinition of #1
|
| 130 |
+
template<typename> void f(long long) {} // OK
|
| 131 |
+
template<> void f<int>(long long) {} // OK, doesn't bind a name
|
| 132 |
+
```
|
| 133 |
+
|
| 134 |
+
— *end example*]
|
| 135 |
+
|
| 136 |
+
— *end note*]
|
| 137 |
|
| 138 |
An entity is *templated* if it is
|
| 139 |
|
| 140 |
- a template,
|
| 141 |
+
- an entity defined [[basic.def]] or created [[class.temporary]] within
|
| 142 |
+
the *compound-statement* of an *expansion-statement* [[stmt.expand]],
|
| 143 |
+
- an entity defined or created in a templated entity,
|
| 144 |
- a member of a templated entity,
|
| 145 |
- an enumerator for an enumeration that is a templated entity, or
|
| 146 |
- the closure type of a *lambda-expression* [[expr.prim.lambda.closure]]
|
| 147 |
appearing in the declaration of a templated entity.
|
| 148 |
|
|
|
|
| 168 |
|
| 169 |
The expression in a *requires-clause* uses a restricted grammar to avoid
|
| 170 |
ambiguities. Parentheses can be used to specify arbitrary expressions in
|
| 171 |
a *requires-clause*.
|
| 172 |
|
| 173 |
+
[*Example 3*:
|
| 174 |
|
| 175 |
``` cpp
|
| 176 |
template<int N> requires N == sizeof new unsigned short
|
| 177 |
int f(); // error: parentheses required around == expression
|
| 178 |
```
|