C++ std::priority_queue uses the lambda expression

There is statement that the compiler can’t pass. I can’t understand it. Can anyone tell me in detail or How to fix it ? Best wishes to you.

The statement as follow:

    std::priority_queue<int,std::vector<int>,[](const int& lhs,const int& rhs)
    { 
        return lhs<rhs;
    } > pq;

The compiler given the information as follow:

 type/value mismatch at argument 3 in template parameter list for 
'template<class _Tp, class _Sequence, class _Compare> class std::priority_queue'

The std::priority_queue inducted in cppreference site:http://en.cppreference.com/w/cpp/container/priority_queue

mainly structure as follow:

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

Leave a Comment