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.

With some extra code, you could create some sort of "slice of immutable" type, but you'd still only be able to get const items.

We *could* add a const *overload* but...

Or avoid using const for containers if you can.

That. D's "turtles all the way down" const doesn't work like C++'s "head only" const. As a general rule, don't use too much const in D, *especially* for containers-like objects...

At this point, adding a const overload would be nothing more that a still unusable mess, with extra maintenance overhead.

Reply via email to