Files
2025-10-25 03:02:53 +03:00

11 KiB
Raw Permalink Blame History

[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]

1

#

Except as described below, an expression is type-dependent if any subexpression is type-dependent.

2

#

this is type-dependent if the current class ([expr.prim.this]) is dependent ([temp.dep.type]).

3

#

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

4

#

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]

5

#

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]

6

#

A braced-init-list is type-dependent if any element is type-dependent or is a pack expansion.

7

#

A fold-expression is type-dependent.

8

#

A pack-index-expression is type-dependent if its id-expression is type-dependent.

9

#

A splice-expression is type-dependent if its splice-specifier orsplice-specialization-specifier is dependent ([temp.dep.splice]).