The following works, but I want to make opAssign in D take const ref D.
It needs to still print "(dup here)". How can this be done?

Thanks
Dan

----------------
import std.stdio;

struct A {
  char a[];
  this(this) { a = a.dup; writeln("(dup here)"); }
}
struct B { A a; }
struct C { B b; }
struct D {
  C c;
  // How can I make this take const ref D other
  ref D opAssign(ref D other) {
    c = other.c;
    return this;
  }
}

void main() {
  D d, d2;
  d2 = d;
}

Reply via email to