Simple example using boost::phoenix:
#include <vector>
#include <algorithm>
#include <boost/phoenix.hpp>
namespace ph = boost::phoenix;
namespace place = boost::phoenix::placeholders;
struct A
{
int val_;
explicit A(int i) : val_(i) {}
int foo() { return val_;}
};
int main()
{
std::vector<A> coll;
coll.push_back(A(2));
coll.push_back(A(4));
coll.push_back(A(5));
coll.push_back(A(7));
std::vector<A>::const_iterator cit;
cit = std::find_if(coll.begin(), coll.end(), ph::bind(&A::foo, place::_1) % 2 == 1);
int val = (*cit).val_;
return 0;
}
It compiles but there are some warnings at the output of VS2008:
c:\boost_1_47_0\boost\phoenix\bind\detail\member_variable.hpp(54) : warning C4180: qualifier applied to function type has no meaning; ignored
Where it came from: 1) incorrectness in code 2) again MS problems. 3) boost::phoenix library not doing well?