functional (STL/CLR)

Incluya el encabezado <cliext/functional> STL/CLR para definir plantillas de clase funcional y delegados y funciones de plantilla relacionadas.

Sintaxis

#include <functional>

Requisitos

Encabezado:<cliext/functional>

Espacio de nombres:cliext

Declaraciones

Delegado Descripción
binary_delegate (STL/CLR) Delegado de dos argumentos.
binary_delegate_noreturn (STL/CLR) Delegado de dos argumentos que devuelve void.
unary_delegate (STL/CLR) Delegado de un argumento.
unary_delegate_noreturn (STL/CLR) Delegado de un argumento que devuelve void.
Clase Descripción
binary_negate (STL/CLR) Functor para negar un functor de dos argumentos.
binder1st (STL/CLR) Functor para enlazar el primer argumento a un functor de dos argumentos.
binder2nd (STL/CLR) Functor para enlazar el segundo argumento a un functor de dos argumentos.
divides (STL/CLR) Functor de división.
equal_to (STL/CLR) Functor de comparación igual.
greater (STL/CLR) Functor de comparación mayor.
greater_equal (STL/CLR) Functor de comparación mayor o igual.
less (STL/CLR) Functor de comparación menor.
less_equal (STL/CLR) Functor de comparación menor o igual.
logical_and (STL/CLR) Functor lógico AND.
logical_not (STL/CLR) Functor lógico NOT.
logical_or (STL/CLR) Functor lógico OR.
minus (STL/CLR) Functor de resta.
modulus (STL/CLR) Functor de módulo.
multiplies (STL/CLR) Functor de multiplicación.
negate (STL/CLR) Functor para devolver su argumento negado.
not_equal_to (STL/CLR) Functor de comparación no igual.
plus (STL/CLR) Functor de suma.
unary_negate (STL/CLR) Functor para negar un functor de un argumento.
Función Descripción
bind1st (STL/CLR) Genera un binder1st para un argumento y un functor.
bind2nd (STL/CLR) Genera un binder2nd para un argumento y un functor.
not1 (STL/CLR) Genera un unary_negate para un functor.
not2 (STL/CLR) Genera un binary_negate para un functor.

Miembros

binary_delegate (STL/CLR)

La clase genérica describe un delegado de dos argumentos. Se usa para especificar un delegado en términos de sus tipos de argumento y valor devuelto.

Sintaxis

generic<typename Arg1,
    typename Arg2,
    typename Result>
    delegate Result binary_delegate(Arg1, Arg2);

Parámetros

Arg1
Tipo del primer argumento.

Arg2
Tipo del segundo argumento.

Result
Tipo de valor devuelto.

Comentarios

El delegado genérico describe una función de dos argumentos.

En estas plantillas de función:

binary_delegate<int, int, int> Fun1;

binary_delegate<int, int, int> Fun2;

los tipos Fun1 y Fun2 son sinónimos, mientras que para:

delegate int Fun1(int, int);

delegate int Fun2(int, int);

no son del mismo tipo.

Ejemplo

// cliext_binary_delegate.cpp
// compile with: /clr
#include <cliext/functional>

bool key_compare(wchar_t left, wchar_t right)
    {
    return (left < right);
    }

typedef cliext::binary_delegate<wchar_t, wchar_t, bool> Mydelegate;
int main()
    {
    Mydelegate^ kcomp = gcnew Mydelegate(&key_compare);

    System::Console::WriteLine("compare(L'a', L'a') = {0}",
        kcomp(L'a', L'a'));
    System::Console::WriteLine("compare(L'a', L'b') = {0}",
        kcomp(L'a', L'b'));
    System::Console::WriteLine("compare(L'b', L'a') = {0}",
        kcomp(L'b', L'a'));
    System::Console::WriteLine();
    return (0);
    }
compare(L'a', L'a') = False
compare(L'a', L'b') = True
compare(L'b', L'a') = False

binary_delegate_noreturn (STL/CLR)

La clase genérica describe un delegado de dos argumentos que devuelve void. Se usa para especificar un delegado en términos de su argumento.

Sintaxis

generic<typename Arg1,
    typename Arg2>
    delegate void binary_delegate(Arg1, Arg2);

Parámetros

Arg1
Tipo del primer argumento.

Arg2
Tipo del segundo argumento.

Comentarios

El delegado genérico describe una función de dos argumentos que devuelve void.

En estas plantillas de función:

binary_delegate_noreturn<int, int> Fun1;

binary_delegate_noreturn<int, int> Fun2;

los tipos Fun1 y Fun2 son sinónimos, mientras que para:

delegate void Fun1(int, int);

delegate void Fun2(int, int);

no son del mismo tipo.

Ejemplo

// cliext_binary_delegate_noreturn.cpp
// compile with: /clr
#include <cliext/functional>

void key_compare(wchar_t left, wchar_t right)
    {
    System::Console::WriteLine("compare({0}, {1}) = {2}",
        left, right, left < right);
    }

