vendredi 29 mai 2015

vector erase-remove idiom compile error

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?

Aucun commentaire:

Enregistrer un commentaire