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_or has its operator() member defined such that it returns true if either (or both) of its arguments are true (using operator||), and false otherwise (when neither of the arguments is true).
This class is derived from binary_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, const T& y)
- Member function returning the result of x||y.
Example
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
Output:
Logical OR: true OR true = true false OR true = true true OR false = true false OR false = false |
See also
| logical_and | Logical AND function object class (class template) |
| logical_not | Logical NOT function object class (class template) |
| binary_function | Binary function object base class (class template) |
