template subclass as template parameter

BCS none at anon.com
Wed Aug 11 21:57:51 PDT 2010


Hello Ivo,

> class C(T, U : A!(T)) { ... }
> 
> And I'm trying to do this
> 
> void main()
> {
> C!(double, B!(double)) var;
> }
> but dmd complains:
> Error: template instance C!(double,B) does not match template
> declaration C(T,U : A!(T))

The way you have it is asking for an exact match. I would have to look it 
up but I think you can make what you want work with something like this:

class C(T, U) if(is(U : A!(T))) { ... }

That takes any types T and U and then checks if  U can convert to A!(T) (I 
haven't tested that so I might have the syntax wrong.)

-- 
... <IXOYE><





More information about the Digitalmars-d-learn mailing list