How do I create a set with std::pair thats sorted based on the ::second pair member using bind

Posted by Stone Free on Stack Overflow See other posts from Stack Overflow or by Stone Free
Published on 2010-06-02T13:40:23Z Indexed on 2010/06/02 13:44 UTC
Read the original article Hit count: 191

Filed under:
|
|
|
|

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

© Stack Overflow or respective owner

Related posts about c++

Related posts about boost