Why would an initialised struct pointer field be null in the struct's destructor?

Stanislav Blinov via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun May 21 17:36:24 PDT 2017


On Monday, 22 May 2017 at 00:23:26 UTC, Adam D. Ruppe wrote:
> On Sunday, 21 May 2017 at 14:13:20 UTC, Stanislav Blinov wrote:
>> Not if you either emplace() or blit Foo.init into all of the 
>> array elements.
>
> You especially need to be safe calling ~this on Foo.init.

How so? .init is supposed to be destructible without question. 
destroy() calls in the runtime also blit the initializer back 
over the destructed objects. std.algorithm.move et al. 
specifically take advantage of .init (blit it over the moved-from 
object, so it can either be destructed or assigned something 
else).

I can't think of any case where you'd want preconditions on 
destructor when the object is in .init state.


More information about the Digitalmars-d-learn mailing list