[ create a new paste ] login | about

Link: http://codepad.org/54PXQSoL    [ raw code | fork ]

C++, pasted on May 5:
#include <algorithm>
#include <functional>
#include <utility>
#include <vector>

template <typename T, template <typename> class F>
struct Pair1stFunc2
{
    template <typename P>
    typename F<T>::result_type operator()(P &lhs, P &rhs) const
    { F<T> f; return f(lhs.first, rhs.first); }

    template <typename P>
    typename F<T>::result_type operator()(const P &lhs, const P &rhs) const
    { F<T> f; return f(lhs.first, rhs.first); }
};

typedef std::pair<int,int> MyPair;
typedef std::vector<MyPair> MyPairList;

MyPairList pairs;


void foo(void)
{
    std::sort(pairs.begin(),
              pairs.end(),
              Pair1stFunc2<int, std::less>());
}

int main(){
foo();
}


Output:
No errors or program output.


Create a new paste based on this one


Comments: