HP Integrity NonStop H-Series User Manual
Page 42
![background image](/manuals/396950/42/background.png)
to improve execution by using inline function calls, or to allow a function object to access or set
state information that is held by an object. We will give examples of each.
The following table illustrates the function objects provided by the standard library.
Name
Implemented operations
arithmetic functions
plus
minus
times
divides
modulus
negate
addition x + y
subtraction x - y
multiplication x * y
division x / y
remainder x % y
negation - x
comparison functions
equal_to
not_equal_to
greater
less
greater_equal
less_equal
equality test x == y
inequality test x != y
greater comparison x > y
less-than comparison x < y
greater than or equal comparison x >= y
less than or equal comparison x <= y
logical functions
logical_and
logical_or
logical_not
logical conjunction x && y
logical disjunction x || y
logical negation ! x
Let's look at a couple of examples that show how these might be used. The first example uses
plus() to compute the by-element addition of two lists of integer values, placing the result back
into the first list. This can be performed by the following:
transform (listOne.begin(), listOne.end(), listTwo.begin(),
listOne.begin(), plus
The second example negates every element in a vector of boolean values:
transform (aVec.begin(), aVec.end(), aVec.begin(),
logical_not
Location of the Class Definitions
The base classes used by the standard library in the definition of the functions shown in the
preceding table are available for the creation of new unary and binary function objects. These
base classes are defined as follows:
template
struct unary_function {