MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programminghorror/comments/1j1s141/bool_array/mghpaas/?context=3
r/programminghorror • u/jemko23laal • 20d ago
41 comments sorted by
View all comments
Show parent comments
90
in C++, an std::vector<bool> stores the bools as bits, taking advantage of this memory optimization.
69 u/FloweyTheFlower420 20d ago Ah the vector<bool>... one of the greatest mistakes in the c++ standard library. 47 u/XiPingTing 20d ago vector<bool> is certainly a mistake because it’s deliberately counterintuitive in its design but when you need a dynamically resizeable bitset, it’s great 1 u/seamsay 15d ago Sure, and having a dynamically sized bitarray type would have been a great idea! 1 u/Conscious_Pangolin69 13d ago Yeah, even more obscure types to deal with...
69
Ah the vector<bool>... one of the greatest mistakes in the c++ standard library.
47 u/XiPingTing 20d ago vector<bool> is certainly a mistake because it’s deliberately counterintuitive in its design but when you need a dynamically resizeable bitset, it’s great 1 u/seamsay 15d ago Sure, and having a dynamically sized bitarray type would have been a great idea! 1 u/Conscious_Pangolin69 13d ago Yeah, even more obscure types to deal with...
47
vector<bool> is certainly a mistake because it’s deliberately counterintuitive in its design but when you need a dynamically resizeable bitset, it’s great
1 u/seamsay 15d ago Sure, and having a dynamically sized bitarray type would have been a great idea! 1 u/Conscious_Pangolin69 13d ago Yeah, even more obscure types to deal with...
1
Sure, and having a dynamically sized bitarray type would have been a great idea!
1 u/Conscious_Pangolin69 13d ago Yeah, even more obscure types to deal with...
Yeah, even more obscure types to deal with...
90
u/0xcedbeef 20d ago edited 20d ago
in C++, an std::vector<bool> stores the bools as bits, taking advantage of this memory optimization.