D's type classes pattern ?
matovitch via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Mar 24 08:50:59 PDT 2015
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 ?
More information about the Digitalmars-d-learn
mailing list