Template Question

BCS BCS at pathlink.com
Mon Apr 14 10:46:20 PDT 2008


Mike Parker wrote:
> I've not worked much with templates in any language beyond the basics. 
> Right now, I've got a problem that I've solved, but for which I'm 
> looking a different solution.
> 
> What I have is a templated interface like so:
> 
> interface Foo(T)
> {
>     void init(T);
>     void term();
>     void blah();
>     void bleh();
> }
> 

quick-n-dirty (and untested)

interface FooBase{}
interface Foo(T) : FooBase
{
     void init(T);
     void term();
     void blah();
     void bleh();
}

then throw this in somewhere:

static assert(is(T:FooBase));


More information about the Digitalmars-d-learn mailing list