dimanche 26 mai 2019

Invalid operand to binary expression C++11 when using lambda

I am trying to get iterator to an object in a vector

This is my code

std::string itemData="SomeData";
std::vector<foo> myVec;
//.....     //Add items to myVec;
std::find(myVec.begin(), myVec.end(), [itemData](const foo& data){
    return data.getName() == itemData;
});

I get an error saying

Error:(999, 22) invalid operands to binary expression ('foo' and 'const (lambda at filename.cpp:5404:73)')

Any suggestions on what might be the cause ?

Aucun commentaire:

Enregistrer un commentaire