3 ms·
Vector<bool> is often specialized to take 1 bit per element, so that's another one.
by okasaki 11y ago
Vector<bool> is often specialized to take 1 bit per element, so that's another one.
- imron 11y agoYes, and like a vector containing > 2 billion single byte elements it's still delving in to a very peculiar use case. Compared to the majority of other uses of std::vector which will never be able to overflow signed ints. I get from a logical point of view that size() would never be < 0 therefore it makes sense to use an unsigned int, however from a practical point of view it also makes programs more susceptible to a number of pernicious bugs that can catch out unsuspecting programmers, e.g. things like for ( size_t i = v.size(); i >= 0; --i ) { ... } Which would work fine with a signed int, but here it will just loop infinitely.