On Monday, 22 May 2017 at 00:45:27 UTC, Adam D. Ruppe wrote:
On Monday, 22 May 2017 at 00:36:24 UTC, Stanislav Blinov wrote:
I can't think of any case where you'd want preconditions on destructor when the object is in .init state.

I think we're actually saying the same thing: I mean the destructor must be callable on .init so you might do like

struct Foo {
   int* ptr;
   ~this() {
      // might be called with ptr is null cuz of .init
      // so wanna check
      if(ptr !is null) free(ptr);
    }
}

Ah, yes, exactly. The page is indeed the same one.

P.S. Though it's fine to call free with a null pointer :P

Reply via email to