vector erase function brings up an error whereas clear function works. What is the reason for this..?
#include <algorithm>
#include <vector>
#include <iostream>
struct person_id{
person_id() = default;
person_id(int id) : p_id (id) {}
bool operator==(const person_id& other) { return p_id == other.p_id; }
int p_id;
};
using std::cout;
using std::endl;
int main(int argc, char* argv[]) {
std::vector<person_id> people;
person_id tmp_person;
tmp_person.p_id = 5;
people.push_back(tmp_person);
people.erase(5); // error : “No matching function for call 'erase'
people.clear(); // works
return 0;
}