4.7 KiB
[temp.dep.general]
13 Templates [temp]
13.8 Name resolution [temp.res]
13.8.3 Dependent names [temp.dep]
13.8.3.1 General [temp.dep.general]
Inside a template, some constructs have semantics which may differ from one instantiation to another.
Such a constructdepends on the template parameters.
In particular, types and expressions may depend on the type and/or value of template parameters (as determined by the template arguments) and this determines the context for name lookup for certain names.
An expression may betype-dependent (that is, its type may depend on a template parameter) orvalue-dependent (that is, its value when evaluated as a constant expression ([expr.const]) may depend on a template parameter) as described below.
A dependent call is an expression, possibly formed as a non-member candidate for an operator ([over.match.oper]), of the form:
postfix-expression ( expression-listopt )
where the postfix-expression is an unqualified-id and
any of the expressions in the expression-list is a pack expansion ([temp.variadic]), or
any of the expressions or braced-init-lists in theexpression-list is type-dependent, or
the unqualified-id is a template-id in which any of the template arguments depends on a template parameter.
The component name of an unqualified-id ([expr.prim.id.unqual]) is dependent if
it is a conversion-function-id whose conversion-type-id is dependent, or
it is operator= and the current class is a templated entity, or
the unqualified-id is the postfix-expression in a dependent call.
[Note 1:
Such names are looked up only at the point of the template instantiation ([temp.point]) in both the context of the template definition and the context of the point of instantiation ([temp.dep.candidate]).
â end note]
[Example 1: template struct X : B {typename T::A* pa; void f(B* pb) {static int i = B::i; pb->j++; }};
The base class nameB, the type nameT::A, the namesB::i andpb->j explicitly depend on thetemplate-parameter.
â end example]