Original Post
Hi again. So I've got this problem with g++(gcc as well), that I've found out some people are saying is considered as it's bug. Here it goes: I've seen several discussionss about this. A hacky(and very dirty) solution, that someone came up with, was to add an additional parameter to the templated function, that relies on the template argument. Then, whe calling, ignore template argument, and just pass the fake one, in hope the compiler deduces what the template param actually is. The conclusion: It did worked for some simple examples, but failed for a more complicated one. So the question is: Is it possible to do it at all? Is there a better version of gxx, where this bug is not present (I'm using 3.3.4)? Finally, can I use any another compliler (the program should run under linux)? Help... /def
template< typename T >
class A
{
public:
template< typename Ta >
void funcA(void) {
// something (probably consisting of Ta usage).
}
public:
// ...
};
template< typename T >
class B
{
public:
A<int> m_a;
public:
void callA(void) {
m_a.funcA<double>; // g++ says: parse error before ';' token.
}
};
int main()
{
B b;
b.callA();
// ...
}
template< typename T >
struct dummy {};
// Declare with:
template< typename T >
void funcA(dummy<T> fakeParam) { /*...*/ };
// And call with:
a.funcA(dummy<double>);
// Here compiler should deduce the template parameter.
// And not brag about being too stupid to understand the grammatic.