instantiation point discussion

Joined
Feb 12, 2008
Messages
108
Reaction score
0
Hello everyone,


We have a lot of discussion in the two days, seems points from people are not quite the same (at least to some degree). Let me quote the original statement from Bjarne and code again here.

My question is,

1. if you agree g(int) -- declaration only -- will not instantise function f to f<int>, which conflicts with Bjarne's point, could you provide some code to prove please?

2. if you agree with Bjarne's points, g(int) -- declaration only -- will instantise function f to f<int>, could you also provide some code to prove please?

My point is (1), since I think VC instantise a template only when we use it other than deduce any information from template definition phase -- but I can not prove it. If you could prove (1), it is great!

Code:
// section C.13.8.3 Point of Instantiatant Binding

template <class T> void f (T a) { g(a); }

void g(int);

void h()
{
	extern g (double);
	f (2);
}

--------------------
the point of instantiation for f<int>() is just before h(), so the g() called in f() is the global g (int) rather than the local g (double).
--------------------

BTW: from above statement from Bjarne, I think he means declaration of g(int) before h() will instiatise f to f <int>.


thanks in advance,
George
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,096
Latest member
ThurmanCre

Latest Threads

Top