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 opUnary
to make this work you will need a postblit constructor:
struct A
{
On Monday, 12 February 2018 at 03:13:43 UTC, aliak wrote:
Hi,
Is there a way to get post increment and pre increment working
properly in this scenario?
import std.stdio;
struct A {
int[] a;
this(int a) { this.a = [a]; }
auto opUnary(string op)(){
return A(mixin(op ~ "this