Is it possible to avoid call to destructor for structs?
    Haridas 
    haridas at systemc.net
       
    Sun Sep 24 18:46:15 UTC 2017
    
    
  
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;
   }
}
    
    
More information about the Digitalmars-d-learn
mailing list