0

The comparator code in C++ below is as follows:

struct WordGreaterComparator
{
    bool operator()(const std::string & left, const std::string & right) const
    {
        return (left > right);
    }
};

My question is can someone explain what exactly is going on with the part:

operator()(...

What exactly is the purpose of it and what does it mean?

Matt
  • 3
  • 2
  • It means the object is invocable. Sometimes called "functor" or "function objects". In modern C++, lambdas have replaced the need for them in many cases. (Lambdas are just syntactic sugar for a functor.) – Eljay May 17 '20 at 20:22
  • @Eljay thanks! very helpful. – Matt May 17 '20 at 20:27

0 Answers0