functional (STL/CLR)

Zahrňte hlavičku <cliext/functional> STL/CLR pro definování šablon funkčních tříd a souvisejících delegátů a funkcí šablon.

Syntaxe

#include <functional>

Požadavky

Header:<cliext/functional>

Obor názvů:cliext

Deklarace

Delegát Popis
binary_delegate (STL/CLR) Delegát se dvěma argumenty.
binary_delegate_noreturn (STL/CLR) Delegát se dvěma argumenty vracející void.
unary_delegate (STL/CLR) Delegát s jedním argumentem.
unary_delegate_noreturn (STL/CLR) Delegát s jedním argumentem, který voidvrací .
Třída Popis
binary_negate (STL/CLR) Functor negate a two-argument functor.
binder1st (STL/CLR) Functor vytvořit vazbu prvního argumentu na functor se dvěma argumenty.
binder2nd (STL/CLR) Functor vytvořit vazbu druhého argumentu na functor se dvěma argumenty.
divides (STL/CLR) Dělit functor.
equal_to (STL/CLR) Equal comparison functor.
greater (STL/CLR) Větší porovnávací functor.
greater_equal (STL/CLR) Větší nebo rovnou porovnávací trychtor.
less (STL/CLR) Méně porovnávaný functor.
less_equal (STL/CLR) Funktor porovnání je menší nebo rovno.
logical_and (STL/CLR) Logický a functor AND.
logical_not (STL/CLR) Logický FUNCTOR NOT.
logical_or (STL/CLR) Logický nebo trychtýr.
minus (STL/CLR) Odečíst functor.
modulus (STL/CLR) Moduls functor.
multiplies (STL/CLR) Násobte funktor.
negate (STL/CLR) Functor vrátit svůj argument negated.
not_equal_to (STL/CLR) Nerovná se porovnávací functor.
plus (STL/CLR) Přidejte functor.
unary_negate (STL/CLR) Functor negovat jeden-argument functor.
Function Popis
bind1st (STL/CLR) Vygeneruje binder1st pro argument a functor.
bind2nd (STL/CLR) Vygeneruje pořadač2nd pro argument a functor.
not1 (STL/CLR) Vygeneruje unary_negate pro functor.
not2 (STL/CLR) Vygeneruje binary_negate pro functor.

Členové

binary_delegate (STL/CLR)

Obecná třída popisuje delegáta se dvěma argumenty. Použijete ho k určení delegáta z hlediska jeho argumentu a návratových typů.

Syntaxe

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

Parametry

Arg1
Typ prvního argumentu.

Arg2
Typ druhého argumentu.

Result
Návratový typ.

Poznámky

Obecný delegát popisuje funkci se dvěma argumenty.

V těchto šablonách funkcí:

binary_delegate<int, int, int> Fun1;

binary_delegate<int, int, int> Fun2;

typy Fun1 a Fun2 jsou synonymy, zatímco pro:

delegate int Fun1(int, int);

delegate int Fun2(int, int);

nejsou stejného typu.

Příklad

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

Obecná třída popisuje delegáta se dvěma argumenty, který vrací void. Použijete ho k určení delegáta z hlediska jeho argumentu.

Syntaxe

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

Parametry

Arg1
Typ prvního argumentu.

Arg2
Typ druhého argumentu.

Poznámky

Obecný delegát popisuje funkci se dvěma argumenty, která vrací void.

V těchto šablonách funkcí:

binary_delegate_noreturn<int, int> Fun1;

binary_delegate_noreturn<int, int> Fun2;

typy Fun1 a Fun2 jsou synonymy, zatímco pro:

delegate void Fun1(int, int);

delegate void Fun2(int, int);

nejsou stejného typu.

Příklad

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

Třída šablony popisuje functor, který při zavolání vrátí logickou HODNOTU svého uloženého dvou argumentu functor. Použijete ho k určení objektu funkce z hlediska uloženého functoru.

Syntaxe

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

Parametry

Fun
Typ uloženého functoru.

Členské funkce

