我想使用priority_queue并将其传递给函数:
// compare points according their distance to some target point
struct MyComparator {
Point target;
MyComparator(Point t) : target(t) {}
bool operator() (const Point& p1, const Point& p2) {
return distance(target, p1) < distance(target, p2);
}
};
typedef priority_queue<Point, vector<Point>, MyComparator> myque;
void myfunc(const Point& target, myque& que) { ... }
// call myfunc
Point target = ...;
myque queue(MyComparator(target));
myfunc(target, queue);
// error :
no matching function for call to ‘myfunc(const Point&, myque (&)(MyComparator))’
如何解决此错误?
感谢。