I want to delete a unique_pointer from a std::vector.
class Obj
{
std::string name;
std::string getName();
}
Now i have a vector of unique pointers of the class obj Obj
std::vector<std::unique_ptr<Obj>> objects;
for( int i = 0; i < objects.size(); i++)
{
if( objects[i]->getName() == "NameOftheObject" )
objects.erase( objects.begin() + i );
}
Now instead of running a loop can we do this through standard algorithm ?
Aucun commentaire:
Enregistrer un commentaire