binary_delegate (STL/CLR)

genereic 类描述两个参数委托。您使用它来指定委托根据其参数并返回类型。

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

参数

  • Arg1
    第一个参数的类型。

  • Arg2
    第二个参数的类型。

  • 结果
    返回类型。

备注

genereic 委托描述两个参数功能。

请注意,对于:

binary_delegate<int, int, int> Fun1;

binary_delegate<int, int, int> Fun2;

类型 Fun1 和 Fun2 是同义词,那么,当为时:

delegate int Fun1(int, int);

delegate int Fun2(int, int);

它们不属于同一类型。

示例

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

要求

标题: <cliext/函数>

命名空间: cliext

请参见

参考

binary_delegate_noreturn (STL/CLR)

unary_delegate (STL/CLR)

unary_delegate_noreturn (STL/CLR)