Apache C++ Standard Library Reference Guide

## logical_or

Library: General utilities

    Does not inherit

- Local Index
- Summary
- Synopsis
- Description
- Interface
- See Also
- Standards Conformance

### Local Index

No Entries

### Summary

A binary function object that returns `true` if either of its arguments are `true`

### Synopsis

    #include <functional>

    namespace std {
      template <class T>
      struct logical_or;
    }

### Description

logical_or is a binary function object. Its `operator()` returns `true` if either `x` or `y` are `true`. You can pass a logical_or object to any algorithm that requires a binary function. For example, the `transform()` algorithm applies a binary operation to corresponding values in two collections and stores the result of the function. logical_or is used in that algorithm in the following manner:

    list<bool> list1;
    list<bool> list2;
    list<bool> listResult;
    .
    .
    .
    transform(list1.begin(), list1.end(),
              list2.begin(),
              listResult.begin(), logical_or<bool>());

After this call to `transform()`, `listResult(n)` contains a `1` (`true`) if either `list1(n)` or `list2(n)` is `true`, or a `0` (`false`) if both `list1(n)` and `list2(n)` are `false`.

### Interface

    namespace std {

      template <class T>
      struct logical_or : binary_function<T, T, bool> {
        bool operator()(const T&, const T&) const;
      };
    }

### See Also

binary_function, Function Objects

### Standards Conformance

ISO/IEC 14882:1998 -- International Standard for Information Systems -- Programming Language C++, Section 20.3.4