Reputation: 3697
I've looked around, and it seems to me that the consensus answer for this problem is this method;
template <typename T>
void removeByValue(vector<T> & vec, const T & val)
{
vec.erase(std::remove(vec.begin(), vec.end(), val), vec.end());
}
However, I get the error error C2660: 'remove' : function does not take 3 arguments
when trying to compile it. Why is it giving me this error?
Upvotes: 1
Views: 3161
Reputation: 283893
std::remove
is only available if you include header <algorithm>
.
This is clearly stated by the MSDN documentation here as well as any C++ reference.
Upvotes: 3