C++ stl中remove的实现

原文:http://www.cplusplus.com/reference/algorithm/remove/

c++98中的实现:

template <class ForwardIterator, class T>
  ForwardIterator remove (ForwardIterator first, ForwardIterator last, const T& val)
{
  ForwardIterator result = first;
  while (first!=last) {
    if (!(*first == val)) {
      *result = *first;
      ++result;
    }
    ++first;
  }
  return result;
}

你可能感兴趣的:(remove)