Please have a look at this example posted by Johannes Schaub to sort a vector of pairs:
How do I sort a vector of pairs based on the second element of the pair?
std::sort(a.begin(), a.end(),
boost::bind(&std::pair<int, int>::second, _1) <
boost::bind(&std::pair<int, int>::second, _2));
I thought I do understand boost::bind, but I have trouble with this one.
Question 1:
the sort algorithm is expecting a predicate function as a third parameter. What I see here, is a boolean expression. What am I missing?:
boost::bind(&std::pair<int, int>::second, _1) < boost::bind(&std::pair<int, int>::second, _2)
Does the boost::bind library overload operator< for those two binds, and is returning some kind of function pointer (like a lambda)?
Question 2:
This gets me confused:
boost::bind(&std::pair<int, int>::second, _1)
Usually there is some kind of function pointer as first parameter of a bind call, but here it is an address of a class member? What is the result of that particular bind?
Thanks for your time & help