Sdílet prostřednictvím


binder2nd (STL/CLR)

Popisuje šablony třídy functor jeden argument, který při jeho uložené dvěma argument functor volána s zadaný argument první a druhý argument uložené vrátí.Použití funkce objektu z hlediska jeho uložené functor určit.

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

Parametry

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

Funkce členů

Definice typu

Description

delegate_type

Typ delegáta obecný.

first_argument_type

Typ functor první argument.

result_type

Typ functor výsledek.

second_argument_type

Typ functor druhý argument.

stored_function_type

Typ functor.

Člen

Description

binder2nd

Konstrukce functor.

Operátor

Description

Operator()

Vypočítá požadované funkce.

operátor delegate_type^()

Vrhá functor delegátovi.

Poznámky

Popisuje šablony třídy functor jeden argument, uchovávající dvě argument functor a druhý argument.Definuje operátor členské operator() tak, že když je objekt volat jako funkci, vrátí výsledek volání uložené functor zadaný argument první a druhý argument uložené.

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

Příklad

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

Požadavky

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

Obor názvů: cliext

Viz také

Referenční dokumentace

bind2nd (STL/CLR)