Definice typu Popis
delegate_type Typ obecného delegáta.
first_argument_type Typ prvního argumentu functoru.
result_type Typ výsledku functoru.
second_argument_type Typ druhéhoargumentho
stored_function_type Typ functoru.
Člen Popis
binary_negate Vytvoří functor.
Operátor Popis
operator() Vypočítá požadovanou funkci.
operator delegate_type^() Přetypuje functor delegáta.

Poznámky

Třída šablony popisuje functor se dvěma argumenty, který ukládá další functor se dvěma argumenty. Definuje operátor operator() člena tak, aby při zavolání objektu jako funkce vrátil logickou hodnotu NOT uloženého functoru volaného se dvěma argumenty.

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

Příklad

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

Vygeneruje binder1st argument a functor.

Syntaxe

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

Parametry šablony

Arg
Typ argumentu.

Fun
Typ functoru.

Parametry funkce

functor
Functor, který se má zabalit.

left
První argument, který se má zabalit.

Poznámky

Šablona funkce vrátí binder1st<Fun>(functor, left). Použijete ho jako pohodlný způsob, jak zabalit functor se dvěma argumenty a jeho první argument v functoru s jedním argumentem, který ho volá s druhým argumentem.

Příklad

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

Vygeneruje binder2nd argument a functor.

Syntaxe

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

Parametry šablony

Arg
Typ argumentu.

Fun
Typ functoru.

Parametry funkce

functor
Functor, který se má zabalit.

right
Druhý argument, který se má zabalit.

Poznámky

Šablona funkce vrátí binder2nd<Fun>(functor, right). Použijete ho jako pohodlný způsob zabalení functoru se dvěma argumenty a jeho druhého argumentu v functoru s jedním argumentem, který ho volá s prvním argumentem.

Příklad

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

Třída šablony popisuje functor s jedním argumentem, který při zavolání vrátí svůj uložený dvou argument functor volaný s uloženým prvním argumentem a zadaným druhým argumentem. Použijete ho k určení objektu funkce z hlediska uloženého functoru.

Syntaxe

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

Fun
Typ uloženého functoru.

Členské funkce

Definice typu Popis
delegate_type Typ obecného delegáta.
first_argument_type Typ prvního argumentu functoru.
result_type Typ výsledku functoru.
second_argument_type Typ druhéhoargumentho
stored_function_type Typ functoru.
Člen Popis
binder1st Vytvoří functor.
Operátor Popis
operator() Vypočítá požadovanou funkci.
operator delegate_type^() Přetypuje functor delegáta.

Poznámky

Třída šablony popisuje functor s jedním argumentem, který ukládá functor se dvěma argumenty a první argument. Definuje operátor operator() člena, aby při volání objektu jako funkce vrátí výsledek volání uloženého functoru s uloženým prvním argumentem a zadaným druhým argumentem.

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

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

binder2nd (STL/CLR)

Třída šablony popisuje functor s jedním argumentem, který při zavolání vrátí svůj uložený dvou argument functor volaný s zadaným prvním argumentem a jeho uložený druhý argument. Použijete ho k určení objektu funkce z hlediska uloženého functoru.

Syntaxe

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

Fun
Typ uloženého functoru.

Členské funkce

Definice typu Popis
delegate_type Typ obecného delegáta.
first_argument_type Typ prvního argumentu functoru.
result_type Typ výsledku functoru.
second_argument_type Typ druhéhoargumentho
stored_function_type Typ functoru.
Člen Popis
binder2nd Vytvoří functor.
Operátor Popis
operator() Vypočítá požadovanou funkci.
operator delegate_type^() Přetypuje functor delegáta.

Poznámky

Třída šablony popisuje functor s jedním argumentem, který ukládá functor se dvěma argumenty a druhý argument. Definuje operátor operator() člena tak, aby při volání objektu jako funkce, vrátí výsledek volání uloženého functoru se zadaným prvním argumentem a uloženým druhým argumentem.

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

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

divides (STL/CLR)

