RAII and Deterministic Destruction
Jim Hewes via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Aug 26 09:34:59 PDT 2015
Thanks for the thorough response. I'm aware of some of what you
explained. Maybe I should have asked differently. Rather than asking
what RAII facilities do exist, I guess I was looking for the answer,
"Here's what you typically do in C++ RAII that you can't do in D." I
could probably find out things by experimenting too (and not be too
lazy). I just didn't want to rely on my assumptions only.
For example, say object A is a member of object B which is in turn a
member of object C. If C is deleted or goes out of scope, does the
destructor of A get called? If all three are classes, obviously not. But
if all three are structs? What if they are classes but are all managed
by Unique? If I use Unique for all of my heap-allocated classes (as I
would with std::unique_ptr in C++) am I assured of destructors being
called when the owning classes get destructed? I'm wondering about these
various nesting/owning combinations.
Jim
More information about the Digitalmars-d-learn
mailing list