Alias delegates and @nogc
Ivan Timokhin via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Feb 18 08:09:50 PST 2015
With dmd 2.066.1, this compiles:
void bar(scope int delegate() a) @nogc {}
void foo(int x) @nogc
{
bar(() => x);
}
but this doesn't:
void bar(alias a)() {}
void foo(int x) @nogc
{
bar!(() => x)();
}
Fails with
Error: function test.foo @nogc function allocates a closure with the GC
Is there any way to pass a delegate that:
1. avoids indirect calls (like alias);
2. does not allocate (like scope delegate);
3. captures local variables?
More information about the Digitalmars-d-learn
mailing list