strange resuts with .stringof and template
Deewiant
deewiant.doesnotlike.spam at gmail.com
Tue Jul 31 12:29:37 PDT 2007
BCS wrote:
>
> |import std.stdio;
> |
> |template T(A...){alias A T;}
> |struct Baz
> |{
> | template Bar(char[] str)
> | {
> | pragma(msg,"B:"~str);
> | bool Bar;
> | }
> |}
> |
> |void main()
> |{
> | Baz v;
> | foreach(i,j;T!(1,2,3,4))
> | {
> | static const char[] s = i.stringof;
> | pragma(msg,"1:"~s);
> | v.Bar!(s) = !!(j&0x01);
> | writef("%d, %s : %s\n", i, v.Bar!(i.stringof), !!(j&0x01));
> | }
> | writef("\n");
> | foreach(i,j;T!(1,2,3,4))
> | {
> | static const char[] s = i.stringof;
> | pragma(msg,"2:"~s);
> | writef("%d, %s : %s\n", i, v.Bar!(s), !!(j&0x01));
> | }
> |}
>
>
> compiles outputting:
> 1:0
> B:0
> B:uint
> 1:1
> 1:2
> 1:3
> 2:0
> 2:1
> 2:2
> 2:3
>
> should be
> 1:0
> B:0
> 1:1
> B:1
> 1:2
> B:2
> 1:3
> B:3
> 2:0
> 2:1
> 2:2
> 2:3
>
This is probably Issue 1168, without looking too closely at your code.
--
Remove ".doesnotlike.spam" from the mail address.
More information about the Digitalmars-d-learn
mailing list