Třída šablony popisuje functor, který při zavolání vrátí první argument dělený druhou. Použijete jej k určení objektu funkce z hlediska jeho typu argumentu.

Syntaxe

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

Parametry

Arg
Typ argumentů a návratová hodnota.

Členské funkce

Definice typu Popis
delegate_type Typ obecného delegáta.
first_argument_type Typ prvního argumentu functoru.
result_type Typ výsledku functoru.
second_argument_type Typ druhéhoargumentho
Člen Popis
divides Vytvoří functor.
Operátor Popis
operator() Vypočítá požadovanou funkci.
operator delegate_type^() Přetypuje functor delegáta.

Poznámky

Třída šablony popisuje functor se dvěma argumenty. Definuje operátor operator() člena, aby, když je objekt volán jako funkce, vrátí první argument dělený druhou.

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

Příklad

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

Třída šablony popisuje functor, který při zavolání vrátí hodnotu true pouze v případě, že první argument je roven druhé. Použijete jej k určení objektu funkce z hlediska jeho typu argumentu.

Syntaxe

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

Parametry

Arg
Typ argumentů.

Členské funkce

Definice typu Popis
delegate_type Typ obecného delegáta.
first_argument_type Typ prvního argumentu functoru.
result_type Typ výsledku functoru.
second_argument_type Typ druhéhoargumentho
Člen Popis
equal_to Vytvoří functor.
Operátor Popis
operator() Vypočítá požadovanou funkci.
operator delegate_type^() Přetypuje functor delegáta.

Poznámky

Třída šablony popisuje functor se dvěma argumenty. Definuje operátor operator() člena tak, aby, když je objekt volána jako funkce, vrátí hodnotu true pouze v případě, že první argument je roven druhé.

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

Příklad

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

Třída šablony popisuje functor, který při zavolání vrátí hodnotu true pouze v případě, že první argument je větší než druhý. Použijete jej k určení objektu funkce z hlediska jeho typu argumentu.

Syntaxe

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

Parametry

Arg
Typ argumentů.

Členské funkce

Definice typu Popis
delegate_type Typ obecného delegáta.
first_argument_type Typ prvního argumentu functoru.
result_type Typ výsledku functoru.
second_argument_type Typ druhéhoargumentho
Člen Popis
greater Vytvoří functor.
Operátor Popis
operator() Vypočítá požadovanou funkci.
operator delegate_type^ Přetypuje functor delegáta.

Poznámky

Třída šablony popisuje functor se dvěma argumenty. Definuje operátor operator() člena, aby, když je objekt volána jako funkce, vrátí hodnotu true pouze v případě, že první argument je větší než druhý.

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

Příklad

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

Třída šablony popisuje functor, který při zavolání vrátí hodnotu true pouze v případě, že první argument je větší nebo roven druhé. Použijete jej k určení objektu funkce z hlediska jeho typu argumentu.

Syntaxe

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

Parametry

Arg
Typ argumentů.

Členské funkce

Definice typu Popis
delegate_type Typ obecného delegáta.
first_argument_type Typ prvního argumentu functoru.
result_type Typ výsledku functoru.
second_argument_type Typ druhéhoargumentho
Člen Popis
greater_equal Vytvoří functor.
Operátor Popis
operator() Vypočítá požadovanou funkci.
operator delegate_type^ Přetypuje functor delegáta.

Poznámky

Třída šablony popisuje functor se dvěma argumenty. Definuje operátor operator() člena tak, aby, když je objekt volána jako funkce, vrátí hodnotu true pouze v případě, že první argument je větší nebo roven druhé.

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

Příklad

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

Třída šablony popisuje functor, který při zavolání vrátí hodnotu true pouze v případě, že první argument je menší než druhý. Použijete jej k určení objektu funkce z hlediska jeho typu argumentu.

Syntaxe

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

Parametry

Arg
Typ argumentů.

Členské funkce

Definice typu Popis
delegate_type Typ obecného delegáta.
first_argument_type Typ prvního argumentu functoru.
result_type Typ výsledku functoru.
second_argument_type Typ druhéhoargumentho
Člen Popis
less Vytvoří functor.
Operátor Popis
operator() Vypočítá požadovanou funkci.
operator delegate_type^ Přetypuje functor delegáta.

