r/cpp • • Feb 23 '26

Bit-field layout

https://maskray.me/blog/2026-02-22-bit-field-layout
28 Upvotes

13 comments sorted by

View all comments

Show parent comment

3

u/TSP-FriendlyFire Feb 23 '26

You know, I think this should be possible with reflection? As long as your struct is an aggregate, you can define a new aggregate with all fields packed optimally. It'd be nice to have Herb's metaclass syntax so the unpacked aggregate has the mangled name, but Packed<Foo> isn't too bad.