#include <string>
#include <iostream>
using namespace std;
struct A{
template<class T> string operator()(T x){
return "No";
}
template</*int*/> string operator()(int x){
return "Yes";
}
};
A check;
int main(){
cout<<check("1")<<endl;
cout<<check(21)<<endl;
return 0;
}
就这个代码,会 CE,这是编译信息:
/tmp/compiler_a4oh_y2p/src:8:21: 错误:显式特例化出现在非命名空间作用域‘struct A’中
template</*int*/> string operator()(int x){
^
看了 cppreference.com 了,也 BDFS 了,还是搞不懂,一直 CE,请问应该怎么改才不会 CE?