Answers for "delete specific vector element c++"

C++
23

delete specific vector element c++

#include <algorithm>
#include <vector>

// using the erase-remove idiom

std::vector<int> vec {2, 4, 6, 8};
int value = 8 // value to be removed
vec.erase(std::remove(vec.begin(), vec.end(), value), vec.end());
Posted by: Guest on February-23-2020

Browse Popular Code Answers by Language