Dear D Experts

I have a situation where I want to pass a D struct object as an argument to a function. Now in my case, I do not want to invoke the default D copy constructor for the struct. Is there a way of doing that? I have tried disabling the postblit and enabling another constructor via "alias this" (see the code below). But the compiler does not like that, and I get an error that tells me that the Bar is not copyable since it has been disabled:

struct Bar {
  @disable this(this);
  alias _foo this;
  Foo _foo;
  public this(Foo foo) {
    this._foo = foo;
  }
}

class Foo {}

void main() {
  Bar bar;
  Bar baz = bar;
}

Regards
Ritu

Reply via email to