【发布时间】:2015-02-11 13:21:45
【问题描述】:
请考虑以下格式错误的程序:
struct S {
template<class T> struct J { };
};
template<>
struct S::J<void> {
void f();
};
template<>
void S::J<void>::f() {} // ERROR
$ clang++ -std=c++11 test.cpp
no function template matches function template specialization 'f'
$ g++ -std=c++11 test.cpp
template-id ‘f<>’ for ‘void S::J<void>::f()’ does not match any template declaration
f 的定义为什么不能编译?如何在上面正确定义函数f?
【问题讨论】:
标签: c++ templates c++11 c++14 template-specialization