template <class T> struct plus; |
C++98 |
template <class T> struct plus : binary_function <T,T,T> { T operator() (const T& x, const T& y) const {return x+y;} }; |
成员类型 | 定义 | 注释 |
first_argument_type | T | 成员operator()中第一个参数的类型 |
second_argument_type | T | 成员operator()中第二个参数的类型 |
result_type | T | 成员operator()返回的类型 |
T operator() (const T& x, const T& y) |
// plus example #include <iostream> // std::cout #include <functional> // std::plus #include <algorithm> // std::transform int main () { int first[]={1,2,3,4,5}; int second[]={10,20,30,40,50}; int results[5]; std::transform (first, first+5, second, results, std::plus<int>()); for (int i=0; i<5; i++) std::cout << results[i] << ' '; std::cout << '\n'; return 0; } |
minus | 减法函数对象类(类模板) |
multiplies | 乘法函数对象类(类模板) |
divides | 除法函数对象类(类模板) |
modulus | 模函数对象类(类模板) |
negate | 取反函数对象类(类模板) |
equal_to | 用于相等比较的函数对象类(类模板) |