destructor, postblit constructor --- force calling always

monarch_dodra monarchdodra at gmail.com
Sun Mar 30 23:06:12 PDT 2014


On Monday, 31 March 2014 at 01:03:22 UTC, Carl Sturtivant wrote:
> What about destructors, are they always called, or is this 
> another optimization if the struct is in it's default .init 
> state?

AFAIK, a destructor is always called when an object goes out of 
scope... unless, it's being moved out of scope. As a matter of 
fact, spec RVO *will* get triggered. This is what allows witting 
factory functions for types without postblit.

In any case, there should be 1 destructor call for every object 
you declared.

Except for thing on the heap. Those are just collected, not 
destroyed :/


More information about the Digitalmars-d-learn mailing list