4

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<typename... T>
void caller() {
   f(/* sizeof...(T) number of arguments; of form T_i::value */);
}

1 Answer 1

6

Yes; the template parameter pack T may expanded the same way as a function parameter pack:

template<typename... T>
caller() {
   f(T::value...);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.