typedef cliext::binary_delegate_noreturn<wchar_t, wchar_t> Mydelegate;
int main()
    {
    Mydelegate^ kcomp = gcnew Mydelegate(&key_compare);

    kcomp(L'a', L'a');
    kcomp(L'a', L'b');
    kcomp(L'b', L'a');
    System::Console::WriteLine();
    return (0);
    }
compare(a, a) = False
compare(a, b) = True
compare(b, a) = False

binary_negate (STL/CLR)

La clase de plantilla describe un functor que, cuando se le llama, devuelve el operador NOT lógico de su functor almacenado de dos argumentos. Se usa para especificar un objeto de función en términos de su functor almacenado.

Sintaxis

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^();
    };

Parámetros

Fun
Tipo del functor almacenado.

Funciones de miembro

Definición de tipo Descripción
delegate_type Tipo del delegado genérico.
first_argument_type Tipo del primer argumento del functor.
result_type Tipo del resultado del functor.
second_argument_type Tipo del segundo argumento del functor.
stored_function_type Tipo del functor.
Miembro Descripción
binary_negate Construye el functor.
Operator Descripción
operator() Calcula la función deseada.
operator delegate_type^() Convierte el functor en un delegado.

Comentarios

La clase de plantilla describe un functor de dos argumentos que almacena otro functor de dos argumentos. Define el operador miembro operator() para que, cuando se llame al objeto como función, devuelva el operador NOT lógico del functor almacenado llamado con los dos argumentos.

También puede pasar el objeto como un argumento de función cuyo tipo es delegate_type^ y se convertirá adecuadamente.

Ejemplo

// 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);
    }
4 3
4 4
1 0
1 0

bind1st (STL/CLR)

Genera binder1st para un argumento y un functor.

Sintaxis

template<typename Fun,
    typename Arg>
    binder1st<Fun> bind1st(Fun% functor,
        Arg left);

Parámetros de plantilla

Arg
Tipo del argumento.

Fun
Tipo del functor.

Parámetros de la función

functor
Functor que se va a encapsular.

left
Primer argumento para encapsular.

Comentarios

La plantilla de función devuelve binder1st<Fun>(functor, left). Se usa como una manera cómoda de encapsular un functor de dos argumentos y su primer argumento en un functor de un solo argumento que lo llama con un segundo argumento.

Ejemplo

// cliext_bind1st.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 c3(2, 0);

// display initial contents " 4 3"
    for each (int elem in c1)
        System::Console::Write(" {0}", elem);
    System::Console::WriteLine();

// transform and display
    cliext::minus<int> sub_op;
    cliext::binder1st<cliext::minus<int> > subfrom3(sub_op, 3);

    cliext::transform(c1.begin(), c1.begin() + 2, c3.begin(),
        subfrom3);
    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(),
        bind1st(sub_op, 3));
    for each (int elem in c3)
        System::Console::Write(" {0}", elem);
    System::Console::WriteLine();
    return (0);
    }
4 3
-1 0
-1 0

bind2nd (STL/CLR)

Genera binder2nd para un argumento y un functor.

Sintaxis

template<typename Fun,
    typename Arg>
    binder2nd<Fun> bind2nd(Fun% functor,
        Arg right);

Parámetros de plantilla

Arg
Tipo del argumento.

Fun
Tipo del functor.

Parámetros de la función

functor
Functor que se va a encapsular.

right
Segundo argumento para encapsular.

Comentarios

La plantilla de función devuelve binder2nd<Fun>(functor, right). Se usa como una manera cómoda de encapsular un functor de dos argumentos y su segundo argumento en un functor de un solo argumento que lo llama con un primer argumento.

Ejemplo

// cliext_bind2nd.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 c3(2, 0);

// display initial contents " 4 3"
    for each (int elem in c1)
        System::Console::Write(" {0}", elem);
    System::Console::WriteLine();

// transform and display
    cliext::minus<int> sub_op;
    cliext::binder2nd<cliext::minus<int> > sub4(sub_op, 4);

    cliext::transform(c1.begin(), c1.begin() + 2, c3.begin(),
        sub4);
    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(),
        bind2nd(sub_op, 4));
    for each (int elem in c3)
        System::Console::Write(" {0}", elem);
    System::Console::WriteLine();
    return (0);
    }
4 3
0 -1
0 -1

binder1st (STL/CLR)

La clase de plantilla describe un functor de un argumento que, cuando se le llama, devuelve su functor almacenado de dos argumentos al que se llama con su primer argumento almacenado y el segundo argumento proporcionado. Se usa para especificar un objeto de función en términos de su functor almacenado.

Sintaxis

template<typename Fun>
    ref class binder1st
    { // 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 typename Fun:result_type result_type;
    typedef Microsoft::VisualC::StlClr::UnaryDelegate<
        second_argument_type, result_type>
        delegate_type;

    binder1st(Fun% functor, first_argument_type left);
    binder1st(binder1st<Arg>% right);

    result_type operator()(second_argument_type right);
    operator delegate_type^();
    };

Parámetros

