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() ||
!pre_erase(pos))
    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 d.maley@stmarys-belfast.ac.uk.

Ivor Spence is with Queen's University of Belfast. He can be contacted at i.spence@qub.ac.uk.

Featured

Most   Popular
Upcoming Events

AppTrends

Sign up for our newsletter.

I agree to this site's Privacy Policy.