I disagree that a signed type is the correct solution to that, rather you need a while loop:
std::size_t i = foo.size();
while (i != 0) {
--i;
...
} std::size_t i = foo.size();
while (i != 0) {
--i;
...
}It's also worth pointing out the style of loop they give can't be used at all if you are counting down iterators or pointers instead of numbers.