Function call with variable number of arguments
Is it possible to construct function call (inside function template) with variable number of arguments, depending on number of template arguments? Something like:
void f(int i) {}
void f(int i1, int i2){}
void f(int i1, int i2, int i3){}
...
template<typ开发者_C百科ename... T>
void caller() {
f(/* sizeof...(T) number of arguments; of form T_i::value */);
}
Yes; the template parameter pack T
may expanded the same way as a function parameter pack:
template<typename... T>
caller() {
f(T::value...);
}
精彩评论