Trying to remove an element from a vector by value

c++, vector

Solution

You were most likely trying to call this function instead the correct one. Probably you don't have `<algorithm>` included so the compiler can't see the overloaded version of the function.

Problem

``` error: cannot convert 'std::vector<int>::iterator {aka __gnu_cxx::__normal_iterator<int*, std::vector<int> >}' to 'const char*' for argument '1' to 'int remove(const char*) ``` When I am doing ``` vec.erase(std::remove(vec.begin(), vec.end(), valToRemove), vec.end()); ``` valToRemove is an int.

Original source