On Sunday, 24 September 2017 at 17:11:26 UTC, Haridas wrote:
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?

No, but you could just set a flag in Bar that the destructor checks and skips running if it is set.

In fact, the destructor should do nothing if bar is in its initial state, so that's how you could check it. For example

~this() {
   if(this.member is null) return;
   // finalize this.member
}


Reply via email to