Default class template parameter

Igor Shirkalin via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat May 27 12:23:59 PDT 2017


Hi,

I try to make a class template with single template argument 
defaulted to some type.
Is it possible to use the name of class without specification of 
template argumet (no '!' operator)?

Example:

class ClassName(T=double) {
     this(T value) { /// do some stuff here
     }
     /// some other stuff..
}


void main() {
     a = ClassName(1.2); /// error:  cannot deduce function from 
argument types !()(int)
     a = ClassName!double(1.2); /// OK
}

It seems the compiler treats 'ClassName' as function, but it is 
obvious that it should treat it as 'ClassName!double'.




More information about the Digitalmars-d-learn mailing list