[boost-users][bind/lambda] how to

Hello, struct Inner { bool good() const; }; struct Outer { Inner inner_; const Inner &inner() const { return inner_; } }; std::vector<Outer> outers; I'd like to find Outer whose Inner is good(): std::find_if(outers.begin(), outers.end(), ?); How should I use boost::bind or boost::lambda to tell the stl algorithms to call Inner::good()? Thank you in advance!

I think what you're after is documented here: http://www.boost.org/doc/libs/1_35_0/libs/bind/bind.html#nested_binds Here's my attempt (though I haven't got access to a compiler atm): function1<bool, Outer*> func = boost::bind(&Inner::good, boost::bind(&Outer::inner, _1)); find_if(outers.begin(), outers.end(), func); Hope that helps! Alex 2008/7/8 Igor R <boost.lists@gmail.com>:
Hello,
struct Inner { bool good() const; }; struct Outer { Inner inner_; const Inner &inner() const { return inner_; } };
std::vector<Outer> outers;
I'd like to find Outer whose Inner is good():
std::find_if(outers.begin(), outers.end(), ?);
How should I use boost::bind or boost::lambda to tell the stl algorithms to call Inner::good()?
Thank you in advance! _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Alex MDC
-
Igor R