我在不属于类的头文件中有以下代码:
template<typename Foo> static const Compl<Foo,bar> *foobar (const FBTYPE &x);
template<> static const Compl<typea,bar> *foobar<typea>(const FBTYPE &x) {
return x.funcA();
}
template<> static const Compl<typeb,bar> *foobar<typeb>(const FBTYPE &x) {
return x.funcB();
}
代码在较旧的 GCC 版本中编译得很好,但在较新的版本中我收到此错误消息:
rsvt.h(672): error #3503: a storage class is not allowed in an explicit specialization
template<> static const Compl<typea,bar> *foobar<typea>(const FBTYPE &x) {
^
知道为什么它适用于旧版本的 GCC 但不适用于新版本吗?另外,我怎样才能让它与 GCC 5 一起工作?
最佳答案
原因在下面的引用中,现在在 C++ 标准中:[dcl.stc]/p1
A storage-class-specifier other than thread_local shall not be specified in an explicit specialization
关于c++ - 显式特化中不允许存储类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41019149/