Fun
Tipo del functor almacenado.

Funciones de miembro

Definición de tipo Descripción
delegate_type Tipo del delegado genérico.
first_argument_type Tipo del primer argumento del functor.
result_type Tipo del resultado del functor.
second_argument_type Tipo del segundo argumento del functor.
stored_function_type Tipo del functor.
Miembro Descripción
binder1st Construye el functor.
Operator Descripción
operator() Calcula la función deseada.
operator delegate_type^() Convierte el functor en un delegado.

Comentarios

La clase de plantilla describe un functor de un solo argumento que almacena un functor de dos argumentos y un primer argumento. Define el operador miembro operator() de modo que, cuando se llama al objeto como una función, devuelve el resultado de llamar al functor almacenado con el primer argumento almacenado y el segundo argumento proporcionado.

También puede pasar el objeto como un argumento de función cuyo tipo es delegate_type^ y se convertirá adecuadamente.

Ejemplo

// cliext_binder1st.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 c3(2, 0);

// display initial contents " 4 3"
    for each (int elem in c1)
        System::Console::Write(" {0}", elem);
    System::Console::WriteLine();

// transform and display
    cliext::minus<int> sub_op;
    cliext::binder1st<cliext::minus<int> > subfrom3(sub_op, 3);

    cliext::transform(c1.begin(), c1.begin() + 2, c3.begin(),
        subfrom3);
    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(),
        bind1st(sub_op, 3));
    for each (int elem in c3)
        System::Console::Write(" {0}", elem);
    System::Console::WriteLine();
    return (0);
    }
4 3
-1 0
-1 0

binder2nd (STL/CLR)

La clase de plantilla describe un functor de un argumento que, cuando se le llama, devuelve su functor almacenado de dos argumentos llamado con el primer argumento proporcionado y su segundo argumento almacenado. Se usa para especificar un objeto de función en términos de su functor almacenado.

Sintaxis

template<typename Fun>
    ref class binder2nd
    { // 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 typename Fun:result_type result_type;
    typedef Microsoft::VisualC::StlClr::UnaryDelegate<
        first_argument_type, result_type>
        delegate_type;

    binder2nd(Fun% functor, second_argument_type left);
    binder2nd(binder2nd<Arg>% right);

    result_type operator()(first_argument_type right);
    operator delegate_type^();
    };

Parámetros

Fun
Tipo del functor almacenado.

Funciones de miembro

Definición de tipo Descripción
delegate_type Tipo del delegado genérico.
first_argument_type Tipo del primer argumento del functor.
result_type Tipo del resultado del functor.
second_argument_type Tipo del segundo argumento del functor.
stored_function_type Tipo del functor.
Miembro Descripción
binder2nd Construye el functor.
Operator Descripción
operator() Calcula la función deseada.
operator delegate_type^() Convierte el functor en un delegado.

Comentarios

La clase de plantilla describe un functor de un solo argumento que almacena un functor de dos argumentos y un segundo argumento. Define el operador miembro operator() para que, cuando se llame al objeto como una función, devuelva el resultado de llamar al functor almacenado con el primer argumento proporcionado y el segundo argumento almacenado.

También puede pasar el objeto como un argumento de función cuyo tipo es delegate_type^ y se convertirá adecuadamente.

Ejemplo

// cliext_binder2nd.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 c3(2, 0);

// display initial contents " 4 3"
    for each (int elem in c1)
        System::Console::Write(" {0}", elem);
    System::Console::WriteLine();

// transform and display
    cliext::minus<int> sub_op;
    cliext::binder2nd<cliext::minus<int> > sub4(sub_op, 4);

    cliext::transform(c1.begin(), c1.begin() + 2, c3.begin(),
        sub4);
    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(),
        bind2nd(sub_op, 4));
    for each (int elem in c3)
        System::Console::Write(" {0}", elem);
    System::Console::WriteLine();
    return (0);
    }
4 3
0 -1
0 -1

divides (STL/CLR)

La clase de plantilla describe un functor que, cuando se le llama, devuelve el primer argumento dividido por el segundo. Se usa para especificar un objeto de función en términos de su tipo de argumento.

Sintaxis

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

    divides();
    divides(divides<Arg>% right);

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

Parámetros

Arg
Tipo de argumentos y valor devuelto.

Funciones de miembro

Definición de tipo Descripción
delegate_type Tipo del delegado genérico.
first_argument_type Tipo del primer argumento del functor.
result_type Tipo del resultado del functor.
second_argument_type Tipo del segundo argumento del functor.
Miembro Descripción
divides Construye el functor.
Operator Descripción
operator() Calcula la función deseada.
operator delegate_type^() Convierte el functor en un delegado.

Comentarios

La clase de plantilla describe un functor de dos argumentos. Define el operador miembro operator() para que, cuando se llame al objeto como una función, devuelva el primer argumento dividido por el segundo.

También puede pasar el objeto como un argumento de función cuyo tipo es delegate_type^ y se convertirá adecuadamente.

Ejemplo

