@nogc with assoc array

Jonathan Marler via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Feb 16 09:55:39 PST 2015


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
}


More information about the Digitalmars-d-learn mailing list