Deduction of Template Value Parameters

gg g at g.com
Tue Nov 2 22:50:30 PDT 2010


> You need to build the class instance with new, and if you want an uint you need to add a U.
> 
> You may also ask similar questions in the D.learn group.
> 
> Bye,
> bearophile
Sorry,i must check before posting, I tried to reduce to a simple test case al long code.
This is THE an actual confusion:


FAILS
class Matrix (Tx,uint x, uint y){
}
void tes(T,uint x,uint y)(Matrix!(T,x,y) x){
	
}
void main(){
	auto g = new Matrix!(double,5,4)();//Here should be the error.!
	tes(g);// WHY fails here?
}
fails Error: cannot implicitly convert expression (g) of type chap.Matrix!(4).Matrix to chap.Matrix!(x).Matrix
WORKS
class Matrix (Tx,uint x, uint y){
}
void tes(T,uint x,uint y)(Matrix!(T,x,y) x){
	
}
void main(){
	auto g = new Matrix!(double,5u,4u)();
	tes(g);
}


The actual question why 5 and 4 and 5u and 4u are accepted in template instantiation but only one is valid 



More information about the Digitalmars-d mailing list