www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Template specialization

reply Li Jie <cpunion gmail.com> writes:
I don't know what is the name of this usage:

template <class T> class SomeClass{};
template <class T, class U> class SomeClass< AnotherClass<T,U> >{};

I think this is very commonly used, but D hasn't supported it yet, Is it in the
plain?

- Li Jie
Apr 18 2006
parent reply Hasan Aljudy <hasan.aljudy gmail.com> writes:
Li Jie wrote:
 I don't know what is the name of this usage:
 
 template <class T> class SomeClass{};
 template <class T, class U> class SomeClass< AnotherClass<T,U> >{};
 
 I think this is very commonly used, but D hasn't supported it yet, Is it in the
 plain?
 
 - Li Jie
 
 
Are you sure? I just tried, and the following works: class SomeClass(T) { T x; } template AnotherClass(T,U) { class AnotherClass( SomeClass(T) ) { } } void main() { }
Apr 18 2006
parent Li Jie <cpunion gmail.com> writes:
In article <e24ltq$2g7f$1 digitaldaemon.com>, Hasan Aljudy says...
Li Jie wrote:
 I don't know what is the name of this usage:
 
 template <class T> class SomeClass{};
 template <class T, class U> class SomeClass< AnotherClass<T,U> >{};
 
 I think this is very commonly used, but D hasn't supported it yet, Is it in the
 plain?
 
 - Li Jie
 
 
Are you sure? I just tried, and the following works: class SomeClass(T) { T x; } template AnotherClass(T,U) { class AnotherClass( SomeClass(T) ) { } } void main() { }
Oh. It's different. // c++ version: That looks like "implicit template parameters type deduce" + "template specialization". How to do it in D? static if?
Apr 19 2006