Does opSlice work with immutable values?
anonymous
anonymous at example.com
Mon Feb 24 03:37:42 PST 2014
On Monday, 24 February 2014 at 07:02:00 UTC, Joseph Cassman wrote:
> I have a custom number type in the works here
> (https://github.com/joichiro/kuttaka/commit/a226d3368a64ae63b0c256c4f4a4ede375a5cee8).
> The test code for opSlice works in this commit. However, when I
> change the auto to immutable (on line 308) I get the following
> error (a similar error occurs for const):
>
> src/bcd.d(309): Error: mutable method
> kuttaka.bcd.BcdSingle.opSlice is not callable using a immutable
> object
> src/bcd.d(310): Error: mutable method
> kuttaka.bcd.BcdSingle.opSlice is not callable using a immutable
> object
> src/bcd.d(311): Error: mutable method
> kuttaka.bcd.BcdSingle.opSlice is not callable using a immutable
> object
> Failed: ["dmd", "-unittest", "-v", "-o-", "src/bcd.d", "-Isrc"]
>
> How can I get immutable to work here? My thinking is that
> opSlice is creating a new object here so the sliced object
> should be allowed to be const or immutable.
Mark opSlice const then.
More information about the Digitalmars-d-learn
mailing list