class template
<functional>
std::logical_or
template <class T> struct logical_or;
Logical OR function object class
Binary function object class whose call returns the result of the logical "or" operation between its two arguments (as returned by operator ||).
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 function call.
It is defined with the same behavior as:
| 12
 3
 
 | template <class T> struct logical_or : binary_function <T,T,bool> {
  bool operator() (const T& x, const T& y) const {return x||y;}
};
 | 
 
| 12
 3
 4
 5
 6
 
 | template <class T> struct logical_or {
  bool operator() (const T& x, const T& y) const {return x||y;}
  typedef T first_argument_type;
  typedef T second_argument_type;
  typedef bool result_type;
};
 | 
 
 
Template parameters
- T
- Type of the arguments passed to the functional call.
 The type shall support the operation (operator||).
 
Member types
| member type | definition | notes | 
|---|
| first_argument_type | T | Type of the first argument in member operator() | 
| second_argument_type | T | Type of the second argument in member operator() | 
| result_type | bool | Type returned by member operator() | 
Member functions
- bool operator() (const T& x, const T& y)
- Member function returning whether any of its arguments are considered true (x||y).
Example
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 
 | // logical_or example
#include <iostream>     // std::cout, std::boolalpha
#include <functional>   // std::logical_or
#include <algorithm>    // std::transform
int main () {
  bool foo[] = {true,false,true,false};
  bool bar[] = {true,true,false,false};
  bool result[4];
  std::transform (foo, foo+4, bar, result, std::logical_or<bool>());
  std::cout << std::boolalpha << "Logical OR:\n";
  for (int i=0; i<4; i++)
    std::cout << foo[i] << " OR " << bar[i] << " = " << result[i] << "\n";
  return 0;
}
 | 
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
)