In page 456 of TC++PL, Stroustrup says "When a vector is resized to accomodate more (or fewer) elements, all of its elements may be moved to new locations." I know that if the size is increased, then a reallocation will happen if the capacity is exceeded. But I thought this could never happen if the size is decreased, say by pop_back(). I have an algorithm which grows a vector by a sequence of push_back()s and pop_back()s, with a known upper bound N to the size, and would like to do
Code:
  vector<T> v;
  v.reserve(N);
followed by a sequence of push_back()s and pop_back()s such that the size is always between 0 and N. Can there ever be a reallocation? If not, any idea what Stroustrup was talking about?