Relocatable objects and internal pointers

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jan 29 18:09:55 PST 2016


On 1/29/16 8:07 PM, Matt Elkins wrote:
> [snip]
> on D and came across a section in TDPL which said internal pointers are
> verboten because objects must be relocatable. Does this mean my example
> is invalid (e.g., the invariant will not hold in all circumstances)? If
> it is invalid, does that mean there are circumstances under which the
> post-blit constructor can be elided when performing a copy or copy-like
> operation (such as a move)? I've been treating it like a sort of
> copy-constructor that lacks visibility on the copied-from object, but
> maybe that's a mistake...

No, you cannot have internal pointers. But...

I figured out a way to have them. You just have to guarantee you don't 
copy the actual "pointer" out of the struct:

https://forum.dlang.org/post/mk5k4l$s5r$1@digitalmars.com

-Steve


More information about the Digitalmars-d-learn mailing list