Also consider the following code. Please let me know if I am doing the right thing for dynamic arrays. My hack seems to have the desired effect on shutting down the destructor. Is this hack legal use of D? Can you please guide me if/how it can be achieved for std.container.Array?

// >>>>
import std.stdio;

struct Bar {
  ~this() {
    writeln("~Bar");
  }
}

void main() {
  {                             // dynamic array
    Bar[] bars;
    bars.length = 4;
    void* tmp = bars.ptr;
    delete(tmp);
    bars.length = 0;
  }
  {                             // std.container.Array
    import std.container: Array;
    Array!Bar bars;
    bars.length = 6;
    // does not seem to work
    void* tmp = &(bars[0]);
    delete(tmp);
    bars.length = 0;
  }
}

Reply via email to