如何定义具有数量可变的参数(每个参数的类型可能不同)的模板化类或函数?
How do you define a templated class or a function with a variable number of arguments, each with a potentially different type?
可以使用 typename… 声明可变参数模板。
首先调用 f 的模板化版本,第一个参数的类型是字符串,作为大小可变的参数提供字符和双精度值。
The first time around, the templated version of f is called, with a string as the first argument type, and the character and double are packed off as the variable size argument.
应用推荐