Sdílet prostřednictvím


unary_negate (STL/CLR)

Popisuje šablony třídy functor, pokud je volána, vrátí logický o své uložené functor jeden argument.Umožňuje určit funkce objektu z hlediska jeho functor uložené.

template<typename Fun>
    ref class unary_negate
    { // wrap operator()
public:
    typedef Fun stored_function_type;
    typedef typename Fun::argument_type argument_type;
    typedef bool result_type;
    typedef Microsoft::VisualC::StlClr::UnaryDelegate<
        argument_type, result_type>
        delegate_type;

    unary_negate(Fun% functor);
    unary_negate(unary_negate<Fun>% right);

    result_type operator()(argument_type left);
    operator delegate_type^();
    };

Parametry

  • Zábava
    Typ uložených functor.

Členské funkce

Definice typu

Popis

argument_type

Typ argumentu functor.

delegate_type

Typ obecného delegáta.

result_type

Typ výsledku functor.

Člen

Popis

unary_negate

Konstrukce functor.

Operátor

Popis

Operator()

Vypočítá požadované funkce.

delegate_type ^

Vrhá functor pro delegáta.

Poznámky

Třída šablony popisuje functor jeden argument, který ukládá jiný jeden argument functor.Definuje operátor členské operator() tak, že když objekt se nazývá jako funkce, vrátí logický ne uložené functor nazývá argumentem.

Objekt můžete také předat jako argument funkce, jejíž typ je delegate_type^ a budou převedeny správně.

Příklad

// cliext_unary_negate.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); 
    } 
 
  

Požadavky

Záhlaví:<cliext, funkční>

Obor názvů: cliext

Viz také

Referenční dokumentace

not1 (STL/CLR)