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:08:10 PDT 2017
On Sunday, 21 May 2017 at 23:59:08 UTC, Guillaume Piolat wrote:
> On Sunday, 21 May 2017 at 12:48:10 UTC, Adam D. Ruppe wrote:
>> Any struct should be able to have its destructor called
>
> Does this rule also applies to class objects?
Yes. If your destructor does modify the state, you should expect
it to be called and have the state ready for it.
When you're using the GC, destructors *may* not be called under
certain conditions:
http://dlang.org/spec/class.html#destructors
But there's no stopping you from destructing manually (via
destroy() call), or by allocating classes manually via malloc or
on the stack.
More information about the Digitalmars-d-learn
mailing list