How to foreach over a DList?
H. S. Teoh
hsteoh at quickfur.ath.cx
Mon Mar 31 14:39:34 PDT 2014
On Mon, Mar 31, 2014 at 07:30:11PM +0000, Jeroen Bollen wrote:
> On Monday, 31 March 2014 at 19:26:23 UTC, Jeroen Bollen wrote:
> >On Monday, 31 March 2014 at 18:24:39 UTC, H. S. Teoh wrote:
> >>On Mon, Mar 31, 2014 at 05:50:16PM +0000, Jeroen Bollen wrote:
> >>>I am trying to foreach over a std.container.DList but it isn't
> >>>working. I
> >>>have tried the following code:
> >>[...]
> >>
> >>Maybe try using opSlice:
> >>
> >> DList myList;
> >> foreach (e; myList[]) { ... }
> >>
> >>?
> >>
> >>
> >>T
> >
> >Can you explain that syntax?
>
> nvm figured it out;
>
> Are constant DLists supposed to be un-foreach-able?
> Error: mutable method std.container.DList!(ubyte).DList.opSlice is not
> callable using a const object
Argh, why is opSlice non-const? :-( Please file a bug.
Not sure what you can do in the meantime... probably cast away const? Or
avoid using const for containers if you can. The last time I tried that,
I got stuck in a quagmire of partially-implemented const support with no
way out of the mess, and I decided that non-const is less painful to
work with. :-/
T
--
English is useful because it is a mess. Since English is a mess, it maps well onto the problem space, which is also a mess, which we call reality. Similarly, Perl was designed to be a mess, though in the nicests of all possible ways. -- Larry Wall
More information about the Digitalmars-d-learn
mailing list