I'm developing this program to run Dijkstra's Algorithm with an heap implementation and I want it to be as versatile as it can be so I'm using function pointer in order to avoid code repetition. This is the error that it pops. I'm using the stl make_heap
"Type must use '.*' or '->*' to call pointer-to-member function in '__comp (...)', e.g. '(... ->* __comp) (...)' "heap.h C/C++ Problem
Here is Dijkstra's Algorithm:
void Graph::dijkstraAlg(Vertex* ini, Vertex* fin, void(Graph::*weight_filler)(void), bool(Graph::*pq_order)(const Vertex* &, const Vertex* &)){
for(unsigned int i = 0; i < vertexs.size(); i++) {
vertexs[i]->path = NULL;
vertexs[i]->holder = MAX_INT_VALUE;
vertexs[i]->processing=false;
}
(this->*weight_filler)();
Vertex* v=ini;
v->holder = 0;
v->processing = true;
vector<Vertex*> pq;
pq.push_back(v);
make_heap(pq.begin(),pq.end(),pq_order);
while(!pq.empty()){
v=pq.front();
pop_heap(pq.begin(),pq.end());
pq.pop_back();
for(unsigned int u=0; u < v->adj.size(); u++){
Vertex* w = v->adj[u]->dest;
if((v->holder+v->adj[u]->weight) < w->holder){
w->holder=v->holder + v->adj[u]->weight;
w->path=v;
if(!w->processing){
w->processing=true;
pq.push_back(w);
}
}
make_heap(pq.begin(),pq.end(),pq_order);
}
}
return;}
The error is in the make_heap and I can't figure it out, any help is appreciated.
Here is the function I'm passing to the make_heap:
bool Graph::regular_PqOrder(const Vertex* &v, const Vertex* &u){
return v->holder > u->holder;}
This is how I call the algo:
dijkstraAlg(i,f,&Graph::price_WeightFiller,&Graph::regular_PqOrder);
If you need more information just tell me and I edit it. Thank you pal's