I am looking for a way to generalize the function template below, so
that it will work with any type, not just double. Is this at all
possible in C++? I'd like to replace double (*fun)(double) with a
generalized A (*fun)(B).
template<double (*fun)(double)>
array<doubleapp ly(const array<double&so urce) {
array<doubleres ult(source.size ());
for (int i = 0; i < source.size(); i++)
result[i] = fun(source[i]);
return result;
}
Comment