Combining Delegate and Functions
Daniel Keep
daniel.keep.lists at gmail.com
Tue Jun 30 21:00:34 PDT 2009
Jason House wrote:
> Eric Poggel Wrote:
>> I don't have D2 installed, but the above fails to compile in d1
>> (non-constant expression __dgliteral1).
>
>
> Here's the code I use in D2:
>
> R delegate(T) toDelegate(R, T...)(R function(T) f){
> return delegate R(T t){return f(t);};
> }
What happens when you do this, though?
void foo(ref int v) { v = 42; }
void main()
{
auto dg = toDelegate(&foo);
int v; dg(v);
writefln("%s", v);
}
More information about the Digitalmars-d
mailing list