Next : , Previous : Base, Top : Table of Contents


Arithmetic operations

plus Function Object
minus Function Object
times Function Object
divides Function Object
modulus Function Object
negate Function Object

The library provides basic function object classes for all of the arithmetic operators in the language.

template 
struct plus : binary_function {
    T operator()(const T& x, const T& y) const { return x + y; }
};

template 
struct minus : binary_function {
    T operator()(const T& x, const T& y) const { return x - y; }
};

template 
struct times : binary_function {
    T operator()(const T& x, const T& y) const { return x * y; }
};

template 
struct divides : binary_function {
    T operator()(const T& x, const T& y) const { return x / y; }
};

template 
struct modulus : binary_function {
    T operator()(const T& x, const T& y) const { return x % y; }
};

template 
struct negate : unary_function {
    T operator()(const T& x) const { return -x; }
};

 

Top