How did they make a variable take only 1 bit of space?
Hello
While programming for a game in Unreal Engine, out of curiosity I decided to take a look at the memory layout of one of the classes I made, and I found an interesting thing: There are many boolean variables (defined as part of the UE class framework) that, instead of taking up one byte as they usually would, only take up one bit and are stacked one close to the other, saving space.
I have also noticed that those variables are not declared as bool, rather, as uint8.
I have thought about it and the only explanation I can come up with is that they declared a uint8 and used each bit of it as its separate variable, but now I wonder, how did they do that in plain C++? And if that's now how they did, what else did they do to pull that off?
This is not something I'm really asking to use, rather, just out of curiosity.
https://redd.it/1o6e172
@r_cpp
Post #24054
23