- tmp/tmph62jjm74/{from.md → to.md} +206 -29
tmp/tmph62jjm74/{from.md → to.md}
RENAMED
|
@@ -70,25 +70,25 @@ A name or *template-id* refers to the *current instantiation* if it is
|
|
| 70 |
class template, the name of the class template followed by the
|
| 71 |
template argument list of its *template-head* [[temp.arg]] enclosed in
|
| 72 |
`<>` (or an equivalent template alias specialization),
|
| 73 |
- in the definition of a nested class of a class template, the name of
|
| 74 |
the nested class referenced as a member of the current instantiation,
|
| 75 |
-
or
|
| 76 |
- in the definition of a class template partial specialization or a
|
| 77 |
member of a class template partial specialization, the name of the
|
| 78 |
class template followed by a template argument list equivalent to that
|
| 79 |
of the partial specialization [[temp.spec.partial]] enclosed in `<>`
|
| 80 |
-
(or an equivalent template alias specialization)
|
|
|
|
|
|
|
| 81 |
|
| 82 |
A template argument that is equivalent to a template parameter can be
|
| 83 |
used in place of that template parameter in a reference to the current
|
| 84 |
-
instantiation.
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
template parameter if
|
| 90 |
|
| 91 |
- it has the same type as the template parameter (ignoring
|
| 92 |
cv-qualification) and
|
| 93 |
- its initializer consists of a single *identifier* that names the
|
| 94 |
template parameter or, recursively, such a variable.
|
|
@@ -200,11 +200,11 @@ A qualified name [[basic.lookup.qual]] is dependent if
|
|
| 200 |
- it is a *conversion-function-id* whose *conversion-type-id* is
|
| 201 |
dependent, or
|
| 202 |
- its lookup context is dependent and is not the current instantiation,
|
| 203 |
or
|
| 204 |
- its lookup context is the current instantiation and it is
|
| 205 |
-
`operator=`,[^
|
| 206 |
- its lookup context is the current instantiation and has at least one
|
| 207 |
dependent base class, and qualified name lookup for the name finds
|
| 208 |
nothing [[basic.lookup.qual]].
|
| 209 |
|
| 210 |
[*Example 4*:
|
|
@@ -248,11 +248,44 @@ struct C : A, T {
|
|
| 248 |
int g() { return m; } // finds A::m in the template definition context
|
| 249 |
};
|
| 250 |
|
| 251 |
template int C<B>::f(); // error: finds both A::m and B::m
|
| 252 |
template int C<B>::g(); // OK, transformation to class member access syntax
|
| 253 |
-
// does not occur in the template definition context; see~[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 254 |
```
|
| 255 |
|
| 256 |
— *end example*]
|
| 257 |
|
| 258 |
A type is dependent if it is
|
|
@@ -266,16 +299,21 @@ A type is dependent if it is
|
|
| 266 |
- an array type whose element type is dependent or whose bound (if any)
|
| 267 |
is value-dependent,
|
| 268 |
- a function type whose parameters include one or more function
|
| 269 |
parameter packs,
|
| 270 |
- a function type whose exception specification is value-dependent,
|
|
|
|
|
|
|
| 271 |
- denoted by a *simple-template-id* in which either the template name is
|
| 272 |
-
a template parameter or any of the template arguments is
|
| 273 |
-
|
| 274 |
-
|
| 275 |
- denoted by `decltype(`*expression*`)`, where *expression* is
|
| 276 |
-
type-dependent [[temp.dep.expr]]
|
|
|
|
|
|
|
|
|
|
| 277 |
|
| 278 |
[*Note 3*: Because typedefs do not introduce new types, but instead
|
| 279 |
simply refer to other types, a name that refers to a typedef that is a
|
| 280 |
member of the current instantiation is dependent only if the type
|
| 281 |
referred to is dependent. — *end note*]
|
|
@@ -291,29 +329,57 @@ dependent [[temp.dep.type]].
|
|
| 291 |
An *id-expression* is type-dependent if it is a *template-id* that is
|
| 292 |
not a concept-id and is dependent; or if its terminal name is
|
| 293 |
|
| 294 |
- associated by name lookup with one or more declarations declared with
|
| 295 |
a dependent type,
|
| 296 |
-
- associated by name lookup with a
|
| 297 |
-
|
| 298 |
-
[[dcl.spec.auto]],
|
| 299 |
- associated by name lookup with a variable declared with a type that
|
| 300 |
contains a placeholder type [[dcl.spec.auto]] where the initializer is
|
| 301 |
type-dependent,
|
| 302 |
- associated by name lookup with one or more declarations of member
|
| 303 |
functions of a class that is the current instantiation declared with a
|
| 304 |
return type that contains a placeholder type,
|
| 305 |
- associated by name lookup with a structured binding declaration
|
| 306 |
[[dcl.struct.bind]] whose *brace-or-equal-initializer* is
|
| 307 |
type-dependent,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 308 |
- associated by name lookup with an entity captured by copy
|
| 309 |
[[expr.prim.lambda.capture]] in a *lambda-expression* that has an
|
| 310 |
explicit object parameter whose type is dependent [[dcl.fct]],
|
| 311 |
- the *identifier* `__func__` [[dcl.fct.def.general]], where any
|
| 312 |
enclosing function is a template, a member of a class template, or a
|
| 313 |
generic lambda,
|
| 314 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 315 |
- dependent
|
| 316 |
|
| 317 |
or if it names a dependent member of the current instantiation that is a
|
| 318 |
static data member of type “array of unknown bound of `T`” for some `T`
|
| 319 |
[[temp.static]]. Expressions of the following forms are type-dependent
|
|
@@ -348,10 +414,12 @@ typeid '(' expression ')'
|
|
| 348 |
typeid '(' type-id ')'
|
| 349 |
'::'ₒₚₜ delete cast-expression
|
| 350 |
'::'ₒₚₜ delete '[' ']' cast-expression
|
| 351 |
throw assignment-expressionₒₚₜ
|
| 352 |
noexcept '(' expression ')'
|
|
|
|
|
|
|
| 353 |
```
|
| 354 |
|
| 355 |
[*Note 1*: For the standard library macro `offsetof`, see
|
| 356 |
[[support.types]]. — *end note*]
|
| 357 |
|
|
@@ -369,21 +437,30 @@ always dependent. — *end note*]
|
|
| 369 |
A *braced-init-list* is type-dependent if any element is type-dependent
|
| 370 |
or is a pack expansion.
|
| 371 |
|
| 372 |
A *fold-expression* is type-dependent.
|
| 373 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 374 |
#### Value-dependent expressions <a id="temp.dep.constexpr">[[temp.dep.constexpr]]</a>
|
| 375 |
|
| 376 |
Except as described below, an expression used in a context where a
|
| 377 |
constant expression is required is value-dependent if any subexpression
|
| 378 |
is value-dependent.
|
| 379 |
|
| 380 |
-
An *id-expression* is value-dependent if
|
| 381 |
|
| 382 |
-
- it is a concept-id and
|
|
|
|
| 383 |
- it is type-dependent,
|
| 384 |
-
- it is the name of a
|
|
|
|
|
|
|
| 385 |
- it names a static data member that is a dependent member of the
|
| 386 |
current instantiation and is not initialized in a *member-declarator*,
|
| 387 |
- it names a static member function that is a dependent member of the
|
| 388 |
current instantiation, or
|
| 389 |
- it names a potentially-constant variable [[expr.const]] that is
|
|
@@ -397,54 +474,154 @@ dependent:
|
|
| 397 |
sizeof unary-expression
|
| 398 |
sizeof '(' type-id ')'
|
| 399 |
typeid '(' expression ')'
|
| 400 |
typeid '(' type-id ')'
|
| 401 |
alignof '(' type-id ')'
|
| 402 |
-
noexcept '(' expression ')'
|
| 403 |
```
|
| 404 |
|
| 405 |
[*Note 1*: For the standard library macro `offsetof`, see
|
| 406 |
[[support.types]]. — *end note*]
|
| 407 |
|
| 408 |
Expressions of the following form are value-dependent if either the
|
| 409 |
-
*type-id*
|
| 410 |
-
*cast-expression* is value-dependent
|
|
|
|
|
|
|
| 411 |
|
| 412 |
``` bnf
|
| 413 |
simple-type-specifier '(' expression-listₒₚₜ ')'
|
|
|
|
|
|
|
|
|
|
| 414 |
static_cast '<' type-id '>' '(' expression ')'
|
| 415 |
const_cast '<' type-id '>' '(' expression ')'
|
| 416 |
reinterpret_cast '<' type-id '>' '(' expression ')'
|
|
|
|
| 417 |
'(' type-id ')' cast-expression
|
| 418 |
```
|
| 419 |
|
| 420 |
Expressions of the following form are value-dependent:
|
| 421 |
|
| 422 |
``` bnf
|
| 423 |
sizeof '...' '(' identifier ')'
|
| 424 |
fold-expression
|
| 425 |
```
|
| 426 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 427 |
An expression of the form `&`*qualified-id* where the *qualified-id*
|
| 428 |
names a dependent member of the current instantiation is
|
| 429 |
value-dependent. An expression of the form `&`*cast-expression* is also
|
| 430 |
value-dependent if evaluating *cast-expression* as a core constant
|
| 431 |
expression [[expr.const]] succeeds and the result of the evaluation
|
| 432 |
refers to a templated entity that is an object with static or thread
|
| 433 |
storage duration or a member function.
|
| 434 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 435 |
#### Dependent template arguments <a id="temp.dep.temp">[[temp.dep.temp]]</a>
|
| 436 |
|
| 437 |
A type *template-argument* is dependent if the type it specifies is
|
| 438 |
dependent.
|
| 439 |
|
| 440 |
-
A
|
| 441 |
the constant expression it specifies is value-dependent.
|
| 442 |
|
| 443 |
-
Furthermore, a
|
| 444 |
-
corresponding
|
| 445 |
type and the *template-argument* designates or points to a member of the
|
| 446 |
current instantiation or a member of a dependent type.
|
| 447 |
|
| 448 |
-
A template
|
| 449 |
-
|
|
|
|
|
|
|
| 450 |
|
|
|
|
| 70 |
class template, the name of the class template followed by the
|
| 71 |
template argument list of its *template-head* [[temp.arg]] enclosed in
|
| 72 |
`<>` (or an equivalent template alias specialization),
|
| 73 |
- in the definition of a nested class of a class template, the name of
|
| 74 |
the nested class referenced as a member of the current instantiation,
|
|
|
|
| 75 |
- in the definition of a class template partial specialization or a
|
| 76 |
member of a class template partial specialization, the name of the
|
| 77 |
class template followed by a template argument list equivalent to that
|
| 78 |
of the partial specialization [[temp.spec.partial]] enclosed in `<>`
|
| 79 |
+
(or an equivalent template alias specialization), or
|
| 80 |
+
- in the definition of a templated function, the name of a local class
|
| 81 |
+
[[class.local]].
|
| 82 |
|
| 83 |
A template argument that is equivalent to a template parameter can be
|
| 84 |
used in place of that template parameter in a reference to the current
|
| 85 |
+
instantiation. A template argument is equivalent to a type template
|
| 86 |
+
parameter if it denotes the same type. A template argument is equivalent
|
| 87 |
+
to a constant template parameter if it is an *identifier* that names a
|
| 88 |
+
variable that is equivalent to the template parameter. A variable is
|
| 89 |
+
equivalent to a template parameter if
|
|
|
|
| 90 |
|
| 91 |
- it has the same type as the template parameter (ignoring
|
| 92 |
cv-qualification) and
|
| 93 |
- its initializer consists of a single *identifier* that names the
|
| 94 |
template parameter or, recursively, such a variable.
|
|
|
|
| 200 |
- it is a *conversion-function-id* whose *conversion-type-id* is
|
| 201 |
dependent, or
|
| 202 |
- its lookup context is dependent and is not the current instantiation,
|
| 203 |
or
|
| 204 |
- its lookup context is the current instantiation and it is
|
| 205 |
+
`operator=`,[^10] or
|
| 206 |
- its lookup context is the current instantiation and has at least one
|
| 207 |
dependent base class, and qualified name lookup for the name finds
|
| 208 |
nothing [[basic.lookup.qual]].
|
| 209 |
|
| 210 |
[*Example 4*:
|
|
|
|
| 248 |
int g() { return m; } // finds A::m in the template definition context
|
| 249 |
};
|
| 250 |
|
| 251 |
template int C<B>::f(); // error: finds both A::m and B::m
|
| 252 |
template int C<B>::g(); // OK, transformation to class member access syntax
|
| 253 |
+
// does not occur in the template definition context; see~[expr.prim.id.general]
|
| 254 |
+
```
|
| 255 |
+
|
| 256 |
+
— *end example*]
|
| 257 |
+
|
| 258 |
+
An initializer is dependent if any constituent expression
|
| 259 |
+
[[intro.execution]] of the initializer is type-dependent. A placeholder
|
| 260 |
+
type [[dcl.spec.auto.general]] is dependent if it designates a type
|
| 261 |
+
deduced from a dependent initializer.
|
| 262 |
+
|
| 263 |
+
A placeholder for a deduced class type [[dcl.type.class.deduct]] is
|
| 264 |
+
dependent if
|
| 265 |
+
|
| 266 |
+
- it has a dependent initializer, or
|
| 267 |
+
- it refers to an alias template that is a member of the current
|
| 268 |
+
instantiation and whose *defining-type-id* is dependent after class
|
| 269 |
+
template argument deduction [[over.match.class.deduct]] and
|
| 270 |
+
substitution [[temp.alias]].
|
| 271 |
+
|
| 272 |
+
[*Example 6*:
|
| 273 |
+
|
| 274 |
+
``` cpp
|
| 275 |
+
template<class T, class V>
|
| 276 |
+
struct S { S(T); };
|
| 277 |
+
|
| 278 |
+
template<class U>
|
| 279 |
+
struct A {
|
| 280 |
+
template<class T> using X = S<T, U>;
|
| 281 |
+
template<class T> using Y = S<T, int>;
|
| 282 |
+
void f() {
|
| 283 |
+
new X(1); // dependent
|
| 284 |
+
new Y(1); // not dependent
|
| 285 |
+
}
|
| 286 |
+
};
|
| 287 |
```
|
| 288 |
|
| 289 |
— *end example*]
|
| 290 |
|
| 291 |
A type is dependent if it is
|
|
|
|
| 299 |
- an array type whose element type is dependent or whose bound (if any)
|
| 300 |
is value-dependent,
|
| 301 |
- a function type whose parameters include one or more function
|
| 302 |
parameter packs,
|
| 303 |
- a function type whose exception specification is value-dependent,
|
| 304 |
+
- denoted by a dependent placeholder type,
|
| 305 |
+
- denoted by a dependent placeholder for a deduced class type,
|
| 306 |
- denoted by a *simple-template-id* in which either the template name is
|
| 307 |
+
a template parameter or any of the template arguments is dependent
|
| 308 |
+
[[temp.dep.temp]],[^11]
|
| 309 |
+
- a *pack-index-specifier*,
|
| 310 |
- denoted by `decltype(`*expression*`)`, where *expression* is
|
| 311 |
+
type-dependent [[temp.dep.expr]], or
|
| 312 |
+
- denoted by a *splice-type-specifier* in which either the
|
| 313 |
+
*splice-specifier* or *splice-specialization-specifier* is dependent
|
| 314 |
+
[[temp.dep.splice]].
|
| 315 |
|
| 316 |
[*Note 3*: Because typedefs do not introduce new types, but instead
|
| 317 |
simply refer to other types, a name that refers to a typedef that is a
|
| 318 |
member of the current instantiation is dependent only if the type
|
| 319 |
referred to is dependent. — *end note*]
|
|
|
|
| 329 |
An *id-expression* is type-dependent if it is a *template-id* that is
|
| 330 |
not a concept-id and is dependent; or if its terminal name is
|
| 331 |
|
| 332 |
- associated by name lookup with one or more declarations declared with
|
| 333 |
a dependent type,
|
| 334 |
+
- associated by name lookup with a constant template parameter declared
|
| 335 |
+
with a type that contains a placeholder type [[dcl.spec.auto]],
|
|
|
|
| 336 |
- associated by name lookup with a variable declared with a type that
|
| 337 |
contains a placeholder type [[dcl.spec.auto]] where the initializer is
|
| 338 |
type-dependent,
|
| 339 |
- associated by name lookup with one or more declarations of member
|
| 340 |
functions of a class that is the current instantiation declared with a
|
| 341 |
return type that contains a placeholder type,
|
| 342 |
- associated by name lookup with a structured binding declaration
|
| 343 |
[[dcl.struct.bind]] whose *brace-or-equal-initializer* is
|
| 344 |
type-dependent,
|
| 345 |
+
- associated by name lookup with a pack,
|
| 346 |
+
\[*Example 1*:
|
| 347 |
+
``` cpp
|
| 348 |
+
struct C { };
|
| 349 |
+
|
| 350 |
+
void g(...); // #1
|
| 351 |
+
|
| 352 |
+
template <typename T>
|
| 353 |
+
void f() {
|
| 354 |
+
C arr[1];
|
| 355 |
+
auto [...e] = arr;
|
| 356 |
+
g(e...); // calls #2
|
| 357 |
+
}
|
| 358 |
+
|
| 359 |
+
void g(C); // #2
|
| 360 |
+
|
| 361 |
+
int main() {
|
| 362 |
+
f<int>();
|
| 363 |
+
}
|
| 364 |
+
```
|
| 365 |
+
|
| 366 |
+
— *end example*]
|
| 367 |
- associated by name lookup with an entity captured by copy
|
| 368 |
[[expr.prim.lambda.capture]] in a *lambda-expression* that has an
|
| 369 |
explicit object parameter whose type is dependent [[dcl.fct]],
|
| 370 |
- the *identifier* `__func__` [[dcl.fct.def.general]], where any
|
| 371 |
enclosing function is a template, a member of a class template, or a
|
| 372 |
generic lambda,
|
| 373 |
+
- associated by name lookup with a result binding [[dcl.contract.res]]
|
| 374 |
+
of a function whose return type is dependent,
|
| 375 |
+
- a *conversion-function-id* that specifies a dependent type,
|
| 376 |
+
- a name N introduced by the *for-range-declaration* of an
|
| 377 |
+
*expansion-statement* S if the type specified for N contains a
|
| 378 |
+
placeholder type and either
|
| 379 |
+
- the *expansion-initializer* of S is type-dependent or
|
| 380 |
+
- S is not an iterating expansion statement, or
|
| 381 |
- dependent
|
| 382 |
|
| 383 |
or if it names a dependent member of the current instantiation that is a
|
| 384 |
static data member of type “array of unknown bound of `T`” for some `T`
|
| 385 |
[[temp.static]]. Expressions of the following forms are type-dependent
|
|
|
|
| 414 |
typeid '(' type-id ')'
|
| 415 |
'::'ₒₚₜ delete cast-expression
|
| 416 |
'::'ₒₚₜ delete '[' ']' cast-expression
|
| 417 |
throw assignment-expressionₒₚₜ
|
| 418 |
noexcept '(' expression ')'
|
| 419 |
+
requires-expression
|
| 420 |
+
reflect-expression
|
| 421 |
```
|
| 422 |
|
| 423 |
[*Note 1*: For the standard library macro `offsetof`, see
|
| 424 |
[[support.types]]. — *end note*]
|
| 425 |
|
|
|
|
| 437 |
A *braced-init-list* is type-dependent if any element is type-dependent
|
| 438 |
or is a pack expansion.
|
| 439 |
|
| 440 |
A *fold-expression* is type-dependent.
|
| 441 |
|
| 442 |
+
A *pack-index-expression* is type-dependent if its *id-expression* is
|
| 443 |
+
type-dependent.
|
| 444 |
+
|
| 445 |
+
A *splice-expression* is type-dependent if its *splice-specifier* or
|
| 446 |
+
*splice-specialization-specifier* is dependent [[temp.dep.splice]].
|
| 447 |
+
|
| 448 |
#### Value-dependent expressions <a id="temp.dep.constexpr">[[temp.dep.constexpr]]</a>
|
| 449 |
|
| 450 |
Except as described below, an expression used in a context where a
|
| 451 |
constant expression is required is value-dependent if any subexpression
|
| 452 |
is value-dependent.
|
| 453 |
|
| 454 |
+
An *id-expression* is value-dependent if
|
| 455 |
|
| 456 |
+
- it is a concept-id and its *concept-name* is dependent or any of its
|
| 457 |
+
arguments are dependent [[temp.dep.temp]],
|
| 458 |
- it is type-dependent,
|
| 459 |
+
- it is the name of a constant template parameter,
|
| 460 |
+
- it is a name introduced by the *for-range-declaration* of an
|
| 461 |
+
*expansion-statement* [[stmt.expand]],
|
| 462 |
- it names a static data member that is a dependent member of the
|
| 463 |
current instantiation and is not initialized in a *member-declarator*,
|
| 464 |
- it names a static member function that is a dependent member of the
|
| 465 |
current instantiation, or
|
| 466 |
- it names a potentially-constant variable [[expr.const]] that is
|
|
|
|
| 474 |
sizeof unary-expression
|
| 475 |
sizeof '(' type-id ')'
|
| 476 |
typeid '(' expression ')'
|
| 477 |
typeid '(' type-id ')'
|
| 478 |
alignof '(' type-id ')'
|
|
|
|
| 479 |
```
|
| 480 |
|
| 481 |
[*Note 1*: For the standard library macro `offsetof`, see
|
| 482 |
[[support.types]]. — *end note*]
|
| 483 |
|
| 484 |
Expressions of the following form are value-dependent if either the
|
| 485 |
+
*type-id*, *simple-type-specifier*, or *typename-specifier* is dependent
|
| 486 |
+
or the *expression* or *cast-expression* is value-dependent or any
|
| 487 |
+
*expression* in the *expression-list* is value-dependent or any
|
| 488 |
+
*assignment-expression* in the *braced-init-list* is value-dependent:
|
| 489 |
|
| 490 |
``` bnf
|
| 491 |
simple-type-specifier '(' expression-listₒₚₜ ')'
|
| 492 |
+
typename-specifier '(' expression-listₒₚₜ ')'
|
| 493 |
+
simple-type-specifier braced-init-list
|
| 494 |
+
typename-specifier braced-init-list
|
| 495 |
static_cast '<' type-id '>' '(' expression ')'
|
| 496 |
const_cast '<' type-id '>' '(' expression ')'
|
| 497 |
reinterpret_cast '<' type-id '>' '(' expression ')'
|
| 498 |
+
dynamic_cast '<' type-id '>' '(' expression ')'
|
| 499 |
'(' type-id ')' cast-expression
|
| 500 |
```
|
| 501 |
|
| 502 |
Expressions of the following form are value-dependent:
|
| 503 |
|
| 504 |
``` bnf
|
| 505 |
sizeof '...' '(' identifier ')'
|
| 506 |
fold-expression
|
| 507 |
```
|
| 508 |
|
| 509 |
+
unless the *identifier* is a structured binding pack whose initializer
|
| 510 |
+
is not dependent.
|
| 511 |
+
|
| 512 |
+
A *noexcept-expression* [[expr.unary.noexcept]] is value-dependent if
|
| 513 |
+
its *expression* involves a template parameter.
|
| 514 |
+
|
| 515 |
An expression of the form `&`*qualified-id* where the *qualified-id*
|
| 516 |
names a dependent member of the current instantiation is
|
| 517 |
value-dependent. An expression of the form `&`*cast-expression* is also
|
| 518 |
value-dependent if evaluating *cast-expression* as a core constant
|
| 519 |
expression [[expr.const]] succeeds and the result of the evaluation
|
| 520 |
refers to a templated entity that is an object with static or thread
|
| 521 |
storage duration or a member function.
|
| 522 |
|
| 523 |
+
A *reflect-expression* is value-dependent if
|
| 524 |
+
|
| 525 |
+
- it is of the form `^^ reflection-name` and the *reflection-name*
|
| 526 |
+
- is a dependent qualified name,
|
| 527 |
+
- is a dependent *namespace-name*,
|
| 528 |
+
- is the name of a template parameter, or
|
| 529 |
+
- names a dependent member of the current instantiation
|
| 530 |
+
[[temp.dep.type]],
|
| 531 |
+
- it is of the form `^^ type-id` and the *type-id* denotes a dependent
|
| 532 |
+
type, or
|
| 533 |
+
- it is of the form `^^ id-expression` and the *id-expression* is
|
| 534 |
+
value-dependent.
|
| 535 |
+
|
| 536 |
+
A *splice-expression* is value-dependent if its *splice-specifier* or
|
| 537 |
+
*splice-specialization-specifier* is dependent [[temp.dep.splice]].
|
| 538 |
+
|
| 539 |
+
#### Dependent splice specifiers <a id="temp.dep.splice">[[temp.dep.splice]]</a>
|
| 540 |
+
|
| 541 |
+
A *splice-specifier* is dependent if its converted *constant-expression*
|
| 542 |
+
is value-dependent. A *splice-specialization-specifier* is dependent if
|
| 543 |
+
its *splice-specifier* is dependent or if any of its template arguments
|
| 544 |
+
are dependent. A *splice-scope-specifier* is dependent if its
|
| 545 |
+
*splice-specifier* or *splice-specialization-specifier* is dependent.
|
| 546 |
+
|
| 547 |
+
[*Example 1*:
|
| 548 |
+
|
| 549 |
+
``` cpp
|
| 550 |
+
template<auto T, auto NS>
|
| 551 |
+
void fn() {
|
| 552 |
+
using a = [:T:]<1>; // [:T:]<1> is dependent because [:T:] is dependent
|
| 553 |
+
static_assert([:NS:]::template TCls<1>::v == a::v); // [:NS:] is dependent
|
| 554 |
+
}
|
| 555 |
+
|
| 556 |
+
namespace N {
|
| 557 |
+
template <auto V> struct TCls { static constexpr int v = V; };
|
| 558 |
+
}
|
| 559 |
+
|
| 560 |
+
int main() {
|
| 561 |
+
fn<^^N::TCls, ^^N>();
|
| 562 |
+
}
|
| 563 |
+
```
|
| 564 |
+
|
| 565 |
+
— *end example*]
|
| 566 |
+
|
| 567 |
+
[*Example 2*:
|
| 568 |
+
|
| 569 |
+
``` cpp
|
| 570 |
+
template<template<class> class X>
|
| 571 |
+
struct S {
|
| 572 |
+
[:^^X:]<int, float> m;
|
| 573 |
+
};
|
| 574 |
+
|
| 575 |
+
template<class> struct V1 {};
|
| 576 |
+
template<class, class = int> struct V2 {};
|
| 577 |
+
|
| 578 |
+
S<V1> s1; // error: V1<int, float> has too many template arguments
|
| 579 |
+
S<V2> s2; // OK
|
| 580 |
+
```
|
| 581 |
+
|
| 582 |
+
— *end example*]
|
| 583 |
+
|
| 584 |
+
#### Dependent namespaces <a id="temp.dep.namespace">[[temp.dep.namespace]]</a>
|
| 585 |
+
|
| 586 |
+
A namespace alias is dependent if it is introduced by a
|
| 587 |
+
*namespace-alias-definition* whose *qualified-namespace-specifier* (if
|
| 588 |
+
any) is a dependent qualified name or whose *splice-specifier* (if any)
|
| 589 |
+
is dependent. A *namespace-name* is dependent if it names a dependent
|
| 590 |
+
namespace alias.
|
| 591 |
+
|
| 592 |
+
[*Example 1*:
|
| 593 |
+
|
| 594 |
+
``` cpp
|
| 595 |
+
template<std::meta::info R>
|
| 596 |
+
int fn() {
|
| 597 |
+
namespace Alias = [:R:]; // [:R:] is dependent
|
| 598 |
+
return typename Alias::T{}; // Alias is dependent
|
| 599 |
+
}
|
| 600 |
+
|
| 601 |
+
namespace NS {
|
| 602 |
+
using T = int;
|
| 603 |
+
}
|
| 604 |
+
|
| 605 |
+
int a = fn<^^NS>();
|
| 606 |
+
```
|
| 607 |
+
|
| 608 |
+
— *end example*]
|
| 609 |
+
|
| 610 |
#### Dependent template arguments <a id="temp.dep.temp">[[temp.dep.temp]]</a>
|
| 611 |
|
| 612 |
A type *template-argument* is dependent if the type it specifies is
|
| 613 |
dependent.
|
| 614 |
|
| 615 |
+
A constant *template-argument* is dependent if its type is dependent or
|
| 616 |
the constant expression it specifies is value-dependent.
|
| 617 |
|
| 618 |
+
Furthermore, a constant *template-argument* is dependent if the
|
| 619 |
+
corresponding constant template parameter is of reference or pointer
|
| 620 |
type and the *template-argument* designates or points to a member of the
|
| 621 |
current instantiation or a member of a dependent type.
|
| 622 |
|
| 623 |
+
A template argument is also dependent if it is a pack expansion.
|
| 624 |
+
|
| 625 |
+
A template template parameter is dependent if it names a template
|
| 626 |
+
parameter or its terminal name is dependent.
|
| 627 |
|