Question
Posted: December 7th, 2017, 1:45 am
I think i know the relationship between smart pointers and scope. If a container (vector) holds a smart pointer then it is responsible for freeing it ? .. correct ? as in this example.
Code: Select all
void EntityManager::Refresh()
{
for (auto i(0u); i < maxGroups; i++)
{
auto& v(groups[i]);
v.erase(std::remove_if(std::begin(v),std::end(v),
[i](Entity* ent)
{
return !ent->Active() || !ent->HasGroup(i);
}
), std::end(v));
}
entities.erase(std::remove_if(std::begin(entities), std::end(entities),
[](const std::unique_ptr<Entity>& inEnt)
{
return !inEnt->Active();
}), std::end(entities));
}