is(Type:Type) fails to evaluate to true

Daniel Keep daniel.keep.lists at gmail.com
Mon Oct 8 16:10:06 PDT 2007



silverclaw wrote:
> I picked up the Matrix class I abandoned some months ago and updated it to the latest DMD (2.022). However, on the opMulAssign the following check fails where it should pass:
> 
> const Matrix!(Type) opMul(T)(const T multiplier)
> {
> 	static if (is(T:Matrix)) //multiplication by a Matrix
> 	{ (....) }
> 	else //multiplication by a scalar
> 	{ (....) }
> }
> 
> It used to work on some other compiler version. So, on the main() I made the following code:
> 
> (static) if (is(Matrix:Matrix)) writefln("true");
> else writefln("false");
> 
> always evaluates to false (prints "false") with or without the "static". As you may have noticed, it is a template class:
> 
> public class Matrix(Type)
> 
> As I said, it used to work, I'm going to try to find out with which DMD. Any suggestions?

Does is(T:Matrix!(Type)) work?  Considering that a template doesn't
exist until you instantiate it, I find it odd that is(T:Matrix) ever
worked at all.

	-- Daniel


More information about the Digitalmars-d-learn mailing list