This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

(nessun oggetto)


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]