I trying to use sort algorithm for sorting the elements of a vector. This is my code snippet.
Comparator
struct comparator
{
boo
The comparator functor is supposed to take the elements but not the iterators as the parameter for comparing.
You should change the parameter type of comparator::operator() from iterator to value type:
struct comparator
{
bool operator() ( const pair > & lhs, const pair > & rhs) const
{
return lhs.first < rhs.first;
}
};
BTW: Making operator() const member function is a good habit.