Cannot use function as foreach aggregate.

Downs default_357-line at yahoo.de
Thu Apr 5 16:32:26 PDT 2007


Daniel Keep wrote:

> 2. What's the cleanest way to wrap a function pointer in a delegate?
> 

Okay, so it's not the cleanest way, and it's not automatic either, but it's easy as heck.

import std.stdio;
bool test(int e, float f) { return true; }
void main() { auto dg=(int e, float f) { return test(e, f); }; dg(4, 3.14159); writefln(typeid(typeof(dg))); }



More information about the Digitalmars-d mailing list