- tmp/tmpb7upcrej/{from.md → to.md} +137 -66
tmp/tmpb7upcrej/{from.md → to.md}
RENAMED
|
@@ -3,31 +3,38 @@
|
|
| 3 |
Inside a template, some constructs have semantics which may differ from
|
| 4 |
one instantiation to another. Such a construct *depends* on the template
|
| 5 |
parameters. In particular, types and expressions may depend on the type
|
| 6 |
and/or value of template parameters (as determined by the template
|
| 7 |
arguments) and this determines the context for name lookup for certain
|
| 8 |
-
names. An
|
| 9 |
depend on a template parameter) or *value-dependent* (that is, its value
|
| 10 |
-
when evaluated as a constant expression
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
where the *postfix-expression* is an *unqualified-id*, the
|
| 15 |
*unqualified-id* denotes a *dependent name* if
|
| 16 |
|
| 17 |
-
- any of the expressions in the *expression-list* is a pack expansion
|
| 18 |
-
[[temp.variadic]]
|
| 19 |
- any of the expressions or *braced-init-list*s in the *expression-list*
|
| 20 |
-
is type-dependent
|
| 21 |
- the *unqualified-id* is a *template-id* in which any of the template
|
| 22 |
arguments depends on a template parameter.
|
| 23 |
|
| 24 |
If an operand of an operator is a type-dependent expression, the
|
| 25 |
-
operator also denotes a dependent name.
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
point of
|
|
|
|
|
|
|
| 29 |
|
| 30 |
[*Example 1*:
|
| 31 |
|
| 32 |
``` cpp
|
| 33 |
template<class T> struct X : B<T> {
|
|
@@ -37,17 +44,17 @@ template<class T> struct X : B<T> {
|
|
| 37 |
pb->j++;
|
| 38 |
}
|
| 39 |
};
|
| 40 |
```
|
| 41 |
|
| 42 |
-
|
| 43 |
and `pb->j` explicitly depend on the *template-parameter*.
|
| 44 |
|
| 45 |
— *end example*]
|
| 46 |
|
| 47 |
In the definition of a class or class template, the scope of a dependent
|
| 48 |
-
base class
|
| 49 |
lookup either at the point of definition of the class template or member
|
| 50 |
or during an instantiation of the class template or member.
|
| 51 |
|
| 52 |
[*Example 2*:
|
| 53 |
|
|
@@ -97,41 +104,50 @@ not affect the binding of names in `Y<A>`.
|
|
| 97 |
|
| 98 |
A name refers to the *current instantiation* if it is
|
| 99 |
|
| 100 |
- in the definition of a class template, a nested class of a class
|
| 101 |
template, a member of a class template, or a member of a nested class
|
| 102 |
-
of a class template, the injected-class-name
|
| 103 |
-
|
| 104 |
- in the definition of a primary class template or a member of a primary
|
| 105 |
class template, the name of the class template followed by the
|
| 106 |
template argument list of the primary template (as described below)
|
| 107 |
enclosed in `<>` (or an equivalent template alias specialization),
|
| 108 |
- in the definition of a nested class of a class template, the name of
|
| 109 |
the nested class referenced as a member of the current instantiation,
|
| 110 |
or
|
| 111 |
- in the definition of a partial specialization or a member of a partial
|
| 112 |
specialization, the name of the class template followed by the
|
| 113 |
template argument list of the partial specialization enclosed in `<>`
|
| 114 |
-
(or an equivalent template alias specialization). If the
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
parameter pack.
|
| 118 |
|
| 119 |
The template argument list of a primary template is a template argument
|
| 120 |
-
list in which the
|
| 121 |
-
template parameter of the class template. If the
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
|
| 126 |
-
A template argument that is equivalent to a template parameter
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
|
| 134 |
[*Example 1*:
|
| 135 |
|
| 136 |
``` cpp
|
| 137 |
template <class T> class A {
|
|
@@ -156,22 +172,26 @@ template <class T1, class T2, int I> struct B {
|
|
| 156 |
B<T2, T1, I>* b2; // not the current instantiation
|
| 157 |
typedef T1 my_T1;
|
| 158 |
static const int my_I = I;
|
| 159 |
static const int my_I2 = I+0;
|
| 160 |
static const int my_I3 = my_I;
|
|
|
|
|
|
|
| 161 |
B<my_T1, T2, my_I>* b3; // refers to the current instantiation
|
| 162 |
B<my_T1, T2, my_I2>* b4; // not the current instantiation
|
| 163 |
B<my_T1, T2, my_I3>* b5; // refers to the current instantiation
|
|
|
|
|
|
|
| 164 |
};
|
| 165 |
```
|
| 166 |
|
| 167 |
— *end example*]
|
| 168 |
|
| 169 |
A *dependent base class* is a base class that is a dependent type and is
|
| 170 |
not the current instantiation.
|
| 171 |
|
| 172 |
-
[*Note
|
| 173 |
|
| 174 |
A base class can be the current instantiation in the case of a nested
|
| 175 |
class naming an enclosing class as a base.
|
| 176 |
|
| 177 |
[*Example 2*:
|
|
@@ -196,26 +216,26 @@ template<class T> struct A<T>::B::C : A<T> {
|
|
| 196 |
|
| 197 |
A name is a *member of the current instantiation* if it is
|
| 198 |
|
| 199 |
- An unqualified name that, when looked up, refers to at least one
|
| 200 |
member of a class that is the current instantiation or a non-dependent
|
| 201 |
-
base class thereof. \[*Note
|
| 202 |
name in a scope enclosed by the definition of a class
|
| 203 |
template. — *end note*]
|
| 204 |
- A *qualified-id* in which the *nested-name-specifier* refers to the
|
| 205 |
current instantiation and that, when looked up, refers to at least one
|
| 206 |
member of a class that is the current instantiation or a non-dependent
|
| 207 |
-
base class thereof. \[*Note
|
| 208 |
current instantiation has any dependent base classes, then the
|
| 209 |
*qualified-id* is a member of an unknown specialization; see
|
| 210 |
below. — *end note*]
|
| 211 |
- An *id-expression* denoting the member in a class member access
|
| 212 |
-
expression
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
thereof. \[*Note
|
| 217 |
instantiation has any dependent base classes, then the *id-expression*
|
| 218 |
is a member of an unknown specialization; see below. — *end note*]
|
| 219 |
|
| 220 |
[*Example 3*:
|
| 221 |
|
|
@@ -247,18 +267,18 @@ A name is a *member of an unknown specialization* if it is
|
|
| 247 |
current instantiation, the current instantiation has at least one
|
| 248 |
dependent base class, and name lookup of the *qualified-id* does not
|
| 249 |
find any member of a class that is the current instantiation or a
|
| 250 |
non-dependent base class thereof.
|
| 251 |
- An *id-expression* denoting the member in a class member access
|
| 252 |
-
expression
|
| 253 |
- the type of the object expression is the current instantiation, the
|
| 254 |
current instantiation has at least one dependent base class, and
|
| 255 |
name lookup of the *id-expression* does not find a member of a class
|
| 256 |
that is the current instantiation or a non-dependent base class
|
| 257 |
thereof; or
|
| 258 |
-
- the type of the object expression is
|
| 259 |
-
|
| 260 |
|
| 261 |
If a *qualified-id* in which the *nested-name-specifier* refers to the
|
| 262 |
current instantiation is not a member of the current instantiation or a
|
| 263 |
member of an unknown specialization, the program is ill-formed even if
|
| 264 |
the template containing the *qualified-id* is not instantiated; no
|
|
@@ -325,20 +345,20 @@ A type is dependent if it is
|
|
| 325 |
- a cv-qualified type where the cv-unqualified type is dependent,
|
| 326 |
- a compound type constructed from any dependent type,
|
| 327 |
- an array type whose element type is dependent or whose bound (if any)
|
| 328 |
is value-dependent,
|
| 329 |
- a function type whose exception specification is value-dependent,
|
| 330 |
-
- a *simple-template-id* in which either the template name is
|
| 331 |
-
parameter or any of the template arguments is a dependent
|
| 332 |
-
expression that is type-dependent or value-dependent or is
|
| 333 |
-
expansion \[*Note
|
| 334 |
-
[[class]]
|
| 335 |
*template-argument-list*. — *end note*] , or
|
| 336 |
- denoted by `decltype(`*expression*`)`, where *expression* is
|
| 337 |
-
type-dependent
|
| 338 |
|
| 339 |
-
[*Note
|
| 340 |
simply refer to other types, a name that refers to a typedef that is a
|
| 341 |
member of the current instantiation is dependent only if the type
|
| 342 |
referred to is dependent. — *end note*]
|
| 343 |
|
| 344 |
#### Type-dependent expressions <a id="temp.dep.expr">[[temp.dep.expr]]</a>
|
|
@@ -347,49 +367,77 @@ Except as described below, an expression is type-dependent if any
|
|
| 347 |
subexpression is type-dependent.
|
| 348 |
|
| 349 |
`this`
|
| 350 |
|
| 351 |
is type-dependent if the class type of the enclosing member function is
|
| 352 |
-
dependent
|
| 353 |
|
| 354 |
-
An *id-expression* is type-dependent if it
|
|
|
|
| 355 |
|
| 356 |
- an *identifier* associated by name lookup with one or more
|
| 357 |
declarations declared with a dependent type,
|
| 358 |
- an *identifier* associated by name lookup with a non-type
|
| 359 |
*template-parameter* declared with a type that contains a placeholder
|
| 360 |
-
type
|
|
|
|
|
|
|
|
|
|
| 361 |
- an *identifier* associated by name lookup with one or more
|
| 362 |
declarations of member functions of the current instantiation declared
|
| 363 |
with a return type that contains a placeholder type,
|
| 364 |
- an *identifier* associated by name lookup with a structured binding
|
| 365 |
-
declaration
|
| 366 |
-
|
| 367 |
-
- the *identifier* `__func__`
|
| 368 |
enclosing function is a template, a member of a class template, or a
|
| 369 |
generic lambda,
|
| 370 |
- a *template-id* that is dependent,
|
| 371 |
- a *conversion-function-id* that specifies a dependent type, or
|
| 372 |
- a *nested-name-specifier* or a *qualified-id* that names a member of
|
| 373 |
an unknown specialization;
|
| 374 |
|
| 375 |
or if it names a dependent member of the current instantiation that is a
|
| 376 |
-
static data member of type “array of unknown bound of `T`” for some
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
*
|
| 380 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 381 |
|
| 382 |
Expressions of the following forms are never type-dependent (because the
|
| 383 |
type of the expression cannot be dependent):
|
| 384 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 385 |
[*Note 1*: For the standard library macro `offsetof`, see
|
| 386 |
[[support.types]]. — *end note*]
|
| 387 |
|
| 388 |
-
A class member access expression
|
| 389 |
-
|
| 390 |
-
|
| 391 |
expression refers to a member of an unknown specialization.
|
| 392 |
|
| 393 |
[*Note 2*: In an expression of the form `x.y` or `xp->y` the type of
|
| 394 |
the expression is usually the type of the member `y` of the class of `x`
|
| 395 |
(or the class pointed to by `xp`). However, if `x` or `xp` refers to a
|
|
@@ -409,37 +457,60 @@ Except as described below, an expression used in a context where a
|
|
| 409 |
constant expression is required is value-dependent if any subexpression
|
| 410 |
is value-dependent.
|
| 411 |
|
| 412 |
An *id-expression* is value-dependent if:
|
| 413 |
|
|
|
|
| 414 |
- it is type-dependent,
|
| 415 |
- it is the name of a non-type template parameter,
|
| 416 |
- it names a static data member that is a dependent member of the
|
| 417 |
current instantiation and is not initialized in a *member-declarator*,
|
| 418 |
- it names a static member function that is a dependent member of the
|
| 419 |
current instantiation, or
|
| 420 |
-
- it
|
| 421 |
-
expression that is value-dependent.
|
| 422 |
|
| 423 |
Expressions of the following form are value-dependent if the
|
| 424 |
*unary-expression* or *expression* is type-dependent or the *type-id* is
|
| 425 |
dependent:
|
| 426 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 427 |
[*Note 1*: For the standard library macro `offsetof`, see
|
| 428 |
[[support.types]]. — *end note*]
|
| 429 |
|
| 430 |
Expressions of the following form are value-dependent if either the
|
| 431 |
*type-id* or *simple-type-specifier* is dependent or the *expression* or
|
| 432 |
*cast-expression* is value-dependent:
|
| 433 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 434 |
Expressions of the following form are value-dependent:
|
| 435 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 436 |
An expression of the form `&`*qualified-id* where the *qualified-id*
|
| 437 |
names a dependent member of the current instantiation is
|
| 438 |
value-dependent. An expression of the form `&`*cast-expression* is also
|
| 439 |
value-dependent if evaluating *cast-expression* as a core constant
|
| 440 |
-
expression
|
| 441 |
refers to a templated entity that is an object with static or thread
|
| 442 |
storage duration or a member function.
|
| 443 |
|
| 444 |
#### Dependent template arguments <a id="temp.dep.temp">[[temp.dep.temp]]</a>
|
| 445 |
|
|
|
|
| 3 |
Inside a template, some constructs have semantics which may differ from
|
| 4 |
one instantiation to another. Such a construct *depends* on the template
|
| 5 |
parameters. In particular, types and expressions may depend on the type
|
| 6 |
and/or value of template parameters (as determined by the template
|
| 7 |
arguments) and this determines the context for name lookup for certain
|
| 8 |
+
names. An expression may be *type-dependent* (that is, its type may
|
| 9 |
depend on a template parameter) or *value-dependent* (that is, its value
|
| 10 |
+
when evaluated as a constant expression [[expr.const]] may depend on a
|
| 11 |
+
template parameter) as described in this subclause.
|
| 12 |
+
|
| 13 |
+
In an expression of the form:
|
| 14 |
+
|
| 15 |
+
``` bnf
|
| 16 |
+
postfix-expression '(' expression-listₒₚₜ ')'
|
| 17 |
+
```
|
| 18 |
|
| 19 |
where the *postfix-expression* is an *unqualified-id*, the
|
| 20 |
*unqualified-id* denotes a *dependent name* if
|
| 21 |
|
| 22 |
+
- any of the expressions in the *expression-list* is a pack expansion
|
| 23 |
+
[[temp.variadic]],
|
| 24 |
- any of the expressions or *braced-init-list*s in the *expression-list*
|
| 25 |
+
is type-dependent [[temp.dep.expr]], or
|
| 26 |
- the *unqualified-id* is a *template-id* in which any of the template
|
| 27 |
arguments depends on a template parameter.
|
| 28 |
|
| 29 |
If an operand of an operator is a type-dependent expression, the
|
| 30 |
+
operator also denotes a dependent name.
|
| 31 |
+
|
| 32 |
+
[*Note 1*: Such names are unbound and are looked up at the point of the
|
| 33 |
+
template instantiation [[temp.point]] in both the context of the
|
| 34 |
+
template definition and the context of the point of instantiation
|
| 35 |
+
[[temp.dep.candidate]]. — *end note*]
|
| 36 |
|
| 37 |
[*Example 1*:
|
| 38 |
|
| 39 |
``` cpp
|
| 40 |
template<class T> struct X : B<T> {
|
|
|
|
| 44 |
pb->j++;
|
| 45 |
}
|
| 46 |
};
|
| 47 |
```
|
| 48 |
|
| 49 |
+
The base class name `B<T>`, the type name `T::A`, the names `B<T>::i`
|
| 50 |
and `pb->j` explicitly depend on the *template-parameter*.
|
| 51 |
|
| 52 |
— *end example*]
|
| 53 |
|
| 54 |
In the definition of a class or class template, the scope of a dependent
|
| 55 |
+
base class [[temp.dep.type]] is not examined during unqualified name
|
| 56 |
lookup either at the point of definition of the class template or member
|
| 57 |
or during an instantiation of the class template or member.
|
| 58 |
|
| 59 |
[*Example 2*:
|
| 60 |
|
|
|
|
| 104 |
|
| 105 |
A name refers to the *current instantiation* if it is
|
| 106 |
|
| 107 |
- in the definition of a class template, a nested class of a class
|
| 108 |
template, a member of a class template, or a member of a nested class
|
| 109 |
+
of a class template, the injected-class-name [[class.pre]] of the
|
| 110 |
+
class template or nested class,
|
| 111 |
- in the definition of a primary class template or a member of a primary
|
| 112 |
class template, the name of the class template followed by the
|
| 113 |
template argument list of the primary template (as described below)
|
| 114 |
enclosed in `<>` (or an equivalent template alias specialization),
|
| 115 |
- in the definition of a nested class of a class template, the name of
|
| 116 |
the nested class referenced as a member of the current instantiation,
|
| 117 |
or
|
| 118 |
- in the definition of a partial specialization or a member of a partial
|
| 119 |
specialization, the name of the class template followed by the
|
| 120 |
template argument list of the partial specialization enclosed in `<>`
|
| 121 |
+
(or an equivalent template alias specialization). If the nᵗʰ template
|
| 122 |
+
parameter is a template parameter pack, the nᵗʰ template argument is a
|
| 123 |
+
pack expansion [[temp.variadic]] whose pattern is the name of the
|
| 124 |
+
template parameter pack.
|
| 125 |
|
| 126 |
The template argument list of a primary template is a template argument
|
| 127 |
+
list in which the nᵗʰ template argument has the value of the nᵗʰ
|
| 128 |
+
template parameter of the class template. If the nᵗʰ template parameter
|
| 129 |
+
is a template parameter pack [[temp.variadic]], the nᵗʰ template
|
| 130 |
+
argument is a pack expansion [[temp.variadic]] whose pattern is the name
|
| 131 |
+
of the template parameter pack.
|
| 132 |
|
| 133 |
+
A template argument that is equivalent to a template parameter can be
|
| 134 |
+
used in place of that template parameter in a reference to the current
|
| 135 |
+
instantiation. For a template *type-parameter*, a template argument is
|
| 136 |
+
equivalent to a template parameter if it denotes the same type. For a
|
| 137 |
+
non-type template parameter, a template argument is equivalent to a
|
| 138 |
+
template parameter if it is an *identifier* that names a variable that
|
| 139 |
+
is equivalent to the template parameter. A variable is equivalent to a
|
| 140 |
+
template parameter if
|
| 141 |
+
|
| 142 |
+
- it has the same type as the template parameter (ignoring
|
| 143 |
+
cv-qualification) and
|
| 144 |
+
- its initializer consists of a single *identifier* that names the
|
| 145 |
+
template parameter or, recursively, such a variable.
|
| 146 |
+
|
| 147 |
+
[*Note 1*: Using a parenthesized variable name breaks the
|
| 148 |
+
equivalence. — *end note*]
|
| 149 |
|
| 150 |
[*Example 1*:
|
| 151 |
|
| 152 |
``` cpp
|
| 153 |
template <class T> class A {
|
|
|
|
| 172 |
B<T2, T1, I>* b2; // not the current instantiation
|
| 173 |
typedef T1 my_T1;
|
| 174 |
static const int my_I = I;
|
| 175 |
static const int my_I2 = I+0;
|
| 176 |
static const int my_I3 = my_I;
|
| 177 |
+
static const long my_I4 = I;
|
| 178 |
+
static const int my_I5 = (I);
|
| 179 |
B<my_T1, T2, my_I>* b3; // refers to the current instantiation
|
| 180 |
B<my_T1, T2, my_I2>* b4; // not the current instantiation
|
| 181 |
B<my_T1, T2, my_I3>* b5; // refers to the current instantiation
|
| 182 |
+
B<my_T1, T2, my_I4>* b6; // not the current instantiation
|
| 183 |
+
B<my_T1, T2, my_I5>* b7; // not the current instantiation
|
| 184 |
};
|
| 185 |
```
|
| 186 |
|
| 187 |
— *end example*]
|
| 188 |
|
| 189 |
A *dependent base class* is a base class that is a dependent type and is
|
| 190 |
not the current instantiation.
|
| 191 |
|
| 192 |
+
[*Note 2*:
|
| 193 |
|
| 194 |
A base class can be the current instantiation in the case of a nested
|
| 195 |
class naming an enclosing class as a base.
|
| 196 |
|
| 197 |
[*Example 2*:
|
|
|
|
| 216 |
|
| 217 |
A name is a *member of the current instantiation* if it is
|
| 218 |
|
| 219 |
- An unqualified name that, when looked up, refers to at least one
|
| 220 |
member of a class that is the current instantiation or a non-dependent
|
| 221 |
+
base class thereof. \[*Note 3*: This can only occur when looking up a
|
| 222 |
name in a scope enclosed by the definition of a class
|
| 223 |
template. — *end note*]
|
| 224 |
- A *qualified-id* in which the *nested-name-specifier* refers to the
|
| 225 |
current instantiation and that, when looked up, refers to at least one
|
| 226 |
member of a class that is the current instantiation or a non-dependent
|
| 227 |
+
base class thereof. \[*Note 4*: If no such member is found, and the
|
| 228 |
current instantiation has any dependent base classes, then the
|
| 229 |
*qualified-id* is a member of an unknown specialization; see
|
| 230 |
below. — *end note*]
|
| 231 |
- An *id-expression* denoting the member in a class member access
|
| 232 |
+
expression [[expr.ref]] for which the type of the object expression is
|
| 233 |
+
the current instantiation, and the *id-expression*, when looked up
|
| 234 |
+
[[basic.lookup.classref]], refers to at least one member of a class
|
| 235 |
+
that is the current instantiation or a non-dependent base class
|
| 236 |
+
thereof. \[*Note 5*: If no such member is found, and the current
|
| 237 |
instantiation has any dependent base classes, then the *id-expression*
|
| 238 |
is a member of an unknown specialization; see below. — *end note*]
|
| 239 |
|
| 240 |
[*Example 3*:
|
| 241 |
|
|
|
|
| 267 |
current instantiation, the current instantiation has at least one
|
| 268 |
dependent base class, and name lookup of the *qualified-id* does not
|
| 269 |
find any member of a class that is the current instantiation or a
|
| 270 |
non-dependent base class thereof.
|
| 271 |
- An *id-expression* denoting the member in a class member access
|
| 272 |
+
expression [[expr.ref]] in which either
|
| 273 |
- the type of the object expression is the current instantiation, the
|
| 274 |
current instantiation has at least one dependent base class, and
|
| 275 |
name lookup of the *id-expression* does not find a member of a class
|
| 276 |
that is the current instantiation or a non-dependent base class
|
| 277 |
thereof; or
|
| 278 |
+
- the type of the object expression is not the current instantiation
|
| 279 |
+
and the object expression is type-dependent.
|
| 280 |
|
| 281 |
If a *qualified-id* in which the *nested-name-specifier* refers to the
|
| 282 |
current instantiation is not a member of the current instantiation or a
|
| 283 |
member of an unknown specialization, the program is ill-formed even if
|
| 284 |
the template containing the *qualified-id* is not instantiated; no
|
|
|
|
| 345 |
- a cv-qualified type where the cv-unqualified type is dependent,
|
| 346 |
- a compound type constructed from any dependent type,
|
| 347 |
- an array type whose element type is dependent or whose bound (if any)
|
| 348 |
is value-dependent,
|
| 349 |
- a function type whose exception specification is value-dependent,
|
| 350 |
+
- denoted by a *simple-template-id* in which either the template name is
|
| 351 |
+
a template parameter or any of the template arguments is a dependent
|
| 352 |
+
type or an expression that is type-dependent or value-dependent or is
|
| 353 |
+
a pack expansion \[*Note 6*: This includes an injected-class-name
|
| 354 |
+
[[class.pre]] of a class template used without a
|
| 355 |
*template-argument-list*. — *end note*] , or
|
| 356 |
- denoted by `decltype(`*expression*`)`, where *expression* is
|
| 357 |
+
type-dependent [[temp.dep.expr]].
|
| 358 |
|
| 359 |
+
[*Note 7*: Because typedefs do not introduce new types, but instead
|
| 360 |
simply refer to other types, a name that refers to a typedef that is a
|
| 361 |
member of the current instantiation is dependent only if the type
|
| 362 |
referred to is dependent. — *end note*]
|
| 363 |
|
| 364 |
#### Type-dependent expressions <a id="temp.dep.expr">[[temp.dep.expr]]</a>
|
|
|
|
| 367 |
subexpression is type-dependent.
|
| 368 |
|
| 369 |
`this`
|
| 370 |
|
| 371 |
is type-dependent if the class type of the enclosing member function is
|
| 372 |
+
dependent [[temp.dep.type]].
|
| 373 |
|
| 374 |
+
An *id-expression* is type-dependent if it is not a concept-id and it
|
| 375 |
+
contains
|
| 376 |
|
| 377 |
- an *identifier* associated by name lookup with one or more
|
| 378 |
declarations declared with a dependent type,
|
| 379 |
- an *identifier* associated by name lookup with a non-type
|
| 380 |
*template-parameter* declared with a type that contains a placeholder
|
| 381 |
+
type [[dcl.spec.auto]],
|
| 382 |
+
- an *identifier* associated by name lookup with a variable declared
|
| 383 |
+
with a type that contains a placeholder type [[dcl.spec.auto]] where
|
| 384 |
+
the initializer is type-dependent,
|
| 385 |
- an *identifier* associated by name lookup with one or more
|
| 386 |
declarations of member functions of the current instantiation declared
|
| 387 |
with a return type that contains a placeholder type,
|
| 388 |
- an *identifier* associated by name lookup with a structured binding
|
| 389 |
+
declaration [[dcl.struct.bind]] whose *brace-or-equal-initializer* is
|
| 390 |
+
type-dependent,
|
| 391 |
+
- the *identifier* `__func__` [[dcl.fct.def.general]], where any
|
| 392 |
enclosing function is a template, a member of a class template, or a
|
| 393 |
generic lambda,
|
| 394 |
- a *template-id* that is dependent,
|
| 395 |
- a *conversion-function-id* that specifies a dependent type, or
|
| 396 |
- a *nested-name-specifier* or a *qualified-id* that names a member of
|
| 397 |
an unknown specialization;
|
| 398 |
|
| 399 |
or if it names a dependent member of the current instantiation that is a
|
| 400 |
+
static data member of type “array of unknown bound of `T`” for some `T`
|
| 401 |
+
[[temp.static]]. Expressions of the following forms are type-dependent
|
| 402 |
+
only if the type specified by the *type-id*, *simple-type-specifier* or
|
| 403 |
+
*new-type-id* is dependent, even if any subexpression is type-dependent:
|
| 404 |
+
|
| 405 |
+
``` bnf
|
| 406 |
+
simple-type-specifier '(' expression-listₒₚₜ ')'
|
| 407 |
+
'::'ₒₚₜ new new-placementₒₚₜ new-type-id new-initializerₒₚₜ
|
| 408 |
+
'::'ₒₚₜ new new-placementₒₚₜ '(' type-id ')' new-initializerₒₚₜ
|
| 409 |
+
dynamic_cast '<' type-id '>' '(' expression ')'
|
| 410 |
+
static_cast '<' type-id '>' '(' expression ')'
|
| 411 |
+
const_cast '<' type-id '>' '(' expression ')'
|
| 412 |
+
reinterpret_cast '<' type-id '>' '(' expression ')'
|
| 413 |
+
'(' type-id ')' cast-expression
|
| 414 |
+
```
|
| 415 |
|
| 416 |
Expressions of the following forms are never type-dependent (because the
|
| 417 |
type of the expression cannot be dependent):
|
| 418 |
|
| 419 |
+
``` bnf
|
| 420 |
+
literal
|
| 421 |
+
sizeof unary-expression
|
| 422 |
+
sizeof '(' type-id ')'
|
| 423 |
+
sizeof '...' '(' identifier ')'
|
| 424 |
+
alignof '(' type-id ')'
|
| 425 |
+
typeid '(' expression ')'
|
| 426 |
+
typeid '(' type-id ')'
|
| 427 |
+
'::'ₒₚₜ delete cast-expression
|
| 428 |
+
'::'ₒₚₜ delete '[' ']' cast-expression
|
| 429 |
+
throw assignment-expressionₒₚₜ
|
| 430 |
+
noexcept '(' expression ')'
|
| 431 |
+
```
|
| 432 |
+
|
| 433 |
[*Note 1*: For the standard library macro `offsetof`, see
|
| 434 |
[[support.types]]. — *end note*]
|
| 435 |
|
| 436 |
+
A class member access expression [[expr.ref]] is type-dependent if the
|
| 437 |
+
expression refers to a member of the current instantiation and the type
|
| 438 |
+
of the referenced member is dependent, or the class member access
|
| 439 |
expression refers to a member of an unknown specialization.
|
| 440 |
|
| 441 |
[*Note 2*: In an expression of the form `x.y` or `xp->y` the type of
|
| 442 |
the expression is usually the type of the member `y` of the class of `x`
|
| 443 |
(or the class pointed to by `xp`). However, if `x` or `xp` refers to a
|
|
|
|
| 457 |
constant expression is required is value-dependent if any subexpression
|
| 458 |
is value-dependent.
|
| 459 |
|
| 460 |
An *id-expression* is value-dependent if:
|
| 461 |
|
| 462 |
+
- it is a concept-id and any of its arguments are dependent,
|
| 463 |
- it is type-dependent,
|
| 464 |
- it is the name of a non-type template parameter,
|
| 465 |
- it names a static data member that is a dependent member of the
|
| 466 |
current instantiation and is not initialized in a *member-declarator*,
|
| 467 |
- it names a static member function that is a dependent member of the
|
| 468 |
current instantiation, or
|
| 469 |
+
- it names a potentially-constant variable [[expr.const]] that is
|
| 470 |
+
initialized with an expression that is value-dependent.
|
| 471 |
|
| 472 |
Expressions of the following form are value-dependent if the
|
| 473 |
*unary-expression* or *expression* is type-dependent or the *type-id* is
|
| 474 |
dependent:
|
| 475 |
|
| 476 |
+
``` bnf
|
| 477 |
+
sizeof unary-expression
|
| 478 |
+
sizeof '(' type-id ')'
|
| 479 |
+
typeid '(' expression ')'
|
| 480 |
+
typeid '(' type-id ')'
|
| 481 |
+
alignof '(' type-id ')'
|
| 482 |
+
noexcept '(' expression ')'
|
| 483 |
+
```
|
| 484 |
+
|
| 485 |
[*Note 1*: For the standard library macro `offsetof`, see
|
| 486 |
[[support.types]]. — *end note*]
|
| 487 |
|
| 488 |
Expressions of the following form are value-dependent if either the
|
| 489 |
*type-id* or *simple-type-specifier* is dependent or the *expression* or
|
| 490 |
*cast-expression* is value-dependent:
|
| 491 |
|
| 492 |
+
``` bnf
|
| 493 |
+
simple-type-specifier '(' expression-listₒₚₜ ')'
|
| 494 |
+
static_cast '<' type-id '>' '(' expression ')'
|
| 495 |
+
const_cast '<' type-id '>' '(' expression ')'
|
| 496 |
+
reinterpret_cast '<' type-id '>' '(' expression ')'
|
| 497 |
+
'(' type-id ')' cast-expression
|
| 498 |
+
```
|
| 499 |
+
|
| 500 |
Expressions of the following form are value-dependent:
|
| 501 |
|
| 502 |
+
``` bnf
|
| 503 |
+
sizeof '...' '(' identifier ')'
|
| 504 |
+
fold-expression
|
| 505 |
+
```
|
| 506 |
+
|
| 507 |
An expression of the form `&`*qualified-id* where the *qualified-id*
|
| 508 |
names a dependent member of the current instantiation is
|
| 509 |
value-dependent. An expression of the form `&`*cast-expression* is also
|
| 510 |
value-dependent if evaluating *cast-expression* as a core constant
|
| 511 |
+
expression [[expr.const]] succeeds and the result of the evaluation
|
| 512 |
refers to a templated entity that is an object with static or thread
|
| 513 |
storage duration or a member function.
|
| 514 |
|
| 515 |
#### Dependent template arguments <a id="temp.dep.temp">[[temp.dep.temp]]</a>
|
| 516 |
|