is(Type:Type) fails to evaluate to true
silverclaw
post_message at newgroup.com
Mon Oct 8 16:24:22 PDT 2007
Frits van Bommel Wrote:
> 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
> > { (....) }
> > }
>
> I assume this is a member of your Matrix template?
Yes. It's an operator overload, I wonder where else I'd put it <g> :P
>
> > 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?
>
> Are you sure it used to work like this?
Yes, I'm sure. I tried to make a template specialization but failing that, I asked in the webnews for a solution and that was the suggestion. As I said before I dropped this module a while ago. It worked at the time, still with a 1.x version of DMD. Anyway, the solution you suggested is what I'll end up doing anyway although I have no idea of what you meant by a "vtable" or in what way it is related to performance. I'll just put in a private empty interface on the module and use it for the comparison and be done with it.
More information about the Digitalmars-d-learn
mailing list