I've stumbled upon a bit of a problem.
I have a struct that contains lots of binary properties (more than 32) most of which will be false. I want to make a global const array of this struct. Problem: I don't care to write down "false" hundreds of times and count them to know which ones should in fact be a "true".
If I had less than 32 of these suckers, I could just make an enum with the names of all the properties like so:
And make the whole bunch of the bools a single 32 bits (unsigned) integer so I can just jot down a 0 if none of the properties are true, and a (1u<<Variable5 | 1u<<Variable9) if only the fifth and ninth variable should be true and, for example, (0 ~ 1u<<Variable4) if all variables except the fourth should be true. However, there's more than 32 of them so I can't use a single int, and even if I use an array of ints 1u<<Variable33 would equate to 0 so I can't go over 32 variables.Code:enum Variablenames { Variable1, Variable2, Variable3, ... VariableNminus1, VariableN, N };
Is there some simple solution to this problem or will I have to do it the hard way using multiple ints that contain 32 bools each? (which is a pain to read because I need to remember which property is located in which int)



LinkBack URL
About LinkBacks



CornedBee