On 12/10/11 5:11 AM, Walter Bright wrote:
On 12/10/2011 3:04 AM, Mehrdad wrote:
On 12/10/2011 3:01 AM, Walter Bright wrote:
On 12/10/2011 2:34 AM, Mehrdad wrote:
... and another...
struct Matrix(T, size_t N = 1)
{ public auto mul(Matrix!(T, N) other) const { return this; } }
In general, to refer to the current template being expanded from
inside of it,
just give its name, as in:
Matrix!(T,N) => Matrix
That's not the issue.
If you say 'int' instead of size_t, it works fine.
That's because
Matrix!(int, cast(int)1)
is considered a different template instantiation (and hence a different
type) from
Matrix!(int, cast(uint)1)
Instantiation types are based on the arguments' types, not the
parameters' types.
If you use my suggestion for the shorthand notation, your code will work
as you expect.
Please let's not deflect the issue. If there's a patentable way to annoy
an annoyed user even more, this must be it. A bug is a bug is a bug.
Matrix can _only_ be instantiated with size_t, it says so in the definition:
struct Matrix(T, size_t N = 1) { ... }
THAT IS NOT:
struct Matrix(T, alias N = cast(size_t) 1) { ... }
as the current compiler seems to wrongly implement it. The fact that one
can actually instantiate it with int or whatnot should first convert the
int to size_t, and then instantiate the matrix with size_t.
http://d.puremagic.com/issues/show_bug.cgi?id=7090
Thanks Mehrdad.
Andrei