jwf*_*arn 17 c++ gcc templates
这是另一个VC9与GCC 4.2编译错误问题.以下代码使用VC9(Microsoft Visual C++ 2008 SP1)编译,但不适用于Mac上的GCC 4.2:
struct C
{
template< typename T >
static bool big() { return sizeof( T ) > 8; }
};
template< typename X >
struct UseBig
{
static bool test()
{
return X::big< char >(); // ERROR: expected primary-expression
} // before 'char'
};
int main()
{
C::big< char >();
UseBig< C >::test();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我有什么想法可以解决这个问题?
Geo*_*che 40
那应该是
return X::template big< char >();
Run Code Online (Sandbox Code Playgroud)
从模板依赖的名字被带到不成为的类型,除非你指定,他们是通过typename与假定未成为模板,除非通过指定的template.
| 归档时间: |
|
| 查看次数: |
22116 次 |
| 最近记录: |