How to get rid of const / immutable poisoning (and I didn't even want to use them...)

Enjoys Math via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon May 22 13:25:35 PDT 2017


On Monday, 22 May 2017 at 20:12:56 UTC, Enjoys Math wrote:
> I had to employ const / immutable to some things to get passed 
> some compiler errors.  Then the poisoning continues.
>
> How do I get this code to run?
>
> String's will hold a T[] which actually will not be modified by 
> the String methods ("immutable strings of T").
>
> I did not want to use any immutable / const anywhere at first, 
> but by passing in [1,2,3]


Solved it by reverting back to original code (no const / 
immutable) on struct and creating two constructors:

	this(T[] s) {
		this.s = s;
	}

	this(const(T)[] s) {
		this.s = cast(T[]) s;
	}


More information about the Digitalmars-d-learn mailing list