The following fails to compile (with gcc 4.2.1 on Linux, anyway):
template< typename T >
class Foo
{
public:
typedef int FooType;
};
void
ordinary()
{
Foo< int >::FooType bar = 0;
}
template< typename T >
void
templated()
{
Foo< T >::FooType bar = T( 0 );
}
int main( int argc, char **argv )
{
return 0;
}
The problem is with this line:
Foo< T >::FooType bar = 0;
...and the compiler makes this complaint:
foo.c: In function ‘void templated()’:
foo.c:22: error: expected `;' before ‘bar’
Normally one sees this when a type hasn't been declared, but as far as I can tell, Foo< T >::FooType should be perfectly valid inside templated().