Or: Turducken 2.0 The Reckoning
Rebindable offers a proxy type,
DeepUnqual!T) that can "stand in" for
T in layout, but does not share
T's constructor, destructor, copy constructor, invariants or constness.
It's effectively "
std.typecons.Rebindable for structs (and everything else)".
This proxy type is useful when implementing data structures where the lifetime of a contained value is different from the lifetime of the data structure itself.
This project sprang from my thread over in general, https://firstname.lastname@example.org "Will D always have a way to rebind an arbitrary data type?"
To my knowledge, rebindable exploits no compiler bugs and invokes no undefined behavior. All casts are such that pointer fields are matched with pointer fields (or void) at the same offset. It is also totally independent of the vagaries of Phobos functions like
moveEmplace, which Turducken used.
Of course, you must still make sure that mutable fields in
DeepUnqual!T are never exposed as immutable. You can do this by only returning
T by value.
See also: Turducken Type Technique https://email@example.com