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

9.7 KiB

[temp.dep.constexpr]

13 Templates [temp]

13.8 Name resolution [temp.res]

13.8.3 Dependent names [temp.dep]

13.8.3.4 Value-dependent expressions [temp.dep.constexpr]

1

#

Except as described below, an expression used in a context where a constant expression is required is value-dependent if any subexpression is value-dependent.

2

#

Anid-expression is value-dependent if

it is a concept-id and its concept-name is dependent or any of its arguments are dependent ([temp.dep.temp]),

it is type-dependent,

it is the name of a constant template parameter,

it is a name introduced by the for-range-declaration of an expansion statement ([stmt.expand]),

it names a static data member that is a dependent member of the current instantiation and is not initialized in a member-declarator,

it names a static member function that is a dependent member of the current instantiation, or

it names a potentially-constant variable ([expr.const]) that is initialized with an expression that is value-dependent.

Expressions of the following form are value-dependent if theunary-expression or expression is type-dependent or thetype-id is dependent:

sizeof unary-expression
sizeof ( type-id )
typeid ( expression )
typeid ( type-id )
alignof ( type-id )

[Note 1:

For the standard library macro offsetof, see [support.types].

— end note]

3

#

Expressions of the following form are value-dependent if either thetype-id,simple-type-specifier, ortypename-specifier is dependent or theexpression orcast-expression is value-dependent or any expression in the expression-list is value-dependent or any assignment-expression in the braced-init-list is value-dependent:

simple-type-specifier ( expression-listopt )
typename-specifier ( expression-listopt )
simple-type-specifier braced-init-list
typename-specifier braced-init-list
static_cast < type-id > ( expression )
const_cast < type-id > ( expression )
reinterpret_cast < type-id > ( expression )
dynamic_cast < type-id > ( expression )
( type-id ) cast-expression

4

#

Expressions of the following form are value-dependent:

sizeof ... ( identifier )
fold-expression

unless the identifier is a structured binding pack whose initializer is not dependent.

5

#

A noexcept-expression ([expr.unary.noexcept]) is value-dependent if its expression involves a template parameter.

6

#

An expression of the form &qualified-id where thequalified-id names a dependent member of the current instantiation is value-dependent.

An expression of the form &cast-expression is also value-dependent if evaluating cast-expression as a core constant expression succeeds and the result of the evaluation refers to a templated entity that is an object with static or thread storage duration or a member function.

7

#

A reflect-expression is value-dependent if

it is of the form ^^reflection-name and the reflection-name

is a dependent qualified name,

is a dependent namespace-name,

is the name of a template parameter, or

names a dependent member of the current instantiation ([temp.dep.type]),

it is of the form ^^type-id and the type-id denotes a dependent type, or

it is of the form ^^id-expression and the id-expression is value-dependent.

8

#

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