Converting function pointers to delegates

Andrej Mitrovic andrej.mitrovich at gmail.com
Mon Apr 14 10:49:22 PDT 2014


On Monday, 14 April 2014 at 17:45:52 UTC, Ryan Voots wrote:
> /**
>  * Convert any function pointer to a delegate.
>  * _ From: http://www.digitalmars.com/d/archives/digitalmars

You can replaced it with std.functional.toDelegate.

As for its use-case, if some API or function supports only 
delegates but you want to pass in a function, you would wrap the 
function with toDelegate and then pass the delegate to the 
API/function.


More information about the Digitalmars-d-learn mailing list