I have a template that computes some values according to the function I pass as parameter. However, not every function I pass to the templates needs all of the parameters computed in the template.
template<typename T>
int func(T function)
{
int a = 0; // some value computed in func
int b = 10; // another value computed in func
return function(a, b);
}
int main()
{
int res = func([](int a, int b)
{
// do somthing
return 0;
}
);
return 0;
}
I would like writing something like
int res2 = func([](int a) // needs only parameter a
{
// do somthing
return 0;
}
);
if the function needs only one of the parameters passed by the template. How can I deduce the number of paramters the function passed to the template needs to achieve this?