// cliext_divides.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(2);
    c2.push_back(1);
    Myvector c3(2, 0);

// display initial contents " 4 3" and " 2 1"
    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::divides<int>());
    for each (int elem in c3)
        System::Console::Write(" {0}", elem);
    System::Console::WriteLine();
    return (0);
    }
4 3
2 1
2 3

equal_to (STL/CLR)

La clase de plantilla describe un functor que, cuando se le llama, devuelve un valor true solo si el primer argumento es igual al segundo. Se usa para especificar un objeto de función en términos de su tipo de argumento.

Sintaxis

template<typename Arg>
    ref class equal_to
    { // 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;

    equal_to();
    equal_to(equal_to<Arg>% right);

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

Parámetros

Arg
Tipo de los argumentos.

Funciones de miembro

Definición de tipo Descripción
delegate_type Tipo del delegado genérico.
first_argument_type Tipo del primer argumento del functor.
result_type Tipo del resultado del functor.
second_argument_type Tipo del segundo argumento del functor.
Miembro Descripción
equal_to Construye el functor.
Operator Descripción
operator() Calcula la función deseada.
operator delegate_type^() Convierte el functor en un delegado.

Comentarios

La clase de plantilla describe un functor de dos argumentos. Define el operador miembro operator() de modo que, cuando se llama al objeto como una función, devuelve true solo si el primer argumento es igual al segundo.

También puede pasar el objeto como un argumento de función cuyo tipo es delegate_type^ y se convertirá adecuadamente.

Ejemplo

// cliext_equal_to.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::transform(c1.begin(), c1.begin() + 2,
        c2.begin(), c3.begin(), cliext::equal_to<int>());
    for each (int elem in c3)
        System::Console::Write(" {0}", elem);
    System::Console::WriteLine();
    return (0);
    }
4 3
4 4
1 0

greater (STL/CLR)

La clase de plantilla describe un functor que, cuando se le llama, devuelve true solo si el primer argumento es mayor que el segundo. Se usa para especificar un objeto de función en términos de su tipo de argumento.

Sintaxis

template<typename Arg>
    ref class greater
    { // 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;

    greater();
    greater(greater<Arg>% right);

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

Parámetros

Arg
Tipo de los argumentos.

Funciones de miembro

Definición de tipo Descripción
delegate_type Tipo del delegado genérico.
first_argument_type Tipo del primer argumento del functor.
result_type Tipo del resultado del functor.
second_argument_type Tipo del segundo argumento del functor.
Miembro Descripción
greater Construye el functor.
Operator Descripción
operator() Calcula la función deseada.
operator delegate_type^ Convierte el functor en un delegado.

Comentarios

La clase de plantilla describe un functor de dos argumentos. Define el operador operator() miembro para que, cuando se llame al objeto como una función, devuelve true solo si el primer argumento es mayor que el segundo.

También puede pasar el objeto como un argumento de función cuyo tipo es delegate_type^ y se convertirá adecuadamente.

Ejemplo

// cliext_greater.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(3);
    c2.push_back(3);
    Myvector c3(2, 0);

// display initial contents " 4 3" and " 3 3"
    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::greater<int>());
    for each (int elem in c3)
        System::Console::Write(" {0}", elem);
    System::Console::WriteLine();
    return (0);
    }
4 3
3 3
1 0

greater_equal (STL/CLR)

La clase de plantilla describe un functor que, cuando se le llama, devuelve true solo si el primer argumento es mayor o igual que el segundo. Se usa para especificar un objeto de función en términos de su tipo de argumento.

Sintaxis

template<typename Arg>
    ref class greater_equal
    { // 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;

    greater_equal();
    greater_equal(greater_equal<Arg>% right);

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

Parámetros

Arg
Tipo de los argumentos.

Funciones de miembro

Definición de tipo Descripción
delegate_type Tipo del delegado genérico.
first_argument_type Tipo del primer argumento del functor.
result_type Tipo del resultado del functor.
second_argument_type Tipo del segundo argumento del functor.
Miembro Descripción
greater_equal Construye el functor.
Operator Descripción
operator() Calcula la función deseada.
operator delegate_type^ Convierte el functor en un delegado.

Comentarios

La clase de plantilla describe un functor de dos argumentos. Define el operador miembro operator() de modo que, cuando se llama al objeto como una función, devuelve true solo si el primer argumento es mayor o igual que el segundo.

También puede pasar el objeto como un argumento de función cuyo tipo es delegate_type^ y se convertirá adecuadamente.

Ejemplo

// cliext_greater_equal.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::transform(c1.begin(), c1.begin() + 2,
        c2.begin(), c3.begin(), cliext::greater_equal<int>());
    for each (int elem in c3)
        System::Console::Write(" {0}", elem);
    System::Console::WriteLine();
    return (0);
    }
4 3
4 4
1 0

less (STL/CLR)

La clase de plantilla describe un functor que, cuando se le llama, devuelve true solo si el primer argumento es menor que el segundo. Se usa para especificar un objeto de función en términos de su tipo de argumento.

