0

I have the following removeOneParam(Parameter* param) code which is from this answer:

class A
    {
        private:
          std::vector<Parameter*> params;
        public:
          void removeOneParam(Parameter* param)
          {
            params.erase(std::remove(params.begin(), params.end(), param), params.end());
          }
}

But I get the following compile error:

error: cannot convert ‘std::vector<Parameter*>::iterator {aka __gnu_cxx::__normal_iterator<Parameter**, std::vector<Parameter*> >}’ to ‘const char*’ for argument ‘1’ to ‘int remove(const char*)

How can I use that answer to my case?

Community
  • 1
  • 1
peterboston
  • 877
  • 1
  • 12
  • 24

3 Answers3

2

Your compiler is picking up the version of std::remove in the cstdio header, not the one you want. You're probably missing #include <algorithm>.

TartanLlama
  • 63,752
  • 13
  • 157
  • 193
1

It seems to me, that header algorithm is not included. Try to

#include <algorithm>

and then all should work fine.

ForEveR
  • 55,233
  • 2
  • 119
  • 133
0

Try to include at the top of your program include <algorithm>

That should make the errors disappear.

Zero Tap
  • 1
  • 7