C# style generic interfaces with templates

Daniel Keep daniel.keep+lists at gmail.com
Sun Jan 14 22:23:33 PST 2007


Running out the door: this works for me with D 1.0:


interface H(T)
{
     T another();
}

class A(T) : H!(T)
{
     T t;
     T another() { return t; }
     void curious() { }
}

import std.stdio;

void main()
{
     alias A!(int) a;
     a b = new a;
     A!(int) c = new A!(int);
     H!(int) d = new A!(int);

     writefln("b.another: ", b.another);
     writefln("c.another: ", c.another);
     writefln("d.another: ", d.another);
}


	-- Daniel


More information about the Digitalmars-d-learn mailing list