Partager via


unary_delegate (STL/CLR)

The genereic class describes a one-argument delegate. You use it specify a delegate in terms of its argument and return types.

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

Parameters

  • Arg
    The type of the argument.

  • Result
    The return type.

Remarks

The genereic delegate describes a one-argument function.

Note that for:

unary_delegare<int, int> Fun1;

unary_delegare<int, int> Fun2;

the types Fun1 and Fun2 are synonyms, while for:

delegate int Fun1(int);

delegate int Fun2(int);

they are not the same type.

Example

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

Requirements

Header: <cliext/functional>

Namespace: cliext

See Also

Reference

binary_delegate (STL/CLR)

binary_delegate_noreturn (STL/CLR)

unary_delegate_noreturn (STL/CLR)