dimanche 14 novembre 2021

Problem deleting a pair Object from a vector using erase() method

I've been trying to delete an object from a vector. the error message I get is:

/usr/include/c++/9/bits/stl_algobase.h:361:18: error: use of deleted function ‘std::pair<int, Workout>& std::pair<int, Workout>::operator=(const std::pair<int, Workout>&)’
  361 |        *__result = std::move(*__first);
      |        ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~

I used the erase() method as follows: (in a for loop)

vectorName.erase(vectorName.begin() + i);

I tried using other methods, such as remove_if() and couldn't do that either.

Aucun commentaire:

Enregistrer un commentaire