参考:https://en.cppreference.com/w/cpp/language/function_template 文章目录 模板参数推导(template argument deduction) 默认模板参数(default template arguments) 显式指定模板参数(specified explicitly) 显式实例化(explicit instantiation) 今天我们来聊聊函数模板参数的获取途径,即模板参数可以通过哪些渠道获得类型。 函数模板的模板参数可以通过以下方式获取: 模板参数推导(template argument deduction) 当调用函数时,编译器可以从函数实参中推导出函数模板的模板参数。例如: template <typename T> void print(T value) {