struct destructors

Janice Caron caron800 at googlemail.com
Fri Mar 7 00:12:06 PST 2008


I see that structs now have destructors, according to the changelog for D2.012.

How does that work? I wasn't even aware that they had /con/structors!
I've still been using static opCall for that (and hating doing so,
because it's such a kludge).

So do we get to use this() and ~this() now? Can we use new and delete
with structs? Can we use delete with structs on the stack?

Also, what about assignment and copy construction?

...and repeatedly returning a struct from a function (as in, e() calls
f(), which calls g(), which calls h(); h returns a struct, which
returns it to g, which returns it to f, which returns it to e). Will
those nested returns invoke a chain of copy constructors and
destructors? Or will it be optimised to just a single copy?

That's a lot of questions for one post. Sorry about that.

Oh - one more. What's a postblit?



More information about the Digitalmars-d mailing list