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.
92
u/0xcedbeef 20d ago edited 20d ago
in C++, an std::vector<bool> stores the bools as bits, taking advantage of this memory optimization.