How do I create a set with std::pair thats sorted based on the ::second pair member using bind
I know I could use the following: template <typename Pair> struct ComparePairThroughSecond : public std::unary_function<Pair, bool> { bool operator ()(const Pair& p1, const Pair& p2) const { return p1.second < p2.second; } }; std::set<std::pair<int, long>, ComparePairThroughSecond> somevar; but wondered if it could be done with boost::bind How about the following one. I'm using boost::function to 'erase' the actual type of the comparator. The comparator is created using boost:bind itself. typedef std::pair<int, int> IntPair; typedef boost::function<bool (const IntPair &, const IntPair &)>