Sorry, the name is a sip. I am working on an array class similar to that described here . I want to define a map function that accepts a user-defined function and applies it to each element of the array. For the purpose of type checking, I would like to define it so that the function specified by the user should take the same number of arguments that are passed to the map function, so
double f(double a, double b) { return a + b; }
Array<double,2> x, y, z; x.map(f, y, z);
will compile but
double g(double a, double b, double c) { return a + b + c; }
Array<double,2> x, y, z;. x.map(g, y, z);
will not, because it gtakes the wrong number of arguments based on what was passed to the map function.
I tried syntax like:
template<typename T, size_t ... Ns> class Array
{
template<class ... Args> inline const Array<T, Ns...>
map(T (*fn)(decltype(Args, double)...), Args...)
{
}
}
, , , . .