unary_delegate (STL/CLR)


For the latest documentation on Visual Studio 2017 RC, see Visual Studio 2017 RC Documentation.

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


The type of the argument.

The return type.

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.

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

Header: <cliext/functional>

Namespace: cliext

binary_delegate (STL/CLR)
binary_delegate_noreturn (STL/CLR)
unary_delegate_noreturn (STL/CLR)