Udostępnij za pośrednictwem


binder1st (STL/CLR)

Teoria jeden argument zawiera opis szablonu klasy, która po wywołaniu zwraca jego przechowywanych teoria dwóch argumentów o nazwie z przechowywanych pierwszy argument i podany drugi argument.Umożliwia ona określić obiekt funkcji pod względem jego teoria przechowywanych.

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

  • Zabawa
    Typ przechowywanych teoria.

Funkcje członkowskie

Definicja typu

Opis

delegate_type

Typ rodzajowy delegata.

first_argument_type

Typ teoria pierwszego argumentu.

Typ_wyniku

Typ wyniku teoria.

second_argument_type

Typ teoria drugiego argumentu.

stored_function_type

Typ teoria.

Członek

Opis

binder1st

Konstrukcje teoria.

Operator

Opis

Operator()

Oblicza odpowiednią funkcję.

Operator delegate_type^()

Posługując się miarką teoria pełnomocnikowi.

Uwagi

Klasa szablon opisuje teoria jeden argument, który przechowuje teoria dwóch argumentów i pierwszy argument.Definiuje operator Państwa operator() tak, że gdy obiekt jest wywoływana w funkcji, funkcja zwraca wynik telefonicznej przechowywanych teoria z przechowywanych pierwszy argument i podany drugi argument.

Można również przekazać obiekt jako argument funkcji, których typ jest delegate_type^ i odpowiednio go będą konwertowane.

Przykład

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

Wymagania

Nagłówek:<cliext/funkcjonalności>

Przestrzeń nazw: cliext

Zobacz też

Informacje

bind1st (STL/CLR)