Poznámky

Třída šablony popisuje functor se dvěma argumenty. Definuje operátor operator() člena, aby, když je objekt volána jako funkce, vrátí hodnotu true pouze v případě, že první argument je menší než druhý.

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

Příklad

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

Třída šablony popisuje functor, který při zavolání vrátí hodnotu true pouze v případě, že první argument je menší nebo roven druhé. Použijete jej k určení objektu funkce z hlediska jeho typu argumentu.

Syntaxe

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

Parametry

Arg
Typ argumentů.

Členské funkce

Definice typu Popis
delegate_type Typ obecného delegáta.
first_argument_type Typ prvního argumentu functoru.
result_type Typ výsledku functoru.
second_argument_type Typ druhéhoargumentho
Člen Popis
less_equal Vytvoří functor.
Operátor Popis
operator() Vypočítá požadovanou funkci.
operator delegate_type^ Přetypuje functor delegáta.

Poznámky

Třída šablony popisuje functor se dvěma argumenty. Definuje operátor operator() člena tak, aby, když je objekt volána jako funkce, vrátí hodnotu true pouze v případě, že první argument je menší nebo roven druhé.

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

Příklad

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

Třída šablony popisuje functor, který při zavolání vrátí hodnotu true pouze v případě, že první i druhý test jako true. Použijete jej k určení objektu funkce z hlediska jeho typu argumentu.

Syntaxe

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

Parametry

Arg
Typ argumentů.

Členské funkce

Definice typu Popis
delegate_type Typ obecného delegáta.
first_argument_type Typ prvního argumentu functoru.
result_type Typ výsledku functoru.
second_argument_type Typ druhéhoargumentho
Člen Popis
logical_and Vytvoří functor.
Operátor Popis
operator() Vypočítá požadovanou funkci.
operator delegate_type^ Přetypuje functor delegáta.

Poznámky

Třída šablony popisuje functor se dvěma argumenty. Definuje operátor operator() člena tak, aby, když je objekt volána jako funkce, vrátí hodnotu true pouze v případě, že první argument i druhý test jako true.

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

Příklad

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

Třída šablony popisuje functor, který při zavolání vrátí hodnotu true pouze v případě, že některý z jeho argumentů testuje jako false. Použijete jej k určení objektu funkce z hlediska jeho typu argumentu.

Syntaxe

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

Parametry

Arg
Typ argumentů.

Členské funkce

Definice typu Popis
argument_type Typ argumentu functoru.
delegate_type Typ obecného delegáta.
result_type Typ výsledku functoru.
Člen Popis
logical_not Vytvoří functor.
Operátor Popis
operator() Vypočítá požadovanou funkci.
operator delegate_type^ Přetypuje functor delegáta.

Poznámky

Třída šablony popisuje functor s jedním argumentem. Definuje operátor operator() člena, aby při zavolání objektu jako funkce vrátil hodnotu true pouze v případě, že argument testuje hodnotu false.

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

Příklad

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

Třída šablony popisuje functor, který při zavolání vrátí hodnotu true pouze v případě, že první nebo druhý test jako true. Použijete jej k určení objektu funkce z hlediska jeho typu argumentu.

Syntaxe

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

Parametry

Arg
Typ argumentů.

Členské funkce

Definice typu Popis
delegate_type Typ obecného delegáta.
first_argument_type Typ prvního argumentu functoru.
result_type Typ výsledku functoru.
second_argument_type Typ druhéhoargumentho
Člen Popis
logical_or Vytvoří functor.
Operátor Popis
operator() Vypočítá požadovanou funkci.
operator delegate_type^ Přetypuje functor delegáta.

Poznámky

Třída šablony popisuje functor se dvěma argumenty. Definuje operátor operator() člena, aby, když je objekt volána jako funkce, vrátí hodnotu true pouze v případě, že první nebo druhý test jako true.

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

