|
Boost Users : |
From: Luis De la Parra (lparrab_at_[hidden])
Date: 2004-02-21 07:07:54
hello,
I don't have much experience with boost, so I'm having problems getting boost
lambda to work...hope someone here can point me in the right direction.
I have:
class Song
{public:
string artist( ) const { return m_artist }
string title( ) const { return m_title }
private:
string m_artist, m_title;
}
typedef boost::shared_ptr<Song> pSong;
vector<pSong> c;
and I am trying to use lambda to find a song in c which matches a certain
artist and title...something like
iterator it = find_if( c.begin(), c.end(), something )
but I havn't figured out what "something" should look like
I've tried
find_if(begin(),end(), (_1->artist() == "a1" && _1->title = "t1" ) );
but the compiler -- or I =) -- doesn't seem to know the type of _1
--> error: base operand of `->' has non-pointer type `const
boost::lambda::lambda_functor<boost::lambda::placeholder<1> >'
If I try
it = find_if(begin(),end(), boost::bind(&Song::artist,_1) == "a1" );
it fails because "_1" is ambiguos (defined as lambda/placeholder and
boost/arg )
using boost::lambda::bind (and not including the "normal" bind ) gives a
bunch cryptic errors...
I've tried several other variants with lambda / lambda::bind / boost::bind but
I havn't figured it out... can anyone help me out?
I'd also like to know what's the difference between boost::bind and
boost::lambda::bind ?
Also... is there a way to know when a lambda object is going to be
constructed?, it's probably just that I don't know much about the BLL, but in
cases where you have several nested lambdas and binds, I'm not sure which
lambda objects will get constructed.
regards,
luis
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net