The problem is that templates are currently being created with their argument types, not their parameter types.
If you changed the return statement to:
return Matrix!(T, cast(int)Row, cast(int)M.Col)();
It will be compiled because it was created using int , not size_t (which is uint or ulong).
This is a long-standing mistake, and although he did not like it earlier, Walter recently changed his mind supporting this change in order to use parameter types. Here is a removal request that fixes this problem (it will be in the next version of DMD), linking various related errors.
source share