c ++ find_if лямбда
Что не так с кодом ниже? Предполагается найти элемент в списке структур, если первый из структуры 's memebers == 0. Компилятор жалуется, что лямбда-аргумент не относится к типу Predicate.
#include
#include
#include
#include
#include
struct S
{
int S1;
int S2;
};
using namespace std;
int main()
{
list l;
S s1;
s1.S1 = 0;
s1.S2 = 0;
S s2;
s2.S1 = 1;
s2.S2 = 1;
l.push_back(s2);
l.push_back(s1);
list::iterator it = find_if(l.begin(), l.end(), [] (S s) { return s.S1 == 0; } );
}