This is how I would use inbuilt function or new class as a custom comparator
priority_queue< int, vector<int>, greater<int> > third (myints,myints+4);
// using mycomparison:
priority_queue< int, vector<int>, mycomparison > q1;
class mycomparison
{
public:
bool operator() (const int& lhs, const int&rhs) const
{
return (lhs<rhs);
}
};
typedef priority_queue<int,vector<int>,mycomparison> q2;
But I wonder if I can use lambda functions there ..
See Question&Answers more detail:os