J
Jason Heyes
Does the STL have a function like this one?
template <typename T>
void remove(std::vector<T> &v, std::vector<T>::size_type index)
{
std::swap(v[index], v.back());
v.resize(index);
}
Unlike std::vector::erase, it calls T:perator= only three times no matter
what size of vector you are removing from and no matter where the removed
element is located.
template <typename T>
void remove(std::vector<T> &v, std::vector<T>::size_type index)
{
std::swap(v[index], v.back());
v.resize(index);
}
Unlike std::vector::erase, it calls T:perator= only three times no matter
what size of vector you are removing from and no matter where the removed
element is located.