Sintaxis

template<typename Arg>
    ref class less
    { // 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;

    less();
    less(less<Arg>% right);

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

Parámetros

Arg
Tipo de los argumentos.

Funciones de miembro

Definición de tipo Descripción
delegate_type Tipo del delegado genérico.
first_argument_type Tipo del primer argumento del functor.
result_type Tipo del resultado del functor.
second_argument_type Tipo del segundo argumento del functor.
Miembro Descripción
less Construye el functor.
Operator Descripción
operator() Calcula la función deseada.
operator delegate_type^ Convierte el functor en un delegado.

Comentarios

La clase de plantilla describe un functor de dos argumentos. Define el operador miembro operator() de modo que, cuando se llama al objeto como una función, devuelve true solo si el primer argumento es menor que el segundo.

También puede pasar el objeto como un argumento de función cuyo tipo es delegate_type^ y se convertirá adecuadamente.

Ejemplo

// cliext_less.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::transform(c1.begin(), c1.begin() + 2,
        c2.begin(), c3.begin(), cliext::less<int>());
    for each (int elem in c3)
        System::Console::Write(" {0}", elem);
    System::Console::WriteLine();
    return (0);
    }
4 3
4 4
0 1

less_equal (STL/CLR)

La clase de plantilla describe un functor que, cuando se le llama, devuelve true solo si el primer argumento es menor o igual que el segundo. Se usa para especificar un objeto de función en términos de su tipo de argumento.

Sintaxis

template<typename Arg>
    ref class less_equal
    { // 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;

    less_equal();
    less_equal(less_equal<Arg>% right);

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

Parámetros

Arg
Tipo de los argumentos.

Funciones de miembro

Definición de tipo Descripción
delegate_type Tipo del delegado genérico.
first_argument_type Tipo del primer argumento del functor.
result_type Tipo del resultado del functor.
second_argument_type Tipo del segundo argumento del functor.
Miembro Descripción
less_equal Construye el functor.
Operator Descripción
operator() Calcula la función deseada.
operator delegate_type^ Convierte el functor en un delegado.

Comentarios

La clase de plantilla describe un functor de dos argumentos. Define el operador miembro operator() de modo que, cuando se llama al objeto como una función, devuelve true solo si el primer argumento es menor o igual que el segundo.

También puede pasar el objeto como un argumento de función cuyo tipo es delegate_type^ y se convertirá adecuadamente.

Ejemplo

// cliext_less_equal.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(3);
    c2.push_back(3);
    Myvector c3(2, 0);

// display initial contents " 4 3" and " 3 3"
    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::less_equal<int>());
    for each (int elem in c3)
        System::Console::Write(" {0}", elem);
    System::Console::WriteLine();
    return (0);
    }
4 3
3 3
0 1

logical_and (STL/CLR)

La clase de plantilla describe un functor que, cuando se le llama, devuelve true solo si tanto el primer argumento como el segundo son true. Se usa para especificar un objeto de función en términos de su tipo de argumento.

Sintaxis

template<typename Arg>
    ref class logical_and
    { // 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_and();
    logical_and(logical_and<Arg>% right);

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

Parámetros

Arg
Tipo de los argumentos.

Funciones de miembro

Definición de tipo Descripción
delegate_type Tipo del delegado genérico.
first_argument_type Tipo del primer argumento del functor.
result_type Tipo del resultado del functor.
second_argument_type Tipo del segundo argumento del functor.
Miembro Descripción
logical_and Construye el functor.
Operator Descripción
operator() Calcula la función deseada.
operator delegate_type^ Convierte el functor en un delegado.

Comentarios

La clase de plantilla describe un functor de dos argumentos. Define el operador miembro operator() de modo que, cuando se llama al objeto como una función, devuelve true solo si tanto el primer argumento como el segundo son true.

También puede pasar el objeto como un argumento de función cuyo tipo es delegate_type^ y se convertirá adecuadamente.

Ejemplo

// cliext_logical_and.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(3);
    c2.push_back(0);
    Myvector c3(2, 0);

// display initial contents " 1 0" and " 1 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_and<int>());
    for each (int elem in c3)
        System::Console::Write(" {0}", elem);
    System::Console::WriteLine();
    return (0);
    }
2 0
3 0
1 0

logical_not (STL/CLR)

La clase de plantilla describe un functor que, cuando se le llama, devuelve true solo si alguno de sus argumentos resulta false. Se usa para especificar un objeto de función en términos de su tipo de argumento.

Sintaxis

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

    logical_not();
    logical_not(logical_not<Arg> %right);

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

Parámetros

Arg
Tipo de los argumentos.

Funciones de miembro

Definición de tipo Descripción
argument_type Tipo del argumento del functor.
delegate_type Tipo del delegado genérico.
result_type Tipo del resultado del functor.
Miembro Descripción
logical_not Construye el functor.
Operator Descripción
operator() Calcula la función deseada.
operator delegate_type^ Convierte el functor en un delegado.

Comentarios

