Generically, function objects are instances of a class with member function operator() defined. 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.
logical_not has its operator() member defined such that it returns true if its argument is false, and false if its argument is true, inverting its value.
This class is derived from unary_function and is defined as:
| 1 2 3 4 |
|
Objects of this class can be used with several standard algorithms (see algorithm).
Members
- T operator() (const T& x)
- Member function returning the result of !x.
Example
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
Output:
Logical NOT: NOT true = false NOT false = true |
See also
| logical_and | Logical AND function object class (class template) |
| logical_or | Logical OR function object class (class template) |
| unary_function | Unary function object base class (class template) |
