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?

Reply via email to