not1 (STL/CLR)

Generates a unary_negate for a functor.

template<typename Fun>
    unary_negate<Fun> not1(Fun% functor);

Template Parameters

  • Fun
    The type of the functor.

Function Parameters

  • functor
    The functor to wrap.

Remarks

The template function returns unary_negate (STL/CLR)<Fun>(functor). You use it as a convenient way to wrap a one-argument functor in a functor that delivers its logical NOT.

Example

// cliext_not1.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(4); 
    c1.push_back(0); 
    Myvector c3(2, 0); 
 
// display initial contents " 4 0" 
    for each (int elem in c1) 
        System::Console::Write(" {0}", elem); 
    System::Console::WriteLine(); 
 
// transform and display 
    cliext::logical_not<int> not_op; 
 
    cliext::transform(c1.begin(), c1.begin() + 2, c3.begin(), 
        cliext::unary_negate<cliext::logical_not<int> >(not_op)); 
    for each (int elem in c3) 
        System::Console::Write(" {0}", elem); 
    System::Console::WriteLine(); 
 
// transform and display with function 
    cliext::transform(c1.begin(), c1.begin() + 2, c3.begin(), 
        cliext::not1(not_op)); 
    for each (int elem in c3) 
        System::Console::Write(" {0}", elem); 
    System::Console::WriteLine(); 
    return (0); 
    } 
 
 4 0
 1 0
 1 0

Requirements

Header: <cliext/functional>

Namespace: cliext

See Also

Reference

unary_negate (STL/CLR)