模板隐含判断,其判断逻辑是在编译期油编译器执行:
template<int i>//模板一 void print() { print<i-1>(); cout<<i<<endl; } //模板重载优先级 模板二 高于 模板一 template<> //模板二 void print<1>() { cout<<1<<endl; } int main(int argc, char const *argv[]) { print<100>(); system("pause"); return 0; }
转载于:https://blog.51cto.com/3754839/1401710