11 KiB
[temp.dep.expr]
13 Templates [temp]
13.8 Name resolution [temp.res]
13.8.3 Dependent names [temp.dep]
13.8.3.3 Type-dependent expressions [temp.dep.expr]
Except as described below, an expression is type-dependent if any subexpression is type-dependent.
this is type-dependent if the current class ([expr.prim.this]) is dependent ([temp.dep.type]).
An id-expression is type-dependent if it is a template-id that is not a concept-id and is dependent; or if its terminal name is
associated by name lookup with one or more declarations declared with a dependent type,
associated by name lookup with a constant template parameter declared with a type that contains a placeholder type ([dcl.spec.auto]),
associated by name lookup with a variable declared with a type that contains a placeholder type ([dcl.spec.auto]) where the initializer is type-dependent,
associated by name lookup with one or more declarations of member functions of a class that is the current instantiation declared with a return type that contains a placeholder type,
associated by name lookup with a structured binding declaration ([dcl.struct.bind]) whosebrace-or-equal-initializer is type-dependent,
associated by name lookup with a pack, [Example 1: struct C { };
void g(...); // #1template <typename T>void f() { C arr[1]; auto [...e] = arr;
g(e...); // calls #2}void g(C); // #2int main() { f();} â end example]
associated by name lookup with an entity captured by copy ([expr.prim.lambda.capture]) in a lambda-expression that has an explicit object parameter whose type is dependent ([dcl.fct]),
theidentifierfunc ([dcl.fct.def.general]), where any enclosing function is a template, a member of a class template, or a generic lambda,
associated by name lookup with a result binding ([dcl.contract.res]) of a function whose return type is dependent,
a conversion-function-id that specifies a dependent type,
a name N introduced by the for-range-declaration of an expansion statement S if the type specified for N contains a placeholder type and either
the expansion-initializer of S is type-dependent or
S is not an iterating expansion statement, or
dependent
or if it names a dependent member of the current instantiation that is a static data member of type âarray of unknown bound of Tâ for some T ([temp.static]).
Expressions of the following forms are type-dependent only if the type specified by thetype-id,simple-type-specifier,typename-specifier, ornew-type-id is dependent, even if any subexpression is type-dependent:
simple-type-specifier ( expression-listopt )
simple-type-specifier braced-init-list
typename-specifier ( expression-listopt )
typename-specifier braced-init-list
::opt new new-placementopt new-type-id new-initializeropt
::opt new new-placementopt ( type-id ) new-initializeropt
dynamic_cast < type-id > ( expression )
static_cast < type-id > ( expression )
const_cast < type-id > ( expression )
reinterpret_cast < type-id > ( expression )
( type-id ) cast-expression
Expressions of the following forms are never type-dependent (because the type of the expression cannot be dependent):
literal
sizeof unary-expression
sizeof ( type-id )
sizeof ... ( identifier )
alignof ( type-id )
typeid ( expression )
typeid ( type-id )
::opt delete cast-expression
::opt delete [ ] cast-expression
throw assignment-expressionopt
noexcept ( expression )
requires-expression
reflect-expression
[Note 1:
For the standard library macro offsetof, see [support.types].
â end note]
A class member access expression is type-dependent if the terminal name of its id-expression, if any, is dependent or the expression refers to a member of the current instantiation and the type of the referenced member is dependent.
[Note 2:
In an expression of the formx.y orxp->y the type of the expression is usually the type of the membery of the class ofx (or the class pointed to byxp).
However, ifx orxp refers to a dependent type that is not the current instantiation, the type ofy is always dependent.
â end note]
A braced-init-list is type-dependent if any element is type-dependent or is a pack expansion.
A fold-expression is type-dependent.
A pack-index-expression is type-dependent if its id-expression is type-dependent.
A splice-expression is type-dependent if its splice-specifier orsplice-specialization-specifier is dependent ([temp.dep.splice]).