On Tuesday, 1 April 2014 at 13:30:21 UTC, Meta wrote:
On Tuesday, 1 April 2014 at 12:30:03 UTC, monarch_dodra wrote:
I fixed this not too long ago. Long story short, the "~=" implementations were made of fail.

Just change those "~=" for "insertBack" and you should be fine.

That aside, why is it necessary to cast 1, 2 and 3 to ubyte when adding them to the DList? Is this a problem with DList or with D?

D has a "feature", where you can't assign something big into something small. EG, you can't assign an int to a byte. This avoids dangerous overflow.

That said, this is *usually* transparent, because D *also* has value range analysis. So what this means is that when you write:
"ubyte b = 1;"
Even though "1" is actually an int, the compiler knows it is int he 0-255 range, so the assignment is fine.

In contrast, if you *pass* "1" to the DList, you lose that info, and the DList will complain that you are trying to assign an int to a ubyte.

For what it's worth, 2.066 introduces uniform initialization, so this will become valid, and is somewhat less intrusive:

    list1.insertBack(ubyte(1));
    list1.insertBack(ubyte(2));
    list1.insertBack(ubyte(3));

Reply via email to