binary_negate (STL/CLR)

La classe de modèle décrit un functor qui, lorsqu'elle est appelée, retourne l'opérateur NOT logique de son functor stocké à deux arguments.Vous utilisez spécifiez un objet de fonction en termes de son functor stocké.

template<typename Fun>
    ref class binary_negate
    { // wrap operator()
public:
    typedef Fun stored_function_type;
    typedef typename Fun::first_argument_type first_argument_type;
    typedef typename Fun::second_argument_type second_argument_type;
    typedef bool result_type;
    typedef Microsoft::VisualC::StlClr::BinaryDelegate<
        first_argument_type, second_argument_type, result_type>
        delegate_type;

    explicit binary_negate(Fun% functor);
    binary_negate(binary_negate<Arg>% right);

    result_type operator()(first_argument_type left,
        second_argument_type right);
    operator delegate_type^();
    };

Paramètres

  • Fun
    Le type du functor stocké.

Fonctions membres

Définition de type

Description

delegate_type

Le type du délégué générique.

first_argument_type

Le type du premier argument de functor.

result_type

Le type du résultat de functor.

second_argument_type

Le type de l'argument de functor deuxième.

stored_function_type

Le type du functor.

Membre

Description

binary_negate

Construit le functor.

Opérateur

Description

operator()

Calcule la fonction souhaitée.

delegate_type^ d'opérateur ()

Effectue un cast du functor à un délégué.

Notes

La classe de modèle décrit un functor à deux arguments qui enregistre un autre functor à deux arguments.Elle définit l'opérateur membre operator() afin que, lorsque l'objet est appelé comme fonction, elle retourne l'opérateur NOT logique du functor stocké appelé avec les deux arguments.

Vous pouvez également passer l'objet comme argument de fonction dont le type est delegate_type^ et il sera converti en conséquence.

Exemple

// cliext_binary_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(3); 
    Myvector c2; 
    c2.push_back(4); 
    c2.push_back(4); 
    Myvector c3(2, 0); 
 
// display initial contents " 4 3" and " 4 4" 
    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::less<int> less_op; 
 
    cliext::transform(c1.begin(), c1.begin() + 2, 
        c2.begin(), c3.begin(), 
        cliext::binary_negate<cliext::less<int> >(less_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, 
        c2.begin(), c3.begin(), cliext::not2(less_op)); 
    for each (int elem in c3) 
        System::Console::Write(" {0}", elem); 
    System::Console::WriteLine(); 
    return (0); 
    } 
 
  

Configuration requise

en-tête :<cliext/fonctionnel>

Cliext del'espace de noms :

Voir aussi

Référence

not2 (STL/CLR)