0

Got a problem when reviewing other's code in C++. He defines a comparison as the following code:

auto f = [](const pair<Tweet*, Tweet*>& x, const pair<Tweet*, Tweet*>& y) {
        return x.second->time < y.second->time;
};

The environment is the follow:(h is defined as vector<pair<Tweet*, Tweet*>> h;)

make_heap(h.begin(), h.end(), f);

My question:

  1. What is the '[ ]' means here?
  2. I trying to rewrite as follow but does not work properly, what do I miss?

    bool f(const pair<Tweet*, Tweet*>& x, const pair<Tweet*, Tweet*>& y)
    {
      return x.second->time < y.second->time;
    }
    

0 Answers0