lundi 5 juillet 2021

Proper lambda syntax for removing elements of the vector

ALL,

class Foo
{
private:
    std::vector<std::string> vec;
};

void Foo::Remove(const std::string &table)
{
    vec.erase( std::remove_if( vec.begin(), vec.end, [](const std::string &str)
    {
        str.find( table ) != -1;
    }, vec.end() ) );
}

How do I proper capture the table parameter inside the lambda? And is my syntax correct? I need to remove the elements of vec that contain the table.

TIA!

Aucun commentaire:

Enregistrer un commentaire