I had to pass an unordered map to the comparator function of a priority queue and using the link Passing a parameter to a comparison function? I decided to do it as follows:
priority_queue < int, std::vector<int>, compare(freq) > pq;
struct compare
{
compare( std::unordered_map<int,int>& freq1 )
{
freq = freq1;
}
bool operator()( int& el1, int& el2 ){
return freq[el1] < freq[el2];
}
std::unordered_map<int,int> freq;
};
However I'm getting the error:
Template argument for template type parameter must be a type
What am I doing wrong?