template <class T> struct greater_equal; |
C++98 |
template <class T> struct greater_equal : 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_equal example #include <iostream> // std::cout #include <functional> // std::greater_equal, std::bind2nd #include <algorithm> // std::count_if int main () { int numbers[]={20,-30,10,-40,0}; int cx = std::count_if (numbers, numbers+5, std::bind2nd(std::greater_equal<int>(),0)); std::cout << "There are " << cx << " non-negative elements.\n"; return 0; } |
equal_to | 用于相等比较的函数对象类(类模板) |
not_equal_to | 用于非相等比较的函数对象类(类模板) |
greater | 用于大于不等比较的函数对象类(类模板) |
less | 用于小于不等比较的函数对象类(类模板) |
less_equal | 用于小于等于比较的函数对象类(类模板) |
binary_function | 二元函数对象基类 (类模板) |