tmp/tmp1g879hk4/{from.md → to.md}
RENAMED
|
@@ -1,34 +1,25 @@
|
|
| 1 |
#### Dependent types <a id="temp.dep.type">[[temp.dep.type]]</a>
|
| 2 |
|
| 3 |
-
A name refers to the *current instantiation* if it is
|
| 4 |
|
| 5 |
- in the definition of a class template, a nested class of a class
|
| 6 |
template, a member of a class template, or a member of a nested class
|
| 7 |
of a class template, the injected-class-name [[class.pre]] of the
|
| 8 |
class template or nested class,
|
| 9 |
- in the definition of a primary class template or a member of a primary
|
| 10 |
class template, the name of the class template followed by the
|
| 11 |
-
template argument list of
|
| 12 |
-
|
| 13 |
- in the definition of a nested class of a class template, the name of
|
| 14 |
the nested class referenced as a member of the current instantiation,
|
| 15 |
or
|
| 16 |
-
- in the definition of a partial specialization or a
|
| 17 |
-
|
| 18 |
-
template
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
pack expansion [[temp.variadic]] whose pattern is the name of the
|
| 22 |
-
template parameter pack.
|
| 23 |
-
|
| 24 |
-
The template argument list of a primary template is a template argument
|
| 25 |
-
list in which the nᵗʰ template argument has the value of the nᵗʰ
|
| 26 |
-
template parameter of the class template. If the nᵗʰ template parameter
|
| 27 |
-
is a template parameter pack [[temp.variadic]], the nᵗʰ template
|
| 28 |
-
argument is a pack expansion [[temp.variadic]] whose pattern is the name
|
| 29 |
-
of the template parameter pack.
|
| 30 |
|
| 31 |
A template argument that is equivalent to a template parameter can be
|
| 32 |
used in place of that template parameter in a reference to the current
|
| 33 |
instantiation. For a template *type-parameter*, a template argument is
|
| 34 |
equivalent to a template parameter if it denotes the same type. For a
|
|
@@ -110,32 +101,17 @@ template<class T> struct A<T>::B::C : A<T> {
|
|
| 110 |
|
| 111 |
— *end example*]
|
| 112 |
|
| 113 |
— *end note*]
|
| 114 |
|
| 115 |
-
A name is a *member of
|
|
|
|
| 116 |
|
| 117 |
-
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
template. — *end note*]
|
| 122 |
-
- A *qualified-id* in which the *nested-name-specifier* refers to the
|
| 123 |
-
current instantiation and that, when looked up, refers to at least one
|
| 124 |
-
member of a class that is the current instantiation or a non-dependent
|
| 125 |
-
base class thereof. \[*Note 4*: If no such member is found, and the
|
| 126 |
-
current instantiation has any dependent base classes, then the
|
| 127 |
-
*qualified-id* is a member of an unknown specialization; see
|
| 128 |
-
below. — *end note*]
|
| 129 |
-
- An *id-expression* denoting the member in a class member access
|
| 130 |
-
expression [[expr.ref]] for which the type of the object expression is
|
| 131 |
-
the current instantiation, and the *id-expression*, when looked up
|
| 132 |
-
[[basic.lookup.classref]], refers to at least one member of a class
|
| 133 |
-
that is the current instantiation or a non-dependent base class
|
| 134 |
-
thereof. \[*Note 5*: If no such member is found, and the current
|
| 135 |
-
instantiation has any dependent base classes, then the *id-expression*
|
| 136 |
-
is a member of an unknown specialization; see below. — *end note*]
|
| 137 |
|
| 138 |
[*Example 3*:
|
| 139 |
|
| 140 |
``` cpp
|
| 141 |
template <class T> class A {
|
|
@@ -151,66 +127,51 @@ template <class T> int A<T>::f() {
|
|
| 151 |
}
|
| 152 |
```
|
| 153 |
|
| 154 |
— *end example*]
|
| 155 |
|
| 156 |
-
A name
|
| 157 |
-
member of the current instantiation that, when
|
| 158 |
-
|
|
|
|
|
|
|
| 159 |
|
| 160 |
-
A name is
|
| 161 |
|
| 162 |
-
-
|
| 163 |
-
dependent
|
| 164 |
-
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
- the type of the object expression is the current instantiation, the
|
| 172 |
-
current instantiation has at least one dependent base class, and
|
| 173 |
-
name lookup of the *id-expression* does not find a member of a class
|
| 174 |
-
that is the current instantiation or a non-dependent base class
|
| 175 |
-
thereof; or
|
| 176 |
-
- the type of the object expression is not the current instantiation
|
| 177 |
-
and the object expression is type-dependent.
|
| 178 |
-
|
| 179 |
-
If a *qualified-id* in which the *nested-name-specifier* refers to the
|
| 180 |
-
current instantiation is not a member of the current instantiation or a
|
| 181 |
-
member of an unknown specialization, the program is ill-formed even if
|
| 182 |
-
the template containing the *qualified-id* is not instantiated; no
|
| 183 |
-
diagnostic required. Similarly, if the *id-expression* in a class member
|
| 184 |
-
access expression for which the type of the object expression is the
|
| 185 |
-
current instantiation does not refer to a member of the current
|
| 186 |
-
instantiation or a member of an unknown specialization, the program is
|
| 187 |
-
ill-formed even if the template containing the member access expression
|
| 188 |
-
is not instantiated; no diagnostic required.
|
| 189 |
|
| 190 |
[*Example 4*:
|
| 191 |
|
| 192 |
``` cpp
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
A<T>::type i; // OK: refers to a member of the current instantiation
|
| 197 |
-
typename A<T>::other j; // error: neither a member of the current instantiation nor
|
| 198 |
-
// a member of an unknown specialization
|
| 199 |
-
}
|
| 200 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 201 |
```
|
| 202 |
|
| 203 |
— *end example*]
|
| 204 |
|
| 205 |
If, for a given set of template arguments, a specialization of a
|
| 206 |
template is instantiated that refers to a member of the current
|
| 207 |
-
instantiation with a
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
lookup
|
| 211 |
-
context, name lookup is ambiguous.
|
| 212 |
|
| 213 |
[*Example 5*:
|
| 214 |
|
| 215 |
``` cpp
|
| 216 |
struct A {
|
|
@@ -226,36 +187,36 @@ struct C : A, T {
|
|
| 226 |
int f() { return this->m; } // finds A::m in the template definition context
|
| 227 |
int g() { return m; } // finds A::m in the template definition context
|
| 228 |
};
|
| 229 |
|
| 230 |
template int C<B>::f(); // error: finds both A::m and B::m
|
| 231 |
-
template int C<B>::g(); // OK
|
| 232 |
-
// does not occur in the template definition context; see~[class.mfct.non
|
| 233 |
```
|
| 234 |
|
| 235 |
— *end example*]
|
| 236 |
|
| 237 |
A type is dependent if it is
|
| 238 |
|
| 239 |
- a template parameter,
|
| 240 |
-
-
|
| 241 |
-
- a nested class or enumeration that is a
|
| 242 |
-
current instantiation,
|
| 243 |
- a cv-qualified type where the cv-unqualified type is dependent,
|
| 244 |
- a compound type constructed from any dependent type,
|
| 245 |
- an array type whose element type is dependent or whose bound (if any)
|
| 246 |
is value-dependent,
|
|
|
|
|
|
|
| 247 |
- a function type whose exception specification is value-dependent,
|
| 248 |
- denoted by a *simple-template-id* in which either the template name is
|
| 249 |
a template parameter or any of the template arguments is a dependent
|
| 250 |
type or an expression that is type-dependent or value-dependent or is
|
| 251 |
-
a pack expansion
|
| 252 |
-
[[class.pre]] of a class template used without a
|
| 253 |
-
*template-argument-list*. — *end note*] , or
|
| 254 |
- denoted by `decltype(`*expression*`)`, where *expression* is
|
| 255 |
type-dependent [[temp.dep.expr]].
|
| 256 |
|
| 257 |
-
[*Note
|
| 258 |
simply refer to other types, a name that refers to a typedef that is a
|
| 259 |
member of the current instantiation is dependent only if the type
|
| 260 |
referred to is dependent. — *end note*]
|
| 261 |
|
|
|
|
| 1 |
#### Dependent types <a id="temp.dep.type">[[temp.dep.type]]</a>
|
| 2 |
|
| 3 |
+
A name or *template-id* refers to the *current instantiation* if it is
|
| 4 |
|
| 5 |
- in the definition of a class template, a nested class of a class
|
| 6 |
template, a member of a class template, or a member of a nested class
|
| 7 |
of a class template, the injected-class-name [[class.pre]] of the
|
| 8 |
class template or nested class,
|
| 9 |
- in the definition of a primary class template or a member of a primary
|
| 10 |
class template, the name of the class template followed by the
|
| 11 |
+
template argument list of its *template-head* [[temp.arg]] enclosed in
|
| 12 |
+
`<>` (or an equivalent template alias specialization),
|
| 13 |
- in the definition of a nested class of a class template, the name of
|
| 14 |
the nested class referenced as a member of the current instantiation,
|
| 15 |
or
|
| 16 |
+
- in the definition of a class template partial specialization or a
|
| 17 |
+
member of a class template partial specialization, the name of the
|
| 18 |
+
class template followed by a template argument list equivalent to that
|
| 19 |
+
of the partial specialization [[temp.spec.partial]] enclosed in `<>`
|
| 20 |
+
(or an equivalent template alias specialization).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
A template argument that is equivalent to a template parameter can be
|
| 23 |
used in place of that template parameter in a reference to the current
|
| 24 |
instantiation. For a template *type-parameter*, a template argument is
|
| 25 |
equivalent to a template parameter if it denotes the same type. For a
|
|
|
|
| 101 |
|
| 102 |
— *end example*]
|
| 103 |
|
| 104 |
— *end note*]
|
| 105 |
|
| 106 |
+
A qualified [[basic.lookup.qual]] or unqualified name is a *member of
|
| 107 |
+
the current instantiation* if
|
| 108 |
|
| 109 |
+
- its lookup context, if it is a qualified name, is the current
|
| 110 |
+
instantiation, and
|
| 111 |
+
- lookup for it finds any member of a class that is the current
|
| 112 |
+
instantiation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
|
| 114 |
[*Example 3*:
|
| 115 |
|
| 116 |
``` cpp
|
| 117 |
template <class T> class A {
|
|
|
|
| 127 |
}
|
| 128 |
```
|
| 129 |
|
| 130 |
— *end example*]
|
| 131 |
|
| 132 |
+
A qualified or unqualified name names a *dependent member of the current
|
| 133 |
+
instantiation* if it is a member of the current instantiation that, when
|
| 134 |
+
looked up, refers to at least one member declaration (including a
|
| 135 |
+
*using-declarator* whose terminal name is dependent) of a class that is
|
| 136 |
+
the current instantiation.
|
| 137 |
|
| 138 |
+
A qualified name [[basic.lookup.qual]] is dependent if
|
| 139 |
|
| 140 |
+
- it is a *conversion-function-id* whose *conversion-type-id* is
|
| 141 |
+
dependent, or
|
| 142 |
+
- its lookup context is dependent and is not the current instantiation,
|
| 143 |
+
or
|
| 144 |
+
- its lookup context is the current instantiation and it is
|
| 145 |
+
`operator=`,[^11] or
|
| 146 |
+
- its lookup context is the current instantiation and has at least one
|
| 147 |
+
dependent base class, and qualified name lookup for the name finds
|
| 148 |
+
nothing [[basic.lookup.qual]].
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
|
| 150 |
[*Example 4*:
|
| 151 |
|
| 152 |
``` cpp
|
| 153 |
+
struct A {
|
| 154 |
+
using B = int;
|
| 155 |
+
A f();
|
|
|
|
|
|
|
|
|
|
|
|
|
| 156 |
};
|
| 157 |
+
struct C : A {};
|
| 158 |
+
template<class T>
|
| 159 |
+
void g(T t) {
|
| 160 |
+
decltype(t.A::f())::B i; // error: typename needed to interpret B as a type
|
| 161 |
+
}
|
| 162 |
+
template void g(C); // … even though A is ::A here
|
| 163 |
```
|
| 164 |
|
| 165 |
— *end example*]
|
| 166 |
|
| 167 |
If, for a given set of template arguments, a specialization of a
|
| 168 |
template is instantiated that refers to a member of the current
|
| 169 |
+
instantiation with a qualified name, the name is looked up in the
|
| 170 |
+
template instantiation context. If the result of this lookup differs
|
| 171 |
+
from the result of name lookup in the template definition context, name
|
| 172 |
+
lookup is ambiguous.
|
|
|
|
| 173 |
|
| 174 |
[*Example 5*:
|
| 175 |
|
| 176 |
``` cpp
|
| 177 |
struct A {
|
|
|
|
| 187 |
int f() { return this->m; } // finds A::m in the template definition context
|
| 188 |
int g() { return m; } // finds A::m in the template definition context
|
| 189 |
};
|
| 190 |
|
| 191 |
template int C<B>::f(); // error: finds both A::m and B::m
|
| 192 |
+
template int C<B>::g(); // OK, transformation to class member access syntax
|
| 193 |
+
// does not occur in the template definition context; see~[class.mfct.non.static]
|
| 194 |
```
|
| 195 |
|
| 196 |
— *end example*]
|
| 197 |
|
| 198 |
A type is dependent if it is
|
| 199 |
|
| 200 |
- a template parameter,
|
| 201 |
+
- denoted by a dependent (qualified) name,
|
| 202 |
+
- a nested class or enumeration that is a direct member of a class that
|
| 203 |
+
is the current instantiation,
|
| 204 |
- a cv-qualified type where the cv-unqualified type is dependent,
|
| 205 |
- a compound type constructed from any dependent type,
|
| 206 |
- an array type whose element type is dependent or whose bound (if any)
|
| 207 |
is value-dependent,
|
| 208 |
+
- a function type whose parameters include one or more function
|
| 209 |
+
parameter packs,
|
| 210 |
- a function type whose exception specification is value-dependent,
|
| 211 |
- denoted by a *simple-template-id* in which either the template name is
|
| 212 |
a template parameter or any of the template arguments is a dependent
|
| 213 |
type or an expression that is type-dependent or value-dependent or is
|
| 214 |
+
a pack expansion,[^12] or
|
|
|
|
|
|
|
| 215 |
- denoted by `decltype(`*expression*`)`, where *expression* is
|
| 216 |
type-dependent [[temp.dep.expr]].
|
| 217 |
|
| 218 |
+
[*Note 3*: Because typedefs do not introduce new types, but instead
|
| 219 |
simply refer to other types, a name that refers to a typedef that is a
|
| 220 |
member of the current instantiation is dependent only if the type
|
| 221 |
referred to is dependent. — *end note*]
|
| 222 |
|