具有可变数量参数的函数调用

Pre*_*rag 4 variadic-templates c++11

是否可以使用可变数量的参数构造函数调用(内部函数模板),具体取决于模板参数的数量?就像是:

void f(int i) {}
void f(int i1, int i2){}
void f(int i1, int i2, int i3){}
...

template<typename... T>
void caller() {
   f(/* sizeof...(T) number of arguments; of form T_i::value */);
}
Run Code Online (Sandbox Code Playgroud)

Joh*_*esD 6

是; 模板参数包T可以像函数参数包一样扩展:

template<typename... T>
caller() {
   f(T::value...);
}
Run Code Online (Sandbox Code Playgroud)