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