Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

How to remove an element from a vector using remove_if

void RemovePet(std::vector<Pet> & pets, std::string name) {
    pets.erase(
        std::remove_if(pets.begin(), pets.end(), [&](Pet const & pet) {
            return pet.Name == name;
        }),
        pets.end());
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #How #remove #element #vector
ADD COMMENT
Topic
Name
6+9 =