template <class T> struct greater; |
C++98 |
template <class T> struct greater : binary_function <T,T,bool> { bool operator() (const T& x, const T& y) const {return x>y;} }; |
成员类型 | 定义 | 注释 |
first_argument_type | T | 成员operator()中第一个参数的类型 |
second_argument_type | T | 成员operator()中第二个参数的类型 |
result_type | bool | 成员operator()返回的类型 |
T operator() (const T& x, const T& y) |
// 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; } |
equal_to | 用于相等比较的函数对象类(类模板) |
not_equal_to | 用于非相等比较的函数对象类(类模板) |
less | 用于小于不等比较的函数对象类(类模板) |
greater_equal | 用于大于等于比较的函数对象类(类模板) |
less_equal | 用于小于等于比较的函数对象类(类模板) |
binary_function | 二元函数对象基类 (类模板) |