Redefinition of vector<T, Alloc> ::erase(iterator).

Supporting Design by Contract in C++
by David Maley and Ivor Spence
Listing 7. Redefinition of vector<T, Alloc> ::erase(iterator).

iterator stdpp::vector<T>::erase(iterator pos)
  if (!size() || pos<begin() || pos>=end() ||
    throw vector<T>();
  vector<T> old(*this);
  iterator newPos = std::vector<T>::erase(pos);
  if (!post_erase(old, newPos) || !inv())
    throw vector<T>();
  return newPos;

About the Authors

David Maley is with St. Mary's University College, Belfast. He can be contacted at

Ivor Spence is with Queen's University of Belfast. He can be contacted at


Upcoming Events


Sign up for our newsletter.

Terms and Privacy Policy consent

I agree to this site's Privacy Policy.