On Sunday, 5 July 2015 at 14:44:30 UTC, John Colvin wrote:
struct A { ubyte[B.sizeof] mem; @property ref B b() { return *cast(B*)(mem.ptr); } mixin std.typecons.Proxy!b; }
Thanks, I followed your suggestion and effectively rolled out my own union implementation. Ugly but it works.
struct A { ubyte[maxSizeof] _data;@property ref T _as(T)() inout { return *cast(T*)(_data.ptr); }
alias b = _as!uint; alias c = _as!size_t; alias d = _as!double; }