On Monday, 17 August 2015 at 12:38:05 UTC, anonymous wrote:
auto func()(uint[] arr, uint delegate(uint) pure @nogc d) @nogc
{
return arr.map!(d);
}
void main() @nogc
{
uint[3] arr = [1,2,3];
uint context = 2;
auto c = Caller(context);
auto d = &c.method;
auto r = func(arr[], d);
import std.algorithm: equal;
import std.range: only;
assert(equal(r, only(2, 4, 6)));
}
I've just checked with my runtime GC hook. Here the call to
func() allocates 12 bytes via gc_malloc, and it's the same for a
4-elements array, so it's not for the array itself, it's for a
closure, I think.