skip to Main Content

Ubuntu – Why iterator type of priority_queue is wrong with range constructor?

The code is as following. #include <iostream> #include <queue> #include <unordered_map> using namespace std; typedef unordered_map<int,int>::iterator myIt; class cmpHelper { public: bool operator()(myIt l, myIt r){return l->second > r->second;} }; int main(int argc, char* argv[]){ unordered_map<int,int> freq_cnt({{3,1},{2,4},{5,2}}); priority_queue<myIt,vector<myIt>, cmpHelper> h(freq_cnt.begin(),…

VIEW QUESTION
Back To Top
Search