M
mlt
I have a function that computes the distance between some objects. The
distance could be euclidian, manhaten etc. I would therefore like to
implement the distance metric as a functor as seen below:
template<typename dist>
function compute_distance(double a, double b)
{
dist dist_measure;
double distance = dist_measure(a,b);
return distance;
}
But can 'dist' just be a separate function or should be a class? Since its
use as a template parameter I assume it must be a type/class and cannot be a
simple function.
distance could be euclidian, manhaten etc. I would therefore like to
implement the distance metric as a functor as seen below:
template<typename dist>
function compute_distance(double a, double b)
{
dist dist_measure;
double distance = dist_measure(a,b);
return distance;
}
But can 'dist' just be a separate function or should be a class? Since its
use as a template parameter I assume it must be a type/class and cannot be a
simple function.