binder2nd (STL/CLR)
La clase de plantilla describe un functor de uno- argumento que, cuando se invoca, devuelva el functor almacenado de dos- argumento con el primer argumento proporcionado y el segundo argumento almacenado. Se utiliza especifica un objeto de función en términos de su functor almacenado.
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
- Debería
El tipo de functor almacenado.
Funciones miembro
Definición de tipo |
Descripción |
---|---|
delegate_type |
El tipo de delegado genérico. |
first_argument_type |
El tipo del primer argumento de functor. |
result_type |
El tipo de resultado de functor. |
second_argument_type |
El tipo de argumento de functor segundo. |
stored_function_type |
El tipo de functor. |
Miembro |
Descripción |
---|---|
binder2nd |
Construye el functor. |
operador ?? |
Descripción |
---|---|
operator() |
Calcula la función deseada. |
operador delegate_type^() |
Convierte el functor un delegado. |
Comentarios
La clase de plantilla describe un functor de uno- argumento que almacena un functor de dos- argumento y un segundo argumento. Define el operador operator() de miembro para que, cuando el objeto se denomina como función, devuelve el resultado de llamar al functor almacenado con el primer argumento proporcionado y el segundo argumento almacenado.
También puede pasar el objeto como argumento de la función cuyo tipo es delegate_type^ y se convierte correctamente.
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);
}
Requisitos
cliext <deEncabezado: /funcional>
cliext deEspacio de nombres: