The following didactic example illustrates my problem :
#include <iostream>
#include <cmath>
template<class Function, class... Args>
double apply(Function f, Args... args)
{
return f(args...);
}
template<class Function, class... Args>
double applybis(Function f, Args... args)
{
return f(std::sin(args...));// <- How to apply a function to
// each variadic parameter and
// return a modified variadic list ?
}
int main(int argc, char* argv[])
{
std::cout<<apply(static_cast<double(*)(double)>(std::sin), 3.)<<std::endl;
return 0;
}
How to “transform” a variadic list by applying a function to each component and return a modified variadic list ?
(Is there a way to write the applybis function without modifying its current signature ?)
Here you go:
That is,
...should come after(args).It expands/unpacks to this form: