Hi folks.
The following code compiles fine with icc, however g++-3.3 issues "12: parse error before ';' token". What's wrong?
Code:
/*
* simple test case for nested templates and template function specialization
*/
# include <iostream>
using std::cout;
using std::endl;
/**
* Class template
*/
template< class T, int pT >
class A
{
public:
static void function()
{
T::function< pT >(); // g++ does not like this line
}
};
/*
* Class with function template
*/
class B
{
public:
template< int pT >
static void function();
};
/*
* For some reason, template function specialization may not occur in class definitions
*/
template< int pT > void B::function()
{
cout << "unspecialized" << endl;
}
template< > void B::function< 0 >()
{
cout << "specialized" << endl;
}
/*
* Typedef to fake template function specialization in a class template
*/
typedef A< B, 0 > C;
/*
* Putting it all together
*/
class D
{
public:
static void function()
{
C::function();
}
};
int main() {
D::function();
return 0;
}