The following code fragment declares a priority_queue of type pair<int,int> and uses a class comparator and correct in C++11 but shows error in C++03. What is the reason?
class compare
{
public:
bool operator () (pair<int,int>&p1,pair<int,int>&p2)
{
return p1.second > p2.second;
}
};
priority_queue <pair<int,int>, vector<pair<int,int> >,compare>pq;
C++03 compiler shows:
- error: template argument for 'template class std::priority_queue' uses local type 'main()::compare' priority_queue , vector >,compare>pq;
- error: trying to instantiate 'template class std::priority_queue'
0for that to be true. - Lightness Races in Orbitpriority_queue. - Some programmer dude