On Thursday, 1 May 2014 at 22:18:59 UTC, H. S. Teoh via
Digitalmars-d wrote:
[snip]
6) Since class dtors were the only thing that cleaned up the
struct
member variables by invoking their dtors, that means the struct
dtor
will *never* get invoked.
[snip]
I might be mistaken but isn't it the case now that class dtors
may never get invoked by the GC anyway? In which case having
class dtors is pointless because one cannot rely on them.
But dtors for structs I thought would still be useful. The dtor
might not be called by the class dtor as it no longer exists, but
it is called if I reassign the struct member by value.
C c = new C();
// some code
auto s = SomeStruct(/*with some parms*/);
c.setStruct(s); // the existing c.struct dtor will be called,
releasing whatever resources it needs
Cheers,
ed