@nogc with assoc array
Benjamin Thaut via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Feb 16 09:58:11 PST 2015
Am 16.02.2015 um 18:55 schrieb Jonathan Marler:
> 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
> }
Because the index operator throws a OutOfRange exception and throwing
exceptions allocates, maybe?
More information about the Digitalmars-d-learn
mailing list