Template Member Functions of Template Classes

G

gogo1969

Hello,

I was wondering why the following code compiles with Intel C++ 8.0 and
MS VC++ 7.1 but not with gcc 4.0.1 and Comeau 4.3.3:

#include <iostream>

template < class T > struct B {
template < class O > static O CastTo( T t ) { return O( t ); }
};

template < class T > int convert( T t )
{
return B< T >::CastTo< int >( t );
// ^
// Comeau: Type not allowed
}

int main( int, char** )
{

std::cout << convert( 'c' );
return 0;
}

The problem is this line: 'B< T >::CastTo< int >( t );'
 
R

red floyd

Hello,

I was wondering why the following code compiles with Intel C++ 8.0 and
MS VC++ 7.1 but not with gcc 4.0.1 and Comeau 4.3.3:

#include <iostream>

template < class T > struct B {
template < class O > static O CastTo( T t ) { return O( t ); }
};

template < class T > int convert( T t )
{
return B< T >::CastTo< int >( t );
 
K

Kai-Uwe Bux

Hello,

I was wondering why the following code compiles with Intel C++ 8.0 and
MS VC++ 7.1 but not with gcc 4.0.1 and Comeau 4.3.3:

#include <iostream>

template < class T > struct B {
template < class O > static O CastTo( T t ) { return O( t ); }
};

template < class T > int convert( T t )
{
return B< T >::CastTo< int >( t );

try:

return B said:
// ^
// Comeau: Type not allowed
}

int main( int, char** )
{

std::cout << convert( 'c' );
return 0;
}

The problem is this line: 'B< T >::CastTo< int >( t );'


Best

Kai-Uwe Bux
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top