La clase de plantilla describe un functor de un argumento. Define el operador miembro operator() de modo que, cuando se llama al objeto como una función, devuelve true solo si su argumento resulta false.

También puede pasar el objeto como un argumento de función cuyo tipo es delegate_type^ y se convertirá adecuadamente.

Ejemplo

// cliext_logical_not.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::transform(c1.begin(), c1.begin() + 2,
        c3.begin(), cliext::logical_not<int>());
    for each (int elem in c3)
        System::Console::Write(" {0}", elem);
    System::Console::WriteLine();
    return (0);
    }
4 0
0 1

logical_or (STL/CLR)

La clase de plantilla describe un functor que, cuando se le llama, devuelve true solo si el primer argumento o el segundo resulta true. Se usa para especificar un objeto de función en términos de su tipo de argumento.

Sintaxis

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^();
    };

Parámetros

Arg
Tipo de los argumentos.

Funciones de miembro

Definición de tipo Descripción
delegate_type Tipo del delegado genérico.
first_argument_type Tipo del primer argumento del functor.
result_type Tipo del resultado del functor.
second_argument_type Tipo del segundo argumento del functor.
Miembro Descripción
logical_or Construye el functor.
Operator Descripción
operator() Calcula la función deseada.
operator delegate_type^ Convierte el functor en un delegado.

Comentarios

La clase de plantilla describe un functor de dos argumentos. Define el operador miembro operator() de modo que, cuando se llama al objeto como una función, devuelve true solo si el primer argumento o el segundo resultan true.

También puede pasar el objeto como un argumento de función cuyo tipo es delegate_type^ y se convertirá adecuadamente.

Ejemplo

// 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

minus (STL/CLR)

La clase de plantilla describe un functor que, cuando se le llama, devuelve el primer argumento menos el segundo. Se usa para especificar un objeto de función en términos de su tipo de argumento.

Sintaxis

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

    minus();
    minus(minus<Arg>% right);

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

Parámetros

Arg
Tipo de argumentos y valor devuelto.

Funciones de miembro

Definición de tipo Descripción
delegate_type Tipo del delegado genérico.
first_argument_type Tipo del primer argumento del functor.
result_type Tipo del resultado del functor.
second_argument_type Tipo del segundo argumento del functor.
Miembro Descripción
minus Construye el functor.
Operator Descripción
operator() Calcula la función deseada.
operator delegate_type^ Convierte el functor en un delegado.

Comentarios

La clase de plantilla describe un functor de dos argumentos. Define el operador miembro operator() para que, cuando se llame al objeto como una función, devuelva el primer argumento menos el segundo.

También puede pasar el objeto como un argumento de función cuyo tipo es delegate_type^ y se convertirá adecuadamente.

Ejemplo

// cliext_minus.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(2);
    c2.push_back(1);
    Myvector c3(2, 0);

// display initial contents " 4 3" and " 2 1"
    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::minus<int>());
    for each (int elem in c3)
        System::Console::Write(" {0}", elem);
    System::Console::WriteLine();
    return (0);
    }
4 3
2 1
2 2

modulus (STL/CLR)

La clase de plantilla describe un functor que, cuando se le llama, devuelve el primer argumento aplicando operación módulo al segundo. Se usa para especificar un objeto de función en términos de su tipo de argumento.

Sintaxis

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

    modulus();
    modulus(modulus<Arg>% right);

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

Parámetros

Arg
Tipo de argumentos y valor devuelto.

Funciones de miembro

Definición de tipo Descripción
delegate_type Tipo del delegado genérico.
first_argument_type Tipo del primer argumento del functor.
result_type Tipo del resultado del functor.
second_argument_type Tipo del segundo argumento del functor.
Miembro Descripción
modulus Construye el functor.
Operator Descripción
operator() Calcula la función deseada.
operator delegate_type^ Convierte el functor en un delegado.

Comentarios

La clase de plantilla describe un functor de dos argumentos. Define el operador miembro operator() para que, cuando se llame al objeto como una función, devuelva el primer argumento aplicando operación módulo al segundo.

También puede pasar el objeto como un argumento de función cuyo tipo es delegate_type^ y se convertirá adecuadamente.

Ejemplo

// cliext_modulus.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(2);
    Myvector c2;
    c2.push_back(3);
    c2.push_back(1);
    Myvector c3(2, 0);

// display initial contents " 4 2" and " 3 1"
    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::modulus<int>());
    for each (int elem in c3)
        System::Console::Write(" {0}", elem);
    System::Console::WriteLine();
    return (0);
    }
4 2
3 1
1 0

multiplies (STL/CLR)

La clase de plantilla describe un functor que, cuando se le llama, devuelve el primer argumento por el segundo. Se usa para especificar un objeto de función en términos de su tipo de argumento.

Sintaxis

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

    multiplies();
    multiplies(multiplies<Arg>% right);

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

Parámetros

Arg
Tipo de argumentos y valor devuelto.

Funciones de miembro

