template <class T> struct less; |
C++98 |
template <class T> struct less : 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) |
// less example #include <iostream> // std::cout #include <functional> // std::less #include <algorithm> // std::sort, std::includes int main () { int foo[]={10,20,5,15,25}; int bar[]={15,10,20}; std::sort (foo, foo+5, std::less<int>()); // 5 10 15 20 25 std::sort (bar, bar+3, std::less<int>()); // 10 15 20 if (std::includes (foo, foo+5, bar, bar+3, std::less<int>())) std::cout << "foo includes bar.\n"; return 0; } |
equal_to | 用于相等比较的函数对象类(类模板) |
not_equal_to | 用于非相等比较的函数对象类(类模板) |
greater | 用于大于不等比较的函数对象类(类模板) |
greater_equal | 用于大于等于比较的函数对象类(类模板) |
less_equal | 用于小于等于比较的函数对象类(类模板) |
binary_function | 二元函数对象基类 (类模板) |