template <class T> struct greater;
123
template <class T> struct greater : binary_function <T,T,bool> { bool operator() (const T& x, const T& y) const {return x>y;} };
123456
template <class T> struct greater { bool operator() (const T& x, const T& y) const {return x>y;} typedef T first_argument_type; typedef T second_argument_type; typedef bool result_type; };
operator()
x>y
12345678910111213
// greater example #include <iostream> // std::cout #include <functional> // std::greater #include <algorithm> // std::sort int main () { int numbers[]={20,40,50,10,30}; std::sort (numbers, numbers+5, std::greater<int>()); for (int i=0; i<5; i++) std::cout << numbers[i] << ' '; std::cout << '\n'; return 0; }
50 40 30 20 10