How to foreach over a DList?

H. S. Teoh hsteoh at quickfur.ath.cx
Mon Mar 31 16:30:48 PDT 2014


On Mon, Mar 31, 2014 at 09:55:01PM +0000, monarch_dodra wrote:
> On Monday, 31 March 2014 at 21:41:16 UTC, H. S. Teoh wrote:
> >Argh, why is opSlice non-const? :-(  Please file a bug.
> 
> If opSlice was const, then you'd get a const slice, with const
> reference.  You wouldn't even be able to iterate on it.
[...]

Um... wat?

I didn't say opSlice should return a const object (that would be
ridiculous, as you point out). Rather, it should return a tail-const
range that iterates over the const items in the const list.

A const container that cannot be iterated over makes no sense at all.
Iterating over something doesn't modify anything!!


T

-- 
Ruby is essentially Perl minus Wall.


More information about the Digitalmars-d-learn mailing list