Turns out that I wasn't including the required headers. It appears that <boost/lambda/bind.hpp>
only brings in bind
functionality, and the operator overloads for the resulting type are not included. If I add #include <boost/lambda/lambda.hpp>
to the above, then it resolves the compiler error that I referenced. The final revised code (fixing another error in the type of the return value from find_if()
) is as follows:
#include <boost/lambda/bind.hpp>
#include <boost/lambda/lambda.hpp>
#include <boost/range/algorithm/find_if.hpp>
#include <string>
#include <vector>
using namespace std;
using namespace boost;
using namespace boost::lambda;
struct foo
{
string s;
int x;
};
int main()
{
// create list and add a couple entries
vector<foo> fooList;
foo f1 = {"abc", 1};
foo f2 = {"def", 2};
fooList.push_back(f1);
fooList.push_back(f2);
// search for a value with the desired member
typename range_iterator<vector<foo> >::type it = find_if(fooList, bind(&foo::s, _1) == "abc");
return 0;
}