How to use boost::lambda together with std::find_if?

c++

Solution

std::find_if(
    vec.begin(), vec.end(),
    bind(&SomeStruct::type, _1) == SomeStruct::Type1 ||
    bind(&SomeStruct::type, _1) == SomeStruct::Type2);

Problem

I have a std::vector and I want to check a specific attribute of each element. SomeStruct has an attribute 'type'. I want to check this attribute to be either Type1 or Type2. My plan is to use boost::lambda. ``` std::vector<SomeStruct>::const_iterator it = std::find_if( vec.begin(), vec.end(), _1.type == SomeStruct::Type1 || _1.type == SomeStruct::Type2); ``` Because I need to access a specific attribute of each element, I'm not sure if I can use boost::lambda at all. Any hints?

Original source