binder1st (STL/CLR)
Popisuje šablony třídy functor jeden argument, pokud je volána, vrátí jeho uložené dvě argument functor volána s jeho uložené první a zadané druhého argumentu.Umožňuje určit funkce objektu z hlediska jeho functor uložené.
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^();
};
Parametry
- Zábava
Typ uložených functor.
Členské funkce
Definice typu |
Popis |
---|---|
delegate_type |
Typ obecného delegáta. |
first_argument_type |
Typ první argument functor. |
result_type |
Typ výsledku functor. |
second_argument_type |
Typ functor druhého argumentu. |
stored_function_type |
Typ functor. |
Člen |
Popis |
---|---|
binder1st |
Konstrukce functor. |
Operátor |
Popis |
---|---|
Operator() |
Vypočítá požadované funkce. |
operátor delegate_type^() |
Vrhá functor pro delegáta. |
Poznámky
Třída šablony popisuje functor jeden argument, který ukládá argument dvě functor a první argument.Definuje operátor členské operator() tak, že když objekt se nazývá jako funkce, vrátí výsledek volání uložené functor uložené první argument a druhý argument zadaný.
Objekt můžete také předat jako argument funkce, jejíž typ je delegate_type^ a budou převedeny správně.
Příklad
// 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);
}
Požadavky
Záhlaví:<cliext, funkční>
Obor názvů: cliext