[Issue 17771] foreach over const input range fails

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Aug 21 08:37:44 PDT 2017


https://issues.dlang.org/show_bug.cgi?id=17771

Alex Goltman <alex.goltman at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |---

--- Comment #2 from Alex Goltman <alex.goltman at gmail.com> ---
If it fails to implicitly copy to a non-const (e.g.  a struct with a pointer
inside) then so be it - but why not make it try at least? as in:

Unqual!(typeof(range)) _r = range;

It seems weird that foreach which intentionally copies the range to avoid
modifying it will fail because a range is an unmodifiable const.

--


More information about the Digitalmars-d-bugs mailing list