D-Programming-Language/phobos — pull request #683 by monarchdodra (2012-07-11 11:18:55+00:00)
Title: better support of foreach for array

See discussion "foreach ref very broken: fails to call front(val)" here:
http://forum.dlang.org/thread/uoptrrkgfczyozxtkkvi@forum.dlang.org

This fix allows writting things like:
Array!int arr;
foreach(ref a; arr)
++a;

In the sense that:
1) arr actually gets modified as intended by ref.
2) "++a" compiles correctly, even though "++front" doesn't allow it.

I think the pull request is complete:
I implemented both opApply and opApplyReverse.
I implemented it both for Array.Range and Array (see: http://forum.dlang.org/thread/rxpbtrawpjzvdfuuwmwp@forum.dlang.org)
I implemented correct behavior for "break" cases.
I documented the public opApply.
I wrote a complete unit test.
I tested && unittested it.

This is my first time doing this, so please forgive me if I did something wrong :(