tags:

views:

72

answers:

1

This is the statement from ISO C++ Standard 14.6.4.1 Point of instantiation

 4.If a virtual function is implicitly instantiated, its point of instantiation
   is immediately following the point of instantiation of its enclosing
   class template specialization.

 5.An explicit instantiation directive is an instantiation point for the
   specialization or specializations specified by the explicit 
   instantiation directive.

 6.The instantiation context of an expression that depends on the
   template arguments is the set of declarations with external linkage 
   declared prior to the point of instantiation of the template 
   specialization in the same translation unit.

Hi all, I am unable to write a programs for this whole section. I am trying to write a programs for this section from yesterday.

Can any one provide me a code for this sections to understand.

Please, normally ..I tried to ask a 1 or more points. In any section. But here iam unable to understand a single point in this section.

So, kindly can any one provide me a code(programs) for this sections to understand.

+2  A: 

The first two statements explain where the instantiation point of certain template constructs are; it doesn't introduce new template constructs. So you can reuse your previous examples.

The third statement (14.6.4.1/6) tells us what the point of instantiation points is: they are the point where names are looked up during the second phase of name lookup. Names that are declared before the instantiation point are visible; those declared afterwards are not. (In the first phase of two-phase name lookup, non-dependent names are looked up in the set of declarations that precede the template definition).

So, given:

template <typename T> void foo() {
  T() + T();
}

the instantiation contexts of the expression T()+T() is the set of declarations that precede the respective instantiation points of foo<T>. The name operator+ is looked up in those contexts, and includes declarations that follow this definition but precede the instantiation point.

MSalters
There is a difference between "point of instantiation" and "instantiation context". The former is just a location within a translation unit. But the latter is a state/condition. "context" is always a state, and "point of" is always a location. For example "point of definition" specifies the location in a template definition (not necessarily at the time the template was defined - c.f. 14.6.4/1bullet1), "point of declaration" is the location at which a name starts to be visible. And "definition context" is the state that the TU was in at template-definition time (c.f. bullet2).
Johannes Schaub - litb
I had assumed there's no doubt about that, given that /6 defines how the two relate. If the two would have been synonyms, /6 would make no sense at all. With BE Student's questions, it's hard to keep your answers concise.
MSalters