parse error in gcc but success in vc.net, call a non_template class's template member function from

K

ken

the test code is :


/////////////////////////////////////////////////////////////////
#include <stdlib.h>
#include <stdio.h>

class CA
{
public:
template <typename T>
T Fun()
{
return T();
}
};
template<>
void CA::Fun<void>()
{
printf("in void\n");
return;
}

template <typename T>
class CB
{
public:
int operator()(T a1=T())
{
printf("aaa\n");
CA a;
a.Fun<T>(); //error this line
return 0;
}
};

int main()
{
CB<int> b;
b();
return 0;
}

/////////////////////////////////////////////////////////////////

the gcc 3.2.2 compiler report a error:
testtemp.cpp: In member function `int CB<T>::eek:perator()(T)':
testtemp.cpp:37: parse error before `;' token

what's the matter? everything is right in the vc.net 7.1?
 
M

Maxim Yegorushkin

[]
the gcc 3.2.2 compiler report a error:
testtemp.cpp: In member function `int CB<T>::eek:perator()(T)':
testtemp.cpp:37: parse error before `;' token

what's the matter? everything is right in the vc.net 7.1?

Looks like a gcc bug. The code compiles fine with g++ 3.4.3 and 4.0.0 and
comeau online.
 

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

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top