Příklad

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

Třída šablony popisuje functor, který při zavolání vrátí první argument minus druhý argument. Použijete jej k určení objektu funkce z hlediska jeho typu argumentu.

Syntaxe

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

Parametry

Arg
Typ argumentů a návratová hodnota.

Členské funkce

Definice typu Popis
delegate_type Typ obecného delegáta.
first_argument_type Typ prvního argumentu functoru.
result_type Typ výsledku functoru.
second_argument_type Typ druhéhoargumentho
Člen Popis
minus Vytvoří functor.
Operátor Popis
operator() Vypočítá požadovanou funkci.
operator delegate_type^ Přetypuje functor delegáta.

Poznámky

Třída šablony popisuje functor se dvěma argumenty. Definuje operátor operator() člena tak, aby při zavolání objektu jako funkce vrátil první argument minus druhý argument.

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

Příklad

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

Třída šablony popisuje functor, který při zavolání vrátí první argument modulo druhé. Použijete jej k určení objektu funkce z hlediska jeho typu argumentu.

Syntaxe

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

Parametry

Arg
Typ argumentů a návratová hodnota.

Členské funkce

Definice typu Popis
delegate_type Typ obecného delegáta.
first_argument_type Typ prvního argumentu functoru.
result_type Typ výsledku functoru.
second_argument_type Typ druhéhoargumentho
Člen Popis
modulus Vytvoří functor.
Operátor Popis
operator() Vypočítá požadovanou funkci.
operator delegate_type^ Přetypuje functor delegáta.

Poznámky

Třída šablony popisuje functor se dvěma argumenty. Definuje operátor operator() člena tak, aby při zavolání objektu jako funkce vrátil první argument modulo druhé.

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

Příklad

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

Třída šablony popisuje functor, který při zavolání vrátí první argument krát druhý. Použijete jej k určení objektu funkce z hlediska jeho typu argumentu.

Syntaxe

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

Parametry

Arg
Typ argumentů a návratová hodnota.

Členské funkce

Definice typu Popis
delegate_type Typ obecného delegáta.
first_argument_type Typ prvního argumentu functoru.
result_type Typ výsledku functoru.
second_argument_type Typ druhéhoargumentho
Člen Popis
multiplies Vytvoří functor.
Operátor Popis
operator() Vypočítá požadovanou funkci.
operator delegate_type^ Přetypuje functor delegáta.

Poznámky

Třída šablony popisuje functor se dvěma argumenty. Definuje operátor operator() člena tak, aby při zavolání objektu jako funkce vrátil první argument krát druhý.

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

Příklad

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

Třída šablony popisuje functor, který při zavolání vrátí svůj argument negated. Použijete jej k určení objektu funkce z hlediska jeho typu argumentu.

Syntaxe

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

Parametry

Arg
Typ argumentů.

Členské funkce

Definice typu Popis
argument_type Typ argumentu functoru.
delegate_type Typ obecného delegáta.
result_type Typ výsledku functoru.
Člen Popis
negate Vytvoří functor.
Operátor Popis
operator() Vypočítá požadovanou funkci.
operator delegate_type^ Přetypuje functor delegáta.

Poznámky

Třída šablony popisuje functor s jedním argumentem. Definuje operátor operator() člena, aby, když je objekt volána jako funkce, vrátí svůj argument negated.

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

Příklad

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

Třída šablony popisuje functor, který při zavolání vrátí hodnotu true pouze v případě, že první argument není roven druhé. Použijete jej k určení objektu funkce z hlediska jeho typu argumentu.

Syntaxe

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

Parametry

Arg
Typ argumentů.

Členské funkce

Definice typu Popis
delegate_type Typ obecného delegáta.
first_argument_type Typ prvního argumentu functoru.
result_type Typ výsledku functoru.
second_argument_type Typ druhéhoargumentho
Člen Popis
not_equal_to Vytvoří functor.
Operátor Popis
operator() Vypočítá požadovanou funkci.
operator delegate_type^ Přetypuje functor delegáta.

