Function objects are objects whose class defines member function operator(). This member function allows the object to be used with the same syntax as a regular function call, and therefore it can be used in templates instead of a pointer to a function.
The function object returned by not1 has its operator() defined such that it returns true when pred would return false, and false when pred would return true.
It is defined with the same behavior as:
| 1 2 3 4 5 |
|
not1 is specifically designed to negate function objects (predicates) derived from unary_function (an argument_type member is required). For binary function objects, see not2.
Parameters
- Predicate
- Unary function object derived from unary_function.
Return value
An unary function object with the opposite behavior of pred.unary_negate is a type derived from unary_function.
Example
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|
Output:
There are 2 elements with even values. |
See also
| not2 | Return negation of binary function object (function template) |
| unary_negate | Generate negation of unary function object class (class template) |
| unary_function | Unary function object base class (class template) |
