How to foreach over a DList?
Ali Çehreli
acehreli at yahoo.com
Tue Apr 1 03:56:39 PDT 2014
On 03/31/2014 10:32 PM, Jeroen Bollen wrote:
> Still no luck:
>
> import std.container;
> import std.stdio;
>
> void main()
> {
> DList!ubyte list1 = DList!ubyte();
> list1 ~= cast(ubyte) 1;
> list1 ~= cast(ubyte) 2;
> list1 ~= cast(ubyte) 3;
>
> foreach(ubyte item; list1[]) {
> writeln(item);
> }
> }
>
> /usr/include/dlang/dmd/std/container.d(1874): Error: no property
> '_first' for type 'ubyte'
> /usr/include/dlang/dmd/std/container.d(1875): Error: no property
> '_first' for type 'ubyte'
> /usr/include/dlang/dmd/std/container.d(1875): Error: undefined
> identifier rhs_, did you mean variable rhs?
> source/app.d(7): Error: template instance
> std.container.DList!ubyte.DList.opOpAssign!("~", ubyte) error instantiating
> source/app.d(7): Error: cannot append type ubyte to type DList!ubyte
I think your problem is fixed in a more recent compiler. The code works
with git head dmd but fails with e.g. 2.064. (Not tested with 2.065.)
Ali
More information about the Digitalmars-d-learn
mailing list