Person &findOrCreate(std::string name)
{
for (auto &p : _people)
{
if (p.getName() == name)
return p;
}
_people.push_back(Person(name));
return _people.back();
}
Does this way of adding to the vector at the bottom allow Person(name) to stay in scope as long as the vector ?
Or am I forced to use like a shared_ptr