mercredi 1 novembre 2017

C++ Priority Queue with Custom Compare Function not Behaving Correctly on Push()

I have defined a C++ priority queue like this:

priority_queue<pair<int,int>, vector<pair<int,int>>, decltype(&mygreater)> frontier(&mygreater);

with a custom mygreater function() like this:

bool mygreater(pair<int,int> v1, pair<int,int> v2) {
        return v1.first > v2.first;
}

However, when I try to push a vector of pairs of ints onto the priority queue, I keep getting a ton of errors, including:

error: no matching function for call to ‘std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int> >, bool (*)(std::pair<int, int>, std::pair<int, int>)>::push(std::vector<std::pair<int, int> >&)’ frontier.push(temp);

Might anyone know what is causing the errors on my attempts to push to the priority queue? Any help is greatly appreciated.

Aucun commentaire:

Enregistrer un commentaire