Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   parse error in gcc but success in vc.net, call a non_template class's template member function from a template class's member function! (http://www.velocityreviews.com/forums/t446634-parse-error-in-gcc-but-success-in-vc-net-call-a-non_template-classs-template-member-function-from-a-template-classs-member-function.html)

ken 06-24-2005 08:13 AM

parse error in gcc but success in vc.net, call a non_template class's template member function from a template class's member function!
 
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>::operator()(T)':
testtemp.cpp:37: parse error before `;' token

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


Maxim Yegorushkin 06-24-2005 09:10 AM

Re: parse error in gcc but success in vc.net, call a non_template class's template member function from a template class's member function!
 
On Fri, 24 Jun 2005 12:13:43 +0400, ken <louguoliang@gmail.com> wrote:

[]

> the gcc 3.2.2 compiler report a error:
> testtemp.cpp: In member function `int CB<T>::operator()(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.

--
Maxim Yegorushkin

ken 06-28-2005 06:57 AM

Re: parse error in gcc but success in vc.net, call a non_template class's template member function from a template class's member function!
 
it seems that I have to update my gcc :(
thank you!



All times are GMT. The time now is 10:30 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.