将代码从gcc 2.95.3移植到gcc 4.4.2会导致新的编译时错误:
too few template-parameter-lists
下面是该代码的抽象和简化示例。错误发生在标记的行上。
#include <iostream>
using namespace std;
template<class SomeType> class SomeTemplate
{
public:
SomeType msg;
void Func ();
};
void SomeTemplate<long>::Func () //--- Error Here ---
{
cout << "SomeType size: " << sizeof (msg) << endl;
}
int main ()
{
SomeTemplate<long> MyType;
MyType.Func ();
}
答案 0 :(得分:1)
写
template <>
void SomeTemplate<long>::Func ()
{
cout << "SomeType size: " << sizeof (msg) << endl;
}