Is the default implemented opAssign really pure and therefore should be considered such.

The code below works. If you turn off the static if, it will fail with:

Error: pure function 'opAssign.foo' cannot call impure function 'opAssign.S.opAssign'.

Also, in case the answer is no and default implemented opAssign must remain impure, is there a standard way, in a member function to do like:

auto ref opAssign(S other) pure {
   blit other into this
   call this(this)
}

Thanks
Dan

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

struct S {
  char[] c;
  this(this) pure { c = c.dup; }
  static if(1) {
auto ref opAssign(S other) pure { c = other.c.dup; return this; }
  }
}

S foo(S s) pure {
  S other;
  other = s;
  return other;
}

void main() {
  S s;
  S another = foo(s);
}

Reply via email to