Re: Struct hash issues with string fields

2012-06-03 Thread H. S. Teoh
On Sat, May 26, 2012 at 09:53:07PM +0200, Andrej Mitrovic wrote: > I don't understand this: > > import std.stdio; > > struct Symbol { string val; } > > void main() > { > int[string] hash1; > hash1["1".idup] = 1; > hash1["1".idup] = 2; > writeln(hash1); // writes "["1":2]" > >

Re: alias this with template class?

2012-06-03 Thread Namespace
Fail. Ok, i tried something like this: [code] import std.stdio; mixin template TConvertTo(T : Object, U) { T!(U) ConvertTo() inout { return cast(T!U) this; } alias ConvertTo this; } class Foo(T) { public: T Num; mixin TCo

Re: alias this with template class?

2012-06-03 Thread Timon Gehr
On 06/03/2012 08:43 PM, Namespace wrote: I think this should work: [code] import std.stdio; class Foo(T) { public: T Num; @property Foo!(U) ConvertTo(U)() inout { return cast(Foo!(U)) this; } alias ConvertTo this; } void Call(const Foo!(float) FFoo) { } vo

alias this with template class?

2012-06-03 Thread Namespace
I think this should work: [code] import std.stdio; class Foo(T) { public: T Num; @property Foo!(U) ConvertTo(U)() inout { return cast(Foo!(U)) this; } alias ConvertTo this; } void Call(const Foo!(float) FFoo) { } void m