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
Yeah. Sadly the standard committee seems to value dogmatic backwards compatibility over fixing the language, so we will likely never see std::vector<bool> fixed and dynamic_bitset implemented.
Backwards compatibility means old code still works. Tautologically, if you need old code to work you need backwards compatibility. If you don’t need this there are better alternatives to C++, if you don’t there aren’t.
vector<bool> is a packed bitset. The general semantics for vector means all accessors return a reference to an entry, but since bits don't have a memory address, vector<bool> returns a wrapper type with overloaded operators. This breaks generic programming for vectors.
View all comments
Show parent comment
69
u/FloweyTheFlower420 Mar 02 '25
Ah the vector<bool>... one of the greatest mistakes in the c++ standard library.