On Tuesday, 24 March 2015 at 15:51:00 UTC, matovitch wrote:
Hi,

It's been a long time since I coded some d code... sorry I take
the lazy way asking for advices. :D

Lets say I want to implement some generic algorithm. I would like
to checks the types passed to my algorithm implements a specific
interface.

interface IStuff(Stuff)
{
     void foo();
}

class TypeClass(T, I) : I(T)
{
     alias this T;
}

void myAwesomeAlgo(Stuff) (TypeClass!(Stuff, IStuff) stuff)
{
     stuff.foo();
}


Well it seems that I have worked out my question in trying to
formulate it...Would something like this work ?

interface Foo{
}
void Bar(T : Foo)(T t){
}

but interfaces enable runtime polymorphism, you can just accept the interface itself
void Fun(Foo foo){
}

Reply via email to