Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to remove an element from a vector by value

Tags:

c++

vector

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.

like image 364
John Smith Avatar asked Jul 07 '26 14:07

John Smith


1 Answers

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.

like image 194
Ivan Smirnov Avatar answered Jul 09 '26 06:07

Ivan Smirnov