Undo struct slicing by type-punning

ponce via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jul 14 14:34:03 PDT 2014


On Monday, 14 July 2014 at 18:43:36 UTC, Ali Çehreli wrote:
> On 07/14/2014 10:35 AM, ponce wrote:
>
> > Ok, solved it, I just use pointer casts and it seems to work
> when the
> > struct is sliced.
>
> I think there is a terminology issue here. Slicing cannot be 
> undone; once the object is sliced, the non-A parts are gone.
>

Well they are not really gone if the struct is passed by-ref, you 
can recover the "gone" parts: http://dpaste.dzfl.pl/d64863fd4c6d


More information about the Digitalmars-d-learn mailing list