Hi All,
I'm currently using gcc 4.20 and I'm running into problems with templates. Afaik the latest gcc versions are quit strict in meeting the standard, so I'm probably doing something wrong, but I don't see what.. (reading the standard didn't help, the lingo is quite weird ;-)
here's a simplified test case:
template< class T >
struct tTest
{
template< class T2 >
static T2 func()( const T& ac_tType )
{
//actual code does stuff to convert T->T2 here
return T2();
}
};
template< class T >
struct tUsesTest
{
typedef tTest< T > mt_Test;
void func()
{
T test;
int nConverted = mt_Test::func( test );
}
};
int main( argc, argv )
{
tUsesTest< unsigned > test;
test.func();
return 0;
}
template< class T >
struct tTest
{
template< class T2 >
static T2 func()( const T& ac_tType )
{
//actual code does stuff to convert T->T2 here
return T2();
}
};
template< class T >
struct tUsesTest
{
typedef tTest< T > mt_Test;
void func()
{
T test;
int nConverted = mt_Test::func( test );
}
};
int main( argc, argv )
{
tUsesTest< unsigned > test;
test.func();
return 0;
}
To copy to clipboard, switch view to plain text mode
this gives:
20: error: no matching function for call to 'tTest<unsigned int>::func(unsigned int&)'
replacing line 20 with
int nConverted = mt_test::func< int >( test );
int nConverted = mt_test::func< int >( test );
To copy to clipboard, switch view to plain text mode
yields:
20: error: expected primary-expression before 'int'
Can anyone explain in understandable language why this fails, and how to code this correctly?
Thanks in advance!
Bookmarks