Hacker News new | ask | show | jobs
by imron 3841 days ago
Yes, 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.