Is it possible to avoid call to destructor for structs?

Haridas haridas at systemc.net
Sun Sep 24 17:11:26 UTC 2017


In the following code, Bar is an element of struct Foo. Is there 
a way to avoid a call to ~Bar when ~Foo is getting executed?

// >>>>>>>>>>

import std.stdio;

struct Foo {
   Bar bar;
   ~this() {
     writeln("~Foo");
     // some code that disables call to ~Bar
   }
}

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

void main() {
   Foo foo;
}



More information about the Digitalmars-d-learn mailing list