On 12/10/2011 2:46 AM, Timon Gehr wrote:
On 12/10/2011 11:18 AM, Mehrdad wrote:
... and another...

struct S(T, int N)
{ public auto opBinary(string op)(in S!(T, N) other) const { return
this; } }
void main() { S!(int, 1) m; m = m * m; }

Error: 'm' is not of arithmetic type, it is a Matrix!(int,1)
Error: 'm' is not of arithmetic type, it is a Matrix!(int,1)

It is unrelated to const, this gives the same error.
struct S(T, int N)
{ public auto opBinary(string op)(S!(T, N) other) { return this; } }
void main() { S!(int, 1) m; m = m * m; }
Yeah, I've complained about const before, but I never said this one was related. :P I just had the word 'const' in there because it was in my original code and I forgot to take it out.

And this works:

struct S(T, int N)
{ public auto opBinary(string op)(in S other) const { return this; } }
void main() { S!(int, 1) m; m = m * m; }

You have to make sure that the signature of your template actually compiles. Maybe the compiler should emit a diagnostic for that case.
Sure, but what's wrong with my version that makes it not compile?

If you blame all your compile errors on const, I can understand why you think its design is broken.

Not _all_ of them (e.g. I figured this one wasn't one of them), but yes, a significant fraction of them that I've seen, only a few of which I've been in the mood to post. :)
So yeah, that's why I've come to the conclusion that it's broken.

Reply via email to