Poznámky

Třída šablony popisuje functor se dvěma argumenty. Definuje operátor operator() člena tak, že když je objekt volána jako funkce, vrátí hodnotu true pouze v případě, že první argument není roven druhému.

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

Příklad

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

Vygeneruje unary_negate pro functor.

Syntaxe

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

Parametry šablony

Fun
Typ functoru.

Parametry funkce

functor
Functor, který se má zabalit.

Poznámky

Šablona funkce vrátí unary_negate<Fun>(functor). Použijete ho jako pohodlný způsob, jak zabalit functor s jedním argumentem do functoru, který poskytuje její logickou NE.

Příklad

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

Vygeneruje binary_negate pro functor.

Syntaxe

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

Parametry šablony

Fun
Typ functoru.

Parametry funkce

functor
Functor, který se má zabalit.

Poznámky

Šablona funkce vrátí binary_negate<Fun>(functor). Použijete ho jako pohodlný způsob, jak zabalit functor se dvěma argumenty do functoru, který poskytuje jeho logickou NE.

Příklad

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

Třída šablony popisuje functor, který při zavolání vrátí první argument plus druhý argument. Použijete jej k určení objektu funkce z hlediska jeho typu argumentu.

Syntaxe

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

Parametry

Arg
Typ argumentů a návratová hodnota.

Členské funkce

Definice typu Popis
delegate_type Typ obecného delegáta.
first_argument_type Typ prvního argumentu functoru.
result_type Typ výsledku functoru.
second_argument_type Typ druhéhoargumentho
Člen Popis
plus Vytvoří functor.
Operátor Popis
operator() Vypočítá požadovanou funkci.
operator delegate_type^ Přetypuje functor delegáta.

Poznámky

Třída šablony popisuje functor se dvěma argumenty. Definuje operátor operator() člena tak, aby při zavolání objektu jako funkce vrátil první argument plus druhý.

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

Příklad

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

Obecná třída popisuje delegáta s jedním argumentem. Použijete ho k určení delegáta z hlediska jeho argumentu a návratových typů.

Syntaxe

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

Parametry

Arg
Typ argumentu.

Result
Návratový typ.

Poznámky

Obecný delegát popisuje funkci s jedním argumentem.

V těchto šablonách funkcí:

unary_delegate<int, int> Fun1;

unary_delegate<int, int> Fun2;

typy Fun1 a Fun2 jsou synonymy, zatímco pro:

delegate int Fun1(int);

delegate int Fun2(int);

nejsou stejného typu.

Příklad

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

Obecná třída popisuje delegát s jedním argumentem, který vrací void. Použijete ho k určení delegáta z hlediska jeho typu argumentu.

Syntaxe

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

Parametry

Arg
Typ argumentu.

Poznámky

Obecný delegát popisuje funkci s jedním argumentem, která vrací void.

V těchto šablonách funkcí:

unary_delegate_noreturn<int> Fun1;

unary_delegate_noreturn<int> Fun2;

typy Fun1 a Fun2 jsou synonymy, zatímco pro:

delegate void Fun1(int);

delegate void Fun2(int);

nejsou stejného typu.

Příklad

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

Třída šablony popisuje functor, který při zavolání vrátí logickou HODNOTU svého uloženého functoru s jedním argumentem. Použijete ho k určení objektu funkce z hlediska uloženého functoru.

Syntaxe

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

Parametry

Fun
Typ uloženého functoru.

Členské funkce

Definice typu Popis
argument_type Typ argumentu functoru.
delegate_type Typ obecného delegáta.
result_type Typ výsledku functoru.
Člen Popis
unary_negate Vytvoří functor.
Operátor Popis
operator() Vypočítá požadovanou funkci.
delegate_type^ Přetypuje functor delegáta.

Poznámky

Třída šablony popisuje functor s jedním argumentem, který ukládá další functor s jedním argumentem. Definuje operátor operator() člena, aby, když je objekt volána jako funkce, vrátí logickou NOT uloženého functoru volaného s argumentem.

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

Příklad

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