Definición de tipo Descripción
delegate_type Tipo del delegado genérico.
first_argument_type Tipo del primer argumento del functor.
result_type Tipo del resultado del functor.
second_argument_type Tipo del segundo argumento del functor.
Miembro Descripción
multiplies Construye el functor.
Operator Descripción
operator() Calcula la función deseada.
operator delegate_type^ Convierte el functor en un delegado.

Comentarios

La clase de plantilla describe un functor de dos argumentos. Define el operador miembro operator() para que, cuando se llame al objeto como una función, devuelva el primer argumento por el segundo.

También puede pasar el objeto como un argumento de función cuyo tipo es delegate_type^ y se convertirá adecuadamente.

Ejemplo

// cliext_multiplies.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(2);
    c2.push_back(1);
    Myvector c3(2, 0);

// display initial contents " 4 3" and " 2 1"
    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::multiplies<int>());
    for each (int elem in c3)
        System::Console::Write(" {0}", elem);
    System::Console::WriteLine();
    return (0);
    }
4 3
2 1
8 3

negate (STL/CLR)

La clase de plantilla describe un functor que, cuando se le llama, devuelve su argumento negado. Se usa para especificar un objeto de función en términos de su tipo de argumento.

Sintaxis

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

    negate();
    negate(negate<Arg>% right);

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

Parámetros

Arg
Tipo de los argumentos.

Funciones de miembro

Definición de tipo Descripción
argument_type Tipo del argumento del functor.
delegate_type Tipo del delegado genérico.
result_type Tipo del resultado del functor.
Miembro Descripción
negate Construye el functor.
Operator Descripción
operator() Calcula la función deseada.
operator delegate_type^ Convierte el functor en un delegado.

Comentarios

La clase de plantilla describe un functor de un argumento. Define el operador miembro operator() de modo que, cuando se llama al objeto como una función, devuelve el argumento negado.

También puede pasar el objeto como un argumento de función cuyo tipo es delegate_type^ y se convertirá adecuadamente.

Ejemplo

// cliext_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 c3(2, 0);

// display initial contents " 4 -3"
    for each (int elem in c1)
        System::Console::Write(" {0}", elem);
    System::Console::WriteLine();

// transform and display
    cliext::transform(c1.begin(), c1.begin() + 2,
        c3.begin(), cliext::negate<int>());
    for each (int elem in c3)
        System::Console::Write(" {0}", elem);
    System::Console::WriteLine();
    return (0);
    }
4 -3
-4 3

not_equal_to (STL/CLR)

La clase de plantilla describe un functor que, cuando se llama, devuelve true solo si el primer argumento no es igual al segundo. Se usa para especificar un objeto de función en términos de su tipo de argumento.

Sintaxis

template<typename Arg>
    ref class not_equal_to
    { // 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;

    not_equal_to();
    not_equal_to(not_equal_to<Arg>% right);

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

Parámetros

Arg
Tipo de los argumentos.

Funciones de miembro

Definición de tipo Descripción
delegate_type Tipo del delegado genérico.
first_argument_type Tipo del primer argumento del functor.
result_type Tipo del resultado del functor.
second_argument_type Tipo del segundo argumento del functor.
Miembro Descripción
not_equal_to Construye el functor.
Operator Descripción
operator() Calcula la función deseada.
operator delegate_type^ Convierte el functor en un delegado.

Comentarios

La clase de plantilla describe un functor de dos argumentos. Define el operador operator() miembro de modo que, cuando se llama al objeto como una función, devuelve true solo si el primer argumento no es igual al segundo.

También puede pasar el objeto como un argumento de función cuyo tipo es delegate_type^ y se convertirá adecuadamente.

Ejemplo

// cliext_not_equal_to.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::transform(c1.begin(), c1.begin() + 2,
        c2.begin(), c3.begin(), cliext::not_equal_to<int>());
    for each (int elem in c3)
        System::Console::Write(" {0}", elem);
    System::Console::WriteLine();
    return (0);
    }
4 3
4 4
0 1

not1 (STL/CLR)

Genera unary_negate para un functor.

Sintaxis

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

Parámetros de plantilla

Fun
Tipo del functor.

Parámetros de la función

functor
Functor que se va a encapsular.

Comentarios

La plantilla de función devuelve unary_negate<Fun>(functor). Se usa como una manera cómoda de encapsular un functor de un argumento en un functor que distribuye su operador NOT lógico.

Ejemplo

// 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

not2 (STL/CLR)

Genera binary_negate para un functor.

Sintaxis

template<typename Fun>
    binary_negate<Fun> not2(Fun% functor);

Parámetros de plantilla

Fun
Tipo del functor.

Parámetros de la función

functor
Functor que se va a encapsular.

Comentarios

La plantilla de función devuelve binary_negate<Fun>(functor). Se usa como una manera cómoda de encapsular un functor de dos argumentos en un functor que distribuye su operador NOT lógico.

Ejemplo

// cliext_not2.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);
    }
4 3
4 4
1 0
1 0

plus (STL/CLR)

