# re: g++的一个bug? 回复 更多评论
2006-10-13 05:36 by
我这里也差不多
#include <iostream>
using namespace std;
class A
{
public:
template <typename T>
T f(T val);
template <>
int f(int val);
};
[root@localhost soft]# g++ testtem.cpp
testtem.cpp:9: 错误:显式特例化出现在非命名空间作用域 ‘class A’ 中
testtem.cpp:10: 错误:‘f’ 不是一个模板函数
gcc 版本 4.1.0 20060304 (Red Hat 4.1.0-3)
# re: g++的一个bug? 回复 更多评论
2007-02-11 13:56 by
According to the Standard, template specializations can only be declared in namespace scope
http://gcc.gnu.org/ml/gcc/1998-09/msg00985.html