c++ delete first element in vector code example
Example 1: c++ vector pop first element
std::vector<int> vect;
vect.erase(vect.begin());
Example 2: remove first element from vector c++
// Deletes the first element from vector v
v.erase(v.begin());
Example 3: 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);
}