Union member positions?

2021-08-17 Thread z via Digitalmars-d-learn
Is it possible to set a "position" on a union member? or is there is a language-integrated equivalent? For example, to get access to each byte in an unsigned integer while still supporting the original type. ```D ///a single uint that would be accessed as two ushort, or four separate ubyte uni

Re: Union member positions?

2021-08-17 Thread Dennis via Digitalmars-d-learn
On Tuesday, 17 August 2021 at 13:46:22 UTC, z wrote: Is it possible to set a "position" on a union member? You can use anonymous `struct` and `union` blocks. ```D union UnionExample{ uint EAX; struct { //upper union { ushort EAHX; struct {

Re: Union member positions?

2021-08-17 Thread ag0aep6g via Digitalmars-d-learn
On 17.08.21 15:46, z wrote: Is it possible to set a "position" on a union member? or is there is a language-integrated equivalent? For example, to get access to each byte in an unsigned integer while still supporting the original type. ```D ///a single uint that would be accessed as two ushort,