remove a specific element from vector c++ code example
Example 1: c++ remove element from vector
vector.erase(position) // remove certain position
// or
vector.erase(left,right) // remove positions within range
Example 2: vector erase specific element
template <typename T>
void remove(std::vector<T>& vec, size_t pos)
{
std::vector<T>::iterator it = vec.begin();
std::advance(it, pos);
vec.erase(it);
}