3 ms·
C++ tried to use template specialization with std::vector<bool> to take advantage of bool-ness and provide a dense storage for bits, but it suffers for reasons
by slackpad 13y ago
C++ tried to use template specialization with std::vector<bool> to take advantage of bool-ness and provide a dense storage for bits, but it suffers for reasons Linus points out here, namely the inability to cleanly address individual elements of the vector (so it doesn't behave exactly like a normal std::vector).
- twoodfin 13y agoRight. At the time, as I understand it, the standards committee thought reference semantics and operator overloading would be powerful enough to create perfect "proxy" objects that would be indistinguishable from their direct equivalents. std::vector<bool> ended up demonstrating the opposite. std::bitset<N> is quite nice though, as long as you have a fixed size.