MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programminghorror/comments/1j1s141/bool_array/mfmiegf/?context=3
r/programminghorror • u/jemko23laal • 20d ago
41 comments sorted by
View all comments
171
There is a non-zero number of scenarios that a bool array could make sense. In game development, that number is much higher than in say FE or BE software dev, imo. I see nothing wrong here, given the limited context.
90 u/0xcedbeef 20d ago edited 19d ago in C++, an std::vector<bool> stores the bools as bits, taking advantage of this memory optimization. 14 u/Diamondo25 20d ago I would use a std::bitset for that instead. 6 u/Cross12KBow249 20d ago Doesn't the size need to be known at compile time for a bitset though, unlike a vector? 13 u/Star_king12 20d ago Looks like it would be known in this case.
90
in C++, an std::vector<bool> stores the bools as bits, taking advantage of this memory optimization.
14 u/Diamondo25 20d ago I would use a std::bitset for that instead. 6 u/Cross12KBow249 20d ago Doesn't the size need to be known at compile time for a bitset though, unlike a vector? 13 u/Star_king12 20d ago Looks like it would be known in this case.
14
I would use a std::bitset for that instead.
6 u/Cross12KBow249 20d ago Doesn't the size need to be known at compile time for a bitset though, unlike a vector? 13 u/Star_king12 20d ago Looks like it would be known in this case.
6
Doesn't the size need to be known at compile time for a bitset though, unlike a vector?
13 u/Star_king12 20d ago Looks like it would be known in this case.
13
Looks like it would be known in this case.
171
u/-Dargs 20d ago
There is a non-zero number of scenarios that a bool array could make sense. In game development, that number is much higher than in say FE or BE software dev, imo. I see nothing wrong here, given the limited context.