Re: Packing enums

2015-07-01 Thread ketmar via Digitalmars-d-learn
On Monday, 29 June 2015 at 22:05:47 UTC, qznc wrote: Something like this: enum X { A, B, C }; enum Y { foo, bar, baz }; alias both = TwoEnums!(X,Y); static assert(both.sizeof == 1); both z; z.X = B; z.Y = bar; that's so easy that it's not even funny... enum X { A, B, C }; enum Y { foo, bar,

Packing enums

2015-06-30 Thread qznc via Digitalmars-d-learn
I stumbled upon this interesting programming challenge [0], which imho should be possible to implement in D. Maybe someone here wants to try. Task: Given two enums with less than 256 states, pack them into one byte and provide convenient accessor functions. Something like this: enum X { A,

Re: Packing enums

2015-06-30 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 29 June 2015 at 22:05:47 UTC, qznc wrote: I stumbled upon this interesting programming challenge [0], which imho should be possible to implement in D. Maybe someone here wants to try. Task: Given two enums with less than 256 states, pack them into one byte and provide convenient ac