Topi Maenpaa <[EMAIL PROTECTED]> wrote: > --------------------------------------------------- > template <class T> class A > { > public: > template <class U> void test(T value) {} > }; > > template <class T> void test2(A<T>& a, T val) > { > a.test<int>(val); > } > > int main() > { > A<int> a; > a.test<int>(1); //works fine > } > ---------------------------------------------------
This is ill-formed. You need to write: a.template test<int>(val); because 'a' is a dependent name. > The funny thing is that if I change the name of the "test2" function > to "test", everything is OK. The compiler complains only if the > functions have different names. Why does the name matter? This is surely a bug. Would you please file a bug report about this? > The code compiles if "test2" is not a template function. Furthermore, > calling A<T>::test directly from main rather than through the > template function works fine. This is correct, because if "test2" is not a template function name anymore, then 'a' is not a dependent name, and the 'template' keyword is not needed to disambiguate the parser. Giovanni Bajo