Pair inside priority queue

This is what priority_queue looks like:

template<
    class T,
    class Container = std::vector<T>, 
    class Compare = std::less<typename Container::value_type>
> class priority_queue;

In other words, CompareDist should be the third argument and the second argument should be the container (which has value_type), like the following:

priority_queue<pair<int,int>,vector<pair<int,int>>,CompareDist> pq;

Notice also, that priority_queue is what is called a “container adaptor”. Another container is used as the underlying container and the priority_queue has special members functions for accessing it. Another example of a container adaptor would be std::stack.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)