Partager via


logical_or (STL/CLR)

 

The latest version of this topic can be found at logical_or (STL/CLR).

The template class describes a functor that, when called, returns true only if either the first argument or the second tests as true. You use it specify a function object in terms of its argument type.

Syntax

template<typename Arg>  
    ref class logical_or  
    { // wrap operator()  
public:  
    typedef Arg first_argument_type;  
    typedef Arg second_argument_type;  
    typedef bool result_type;  
    typedef Microsoft::VisualC::StlClr::BinaryDelegate<  
        first_argument_type, second_argument_type, result_type>  
        delegate_type;  
  
    logical_or();  
    logical_or(logical_or<Arg>% right);  
  
    result_type operator()(first_argument_type left,  
        second_argument_type right);  
    operator delegate_type^();  
    };  

Parameters

Arg
The type of the arguments.

Member Functions

Type Definition Description
delegate_type The type of the generic delegate.
first_argument_type The type of the functor first argument.
result_type The type of the functor result.
second_argument_type The type of the functor second argument.
Member Description
logical_or Constructs the functor.
Operator Description
operator() Computes the desired function.
operator delegate_type^ Casts the functor to a delegate.

Remarks

The template class describes a two-argument functor. It defines the member operator operator() so that, when the object is called as a function, it returns true only if either the first argument or the second tests as true.

You can also pass the object as a function argument whose type is delegate_type^ and it will be converted appropriately.

Example

// cliext_logical_or.cpp   
// compile with: /clr   
#include <cliext/algorithm>   
#include <cliext/functional>   
#include <cliext/vector>   
  
typedef cliext::vector<int> Myvector;   
int main()   
    {   
    Myvector c1;   
    c1.push_back(2);   
    c1.push_back(0);   
    Myvector c2;   
    c2.push_back(0);   
    c2.push_back(0);   
    Myvector c3(2, 0);   
  
// display initial contents " 2 0" and " 0 0"   
    for each (int elem in c1)   
        System::Console::Write(" {0}", elem);   
    System::Console::WriteLine();   
  
    for each (int elem in c2)   
        System::Console::Write(" {0}", elem);   
    System::Console::WriteLine();   
  
// transform and display   
    cliext::transform(c1.begin(), c1.begin() + 2,   
        c2.begin(), c3.begin(), cliext::logical_or<int>());   
    for each (int elem in c3)   
        System::Console::Write(" {0}", elem);   
    System::Console::WriteLine();   
    return (0);   
    }  
  
2 0  
0 0  
1 0  

Requirements

Header: <cliext/functional>

Namespace: cliext

See Also

logical_and (STL/CLR)