class template specialization and inheritance

Bill Baxter dnewsgroup at billbaxter.com
Wed May 14 19:08:08 PDT 2008


Edward Diener wrote:
> mki wrote:
>> Hello!
>>
>> I just discovered the template syntax of D. I am very exited about its 
>> simplicity compared to C++.
>>
>> Now I ran into a template behavior I do not understand. This code:
>  > snip...
>> class C(TT:A!(T)) {
>>     static void tellMe() {
>>         writefln("derived from A!(T).");
>>     }
>> }
> 
> Huh ! What is T above ? I do not think that your use of T should be 
> legal. Are you sure you did not mean 'class C(TT:A!(TT)) { etc.' ?

I think it's supposed to be legal using:

class C(TT:A!(T), T)

That is, one template parameter can depend on another in a non-trivial 
way in theory. But I think the compiler has trouble with such things 
right now.

 From what I understand that is the intended way to do C++ things like 
this in D:

template <typename Z>
template class C { ... }

// specialization for all Z == A<T> for template A and some T
template <typename T>
   template class C< A<T> > { ... }


--bb



More information about the Digitalmars-d mailing list