在这个例子中,如何调用第二个函数?
template<class T>
T square(T a) {
std::cout << "using generic version to square " << a << std::endl;
return a*a;
}
/// "int" is so special -- provide a specialized function template
template<>
int square(int a) {
std::cout << "using specialized generic version to square " << a << std::endl;
return a*a;
}
/// and there's one more: a non-template square function for int
int square(int a) {
std::cout << "using explicit version to square " << a << std::endl;
return a*a;
}
提前致谢!