On Monday, 12 February 2018 at 06:16:21 UTC, rumbu wrote:
writeln(a++) translates to:A copy = a; a.opUnary!"++"; writeln(copy);copy.a[] and a.a[] are the same reference, you increment a.a[0]/copy.a[0] in opUnaryto make this work you will need a postblit constructor: struct A { .... this(this) { a = a.dup; //make a copy a; } }In fact, you'll find exactly the same scenario in docs: https://dlang.org/spec/struct.html#struct-postblit
Ah! Awesome. Yes that works, thank you! Cheers