Why foreach is not nothrow even for a simple associative array?

Cheng Wei rivercheng at gmail.com
Thu Oct 13 02:22:35 PDT 2011


import std.c.stdio

int[int] g_map;

void main() {
    test();
}

nothrow void test() {
    foreach(k, v) {
       printf("%d, %d\n", k, v);
    }
}
Cannot compile with the error:

Error: _aaApply2 is not nothrow

It is not so convenient that we have to use try-catch for all
iteration even when we know that it will not throw at all.


More information about the Digitalmars-d-learn mailing list