Taking a function or delegate as argument.

Mike Parker aldacron at gmail.com
Tue Jan 10 05:43:02 PST 2012

On 1/10/2012 10:05 PM, simendsjo wrote:
> If I want to have a method taking a callback function, I have to specify
> if it should take a function or delegate even if I don't really care.
> What's the best way to accept either? I cannot see any wrapper for
> something like this in std.typecons.

The simple way:

void callback(int i, void delegate(int) dg)

void callback(int i, void function(int) fn)
     void wrap(int j)
     callback(i, &wrap);

More information about the Digitalmars-d-learn mailing list