On Wednesday, 30 January 2013 at 10:29:26 UTC, monarch_dodra
wrote:
On Wednesday, 30 January 2013 at 08:15:15 UTC, Mike Parker
wrote:
Destructors of members will not be called when an object is
collected. Only that of the object itself. But, there's no
guarantee that any member references will still be valid when
the object's destructor is called. See below for more.
Just to be clear, I suppose you (both) are talking about
"member references"? EG: Nested classes?
I found calling member class references as nested classes
confusing - they are very different.
Destroying an object 100% guarantees its member destroyers are
also called, outer to inner, first in first out, as part of the
destruction process. The thing is that when you store a "class
reference" then you call the destructor of the reference
itself. References being glorified pointers, it basically means
it does nothing.
Are you implying that in following code snippet:
class A { ~this() { ... } }
class B { A a; ~this() { ... } }
destructor of A will be always called after B, so "a" member is
always accessible in B's dtor?