Problem about Tuple.opEquals, const qualifier

Tongzhou Li zhangsongcui at hotmail.com
Sat Mar 17 18:07:12 PDT 2012


On Saturday, 17 March 2012 at 23:05:30 UTC, Simen Kjærås wrote:
> On Sat, 17 Mar 2012 17:27:21 +0100, Tongzhou Li 
> <zhangsongcui at hotmail.com> wrote:
>
>> I'm learning D, and trying to convert My C++ code into D:
>> http://pastebin.com/eCz9DdZ3
>> I wrote: auto stack = SList!(Tuple!(double, char))();
>> But I got an error
>> Error: function 
>> std.typecons.Tuple!(double,char).Tuple.opEquals!(const(Tuple!(double,char))).opEquals 
>> (const(Tuple!(double,char)) rhs) is not callable using 
>> argument types (const(Tuple!(double,char))) const
>> Does the function Tuple.opEquals miss a const qualifier?
>> Sorry for my bad English:)
>
> As others have pointed out, there are const-correctness bugs.
>
> As for a workaround, have you considered using a simple array 
> instead of a linked list?
> Arrays in D, especially when combined with std.array, make for 
> easy-to-use (though
> perhaps not particularly efficient) stacks:
>
> int[] stack;
>
> stack ~= 3; // Push
> stack = stack[0..$-1]; // Pop
> stack.popBack(); // Pop with std.array

Seems good! I'll have a try.
Thanks


More information about the Digitalmars-d-learn mailing list