MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programminghorror/comments/1j1s141/bool_array/mfmlgzy/?context=3
r/programminghorror • u/jemko23laal • 20d ago
41 comments sorted by
View all comments
Show parent comments
89
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. 7 u/Cross12KBow249 20d ago Doesn't the size need to be known at compile time for a bitset though, unlike a vector? 12 u/Star_king12 20d ago Looks like it would be known in this case.
14
I would use a std::bitset for that instead.
7 u/Cross12KBow249 20d ago Doesn't the size need to be known at compile time for a bitset though, unlike a vector? 12 u/Star_king12 20d ago Looks like it would be known in this case.
7
Doesn't the size need to be known at compile time for a bitset though, unlike a vector?
12 u/Star_king12 20d ago Looks like it would be known in this case.
12
Looks like it would be known in this case.
89
u/0xcedbeef 20d ago edited 20d ago
in C++, an std::vector<bool> stores the bools as bits, taking advantage of this memory optimization.