d future or plans for d3
jerro
nomail at nomail.com
Tue Dec 20 06:05:49 PST 2011
> The array concatenation requiring GC I get, but why does a
> delegate require it?
If you really want a stack allocated delegate, you could use something like:
import std.stdio, std.traits;
struct DelegateWrapper(alias fun, Args...)
{
Args args;
private auto f(ParameterTypeTuple!fun[Args.length..$] otherArgs)
{
return fun(args, otherArgs);
}
auto dg()
{
return &f;
}
}
auto delegateWrapper(alias fun, A...)(A a)
{
return DelegateWrapper!(fun,A)(a);
}
void main()
{
static test (int a, int b, int c)
{
writeln(a, b, c);
}
auto b = delegateWrapper!(test)(1,2);
b.dg()(3);
}
More information about the Digitalmars-d
mailing list