Let's say memory is precious, and I have a class with a uint32_t member variable ui and I know that the values will stay below 1 million. The class also hase some bool members.
Does it make sense to use the highest (highest 2,3,..) bit(s) of
uiin order to save memory, sinceboolis 1 byte?If it does make sense, what is the most efficient way to get the highest (leftmost?) bit (or 2nd)? I read a few old threads and there seems to be disagreement about using inline ASM or some sort of shift.
struct A { bool a:1; uint32_t b: 31;};bbecause it is not of the same type asa. Maybe a compiler-specific member backing directive would help.