@nogc with assoc array

Tobias Pankrath via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Feb 16 09:57:45 PST 2015


On Monday, 16 February 2015 at 17:55:42 UTC, Jonathan Marler 
wrote:
> Why is the 'in' operator nogc but the index operator is not?
>
> void main() @nogc
> {
>     int[int] a;
>     auto v = 0 in a; // OK
>     auto w = a[0];   // Error: indexing an associative
>                      // array in @nogc function main may
>                      // cause GC allocation
> }

Might throw.


More information about the Digitalmars-d-learn mailing list