Avoid GC with closures
Iakh via Digitalmars-d
digitalmars-d at puremagic.com
Sat May 28 11:58:53 PDT 2016
On Friday, 27 May 2016 at 10:34:38 UTC, Kagamin wrote:
> On Thursday, 26 May 2016 at 18:53:35 UTC, Iakh wrote:
>> void g() @nogc
>> {
>> catch scope(void);
>> int[N] arr = [/*...*/];
>> arr[].sort!((a, b) => a > b);
>> }
>
> This compiles just fine and doesn't allocate:
> void g() @nogc
> {
> int[2] arr = [5,4];
> arr[].sort!((a, b) => a > b);
> }
Yeah. It doesn't capture any context. But once it does it
would be an error.
More information about the Digitalmars-d
mailing list