I need to pass a distance-function to a template. Therefore I use boost::function and boost::bind. But I do not understand what I have to pass for class Distance:
template<class DataType, class Point, class Distance>
class CoverTree
{
Distance distance;
...
public:
CoverTree(const Distance& distance) : max_level(default_max_level), min_level(default_max_level), distance(distance) {}
...
}
the example by the author of the template looks like this:
float euclidian(const std::vector<float>& p1, const std::vector<float>& p2)
{
...
}
int main(int argc, char** argv)
{
CoverTree<float, std::vector<float>, float (*const)(const std::vector<float>&, const std::vector<float>&)> tree(&euclidian);
...
}
Now this is my main:
int main(int argc, char** argv)
{
AllData myData;
boost::function<float (const vector<Frame>::const_iterator&, const vector<Frame>::const_iterator&)> j_dist;
j_dist = boost::bind(&AllData::jaccard_distance, myData, _1, _2);
myData.AddData("C:\\...");
cout<<j_dist(myData.DATAx.begin()+20, myData.DATAx.begin()+40)<<endl; //works fine
CoverTree<float, vector<Frame>::const_iterator, ???> tree(&j_dist);
...
}
At first, can somone explain me what (*const) means or where I can read about this?
And second:
I think I wrote everything you need, to tell what to write for ??? but I don't get it.
I already tried:
boost::function<float (const vector<Frame>::const_iterator&, const vector<Frame>::const_iterator&)
and
float (*const) (const vector<Frame>::const_iterator&, const vector<Frame>::const_iterator&)
but this was nice try and error :)