Problem about Tuple.opEquals, const qualifier

Tongzhou Li zhangsongcui at hotmail.com
Sat Mar 17 21:02:58 PDT 2012


On Saturday, 17 March 2012 at 23:05:30 UTC, Simen Kjærås wrote:
> 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

Another problem. I wrote:
     Tuple!(double, char)[] stack;
     stack ~= tuple(10, '+');
It won't compile:
     Error: cannot append type Tuple!(int,char) to type 
Tuple!(double,char)[]
I also tried:
     Tuple!(double, "Num", char, "Oper")[] stack;
     stack ~= tuple(10.0, '+');
I also got an error:
     Error: cannot append type Tuple!(double,char) to type 
Tuple!(double,"Num",char,"Oper")[]

But I tried:
     Tuple!(double, "Num", char, "Oper") t;
     t = tuple(10, 'a');
It does compile.
I don't understand why...


More information about the Digitalmars-d-learn mailing list