La clase de plantilla describe un functor que, cuando se le llama, devuelve el primer argumento más el segundo. Se usa para especificar un objeto de función en términos de su tipo de argumento.

Sintaxis

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

    plus();
    plus(plus<Arg>% right);

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

Parámetros

Arg
Tipo de argumentos y valor devuelto.

Funciones de miembro

Definición de tipo Descripción
delegate_type Tipo del delegado genérico.
first_argument_type Tipo del primer argumento del functor.
result_type Tipo del resultado del functor.
second_argument_type Tipo del segundo argumento del functor.
Miembro Descripción
plus Construye el functor.
Operator Descripción
operator() Calcula la función deseada.
operator delegate_type^ Convierte el functor en un delegado.

Comentarios

La clase de plantilla describe un functor de dos argumentos. Define el operador miembro operator() para que, cuando se llame al objeto como una función, devuelva el primer argumento más el segundo.

También puede pasar el objeto como un argumento de función cuyo tipo es delegate_type^ y se convertirá adecuadamente.

Ejemplo

// cliext_plus.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(2);
    c2.push_back(1);
    Myvector c3(2, 0);

// display initial contents " 4 3" and " 2 1"
    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::plus<int>());
    for each (int elem in c3)
        System::Console::Write(" {0}", elem);
    System::Console::WriteLine();
    return (0);
    }
4 3
2 1
6 4

unary_delegate (STL/CLR)

La clase genérica describe un delegado de un argumento. Se usa para especificar un delegado en términos de sus tipos de argumento y valor devuelto.

Sintaxis

generic<typename Arg,
    typename Result>
    delegate Result unary_delegate(Arg);

Parámetros

Arg
Tipo del argumento.

Result
Tipo de valor devuelto.

Comentarios

El delegado genérico describe una función de un argumento.

En estas plantillas de función:

unary_delegate<int, int> Fun1;

unary_delegate<int, int> Fun2;

los tipos Fun1 y Fun2 son sinónimos, mientras que para:

delegate int Fun1(int);

delegate int Fun2(int);

no son del mismo tipo.

Ejemplo

// cliext_unary_delegate.cpp
// compile with: /clr
#include <cliext/functional>

int hash_val(wchar_t val)
    {
    return ((val * 17 + 31) % 67);
    }

typedef cliext::unary_delegate<wchar_t, int> Mydelegate;
int main()
    {
    Mydelegate^ myhash = gcnew Mydelegate(&hash_val);

    System::Console::WriteLine("hash(L'a') = {0}", myhash(L'a'));
    System::Console::WriteLine("hash(L'b') = {0}", myhash(L'b'));
    return (0);
    }
hash(L'a') = 5
hash(L'b') = 22

unary_delegate_noreturn (STL/CLR)

La clase genérica describe un delegado de un argumento que devuelve void. Se usa para especificar un delegado en términos de su tipo de argumento.

Sintaxis

generic<typename Arg>
    delegate void unary_delegate_noreturn(Arg);

Parámetros

Arg
Tipo del argumento.

Comentarios

El delegado genérico describe una función de un argumento que devuelve void.

En estas plantillas de función:

unary_delegate_noreturn<int> Fun1;

unary_delegate_noreturn<int> Fun2;

los tipos Fun1 y Fun2 son sinónimos, mientras que para:

delegate void Fun1(int);

delegate void Fun2(int);

no son del mismo tipo.

Ejemplo

// cliext_unary_delegate_noreturn.cpp
// compile with: /clr
#include <cliext/functional>

void hash_val(wchar_t val)
    {
    System::Console::WriteLine("hash({0}) = {1}",
       val, (val * 17 + 31) % 67);
    }

typedef cliext::unary_delegate_noreturn<wchar_t> Mydelegate;
int main()
    {
    Mydelegate^ myhash = gcnew Mydelegate(&hash_val);

    myhash(L'a');
    myhash(L'b');
    return (0);
    }
hash(a) = 5
hash(b) = 22

unary_negate (STL/CLR)

La clase de plantilla describe un functor que, cuando se le llama, devuelve el operador NOT lógico de su functor almacenado de un argumento. Se usa para especificar un objeto de función en términos de su functor almacenado.

Sintaxis

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^();
    };

Parámetros

Fun
Tipo del functor almacenado.

Funciones de miembro

Definición de tipo Descripción
argument_type Tipo del argumento del functor.
delegate_type Tipo del delegado genérico.
result_type Tipo del resultado del functor.
Miembro Descripción
unary_negate Construye el functor.
Operator Descripción
operator() Calcula la función deseada.
delegate_type^ Convierte el functor en un delegado.

Comentarios

La clase de plantilla describe un functor de un argumento que almacena otro functor de un argumento. Define el operador miembro operator() para que, cuando se llame al objeto como función, devuelva el operador NOT lógico del functor almacenado llamado con el argumento.

También puede pasar el objeto como un argumento de función cuyo tipo es delegate_type^ y se convertirá adecuadamente.

Ejemplo

// 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);
    }
4 0
1 0
1 0