-1

when sorting a vector i am using the following code

sort(vec1.begin(), vec1.end(), less<int>());

compiler accepts the third argument which is also the default argument. But for sorting in descending order i see greater<int>() on every forum but my compiler only accepts

sort(vec1.begin(), vec1.end(), isgreater<int, int>);

which works by the way. is the template updated in c++ or is the older greater<>() in some other library?

1 Answers1

2

The template is called std::greater, and it is declared in the header <functional>, which you must include.

Kerrek SB
  • 464,522
  • 92
  • 875
  • 1,084