Assigning &this in constructor.
Adam D. Ruppe via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Jan 18 17:19:43 PST 2017
On Thursday, 19 January 2017 at 00:55:42 UTC, NotSpooky wrote:
> You already answered on the IRC so thanks X2.
> So, it's problematic to have pointers to structs in all cases
> according to spec?
Maybe... though in practice (and with C compatibility), pointers
to ones where you know the memory management scheme is fine.
So if you declare a local, and get a pointer to it, you're OK. Or
if you new it, or malloc it, or something like that.
The big problem with a pointer to itself in the constructor or as
a member is that the struct itself doesn't know where it is going
or how it was allocated, just the code outside does.
More information about the Digitalmars-d-learn
mailing list