S
Szabolcs
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<double> apply(const array<double> &source) {
array<double> result(source.size());
for (int i = 0; i < source.size(); i++)
result = fun(source);
return result;
}
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<double> apply(const array<double> &source) {
array<double> result(source.size());
for (int i = 0; i < source.size(); i++)
result = fun(source);
return result;
}