Why D const is annoying

SomeDude lovelydear at mailmetrash.com
Sat Apr 28 02:50:48 PDT 2012


On Saturday, 10 December 2011 at 10:34:28 UTC, Mehrdad wrote:
> ... and another...
>
> struct Matrix(T, size_t N = 1)
> { public auto mul(Matrix!(T, N) other) const { return this; } }
>
> void main()
> {
>     Matrix!(int, 2) m;
>     m.mul(m);
> }
>
> annoy.d(7): Error: function annoy.Matrix!(int,2).Matrix.mul 
> (Matrix!(int,N) other) const is not callable using argument 
> types (Matrix!(int,2))
> annoy.d(7): Error: cannot implicitly convert expression (m) of 
> type Matrix!(int,2) to Matrix!(int,N)

This one now works. :)


More information about the Digitalmars-d mailing list