Re:A Better Way to Implement Bit Fields
by lifthrasiir on Wednesday November 14, 2018 @09:37PM
(#18456416)
I recall that Herb Sutter's C++ Metaclasses proposal has an example of bitfield metaclass [1]. Zig's design is reasonable if it also makes use of those non-2^k-bit integer types in other places, and indeed it does (e.g. alignment is commonly `u29`). However if it is not doable, I think Sutter's design (auto-generated overlay on normal integers) makes more sense.
[1] http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p070...