template <class T> struct divides; |
C++98 |
template <class T> struct divides : 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) |
// divides example #include <iostream> // std::cout #include <functional> // std::divides #include <algorithm> // std::transform int main () { int first[]={10,40,90,40,10}; int second[]={1,2,3,4,5}; int results[5]; std::transform (first, first+5, second, results, std::divides<int>()); for (int i=0; i<5; i++) std::cout << results[i] << ' '; std::cout << '\n'; return 0; } |
plus | 加法函数对象类(类模板) |
minus | 减法函数对象类(类模板) |
multiplies | 乘法函数对象类(类模板) |
modulus | 模函数对象类(类模板) |
negate | 取反函数对象类(类模板) |
equal_to | 用于相等比较的函数对象类(类模板) |