(nessun oggetto)

Graziano Servizi Graziano.Servizi@bo.infn.it
Fri Oct 10 14:01:00 GMT 2014


I'm wondering in reading the 14.7.1.4  example of the standard, about 
template implicit instantiation: there it is found the following code

template<class T> struct Z {
void f();
void g();
};
void h() {
Z<int> a; // instantiation of class Z<int> required
Z<char>* p; // instantiation of class Z<char> not required
Z<double>* q; // instantiation of class Z<double> not required
a.f(); // instantiation of Z<int>::f() required
p->g(); // instantiation of class Z<char> required, and
         // instantiation of Z<char>::g() required
}

followed by this comment:

"Nothing in this example requires class

  Z<double>, Z<int>::g(), or Z<char>::f()

  to be implicitly instantiated."


Almost all is clear enaugh to me, but my question is: does the line

p->g();

imply allocation of the pointer p to hold an address for the member 
function g ONLY?

I didn't find any new operator before.

And what about this pointer at the end of the expression? Is it 
implicitly released as well as it was "implicitly allocated"?

Or all I wrote up to now is meaningless? ....

Thanks in advance.

                                GS



More information about the Gcc-help mailing list