On Thursday, 3 December 2015 at 21:38:48 UTC, Chris Wright wrote:
The terrible way is something like:

void reset(Object o)
in {
  assert(!(o is null));
}
body {
  auto p = cast(ubyte*)*cast(void**)&o;
  auto ci = o.classinfo;
  auto init = cast(ubyte)ci.init;
  p[0..init.length] = init[];
  if (ci.defaultConstructor) {
    ci.defaultConstructor(o);
  } else {
throw new Exception("no default constructor; object is in invalid
state");
  }
}

In what way is this better than my solution?

Reply via email to