Boost logo

Boost Users :

Subject: [Boost-users] [lambda] shared_ptr's in lambda expressions
From: Michael Crawford (mbcrawfo_at_[hidden])
Date: 2009-06-28 19:28:25


I have the following piece of code:
void MultiLog::removeLog(const std::string& name)
{
  std::remove_if(m_logs.begin( ), m_logs.end( ), (boost::lambda::_1 ->*
&Log::getName) == name);
}
Which fails to compile with the typical spectacular list of template error
messages, the first of which is
"error C2784 ... could not deduce template argument for 'const
boost::lambda::lambda_functor<T> &' from
'boost::lambda::detail::member_pointer_caller<RET,A,B>'"
I'm assuming that the error is because each element here is a
shared_ptr<Log>, rather than a raw pointer to Log. Using bind to wrap
shared_ptr::get appears to work:
void MultiLog::removeLog(const std::string& name)
{
  std::remove_if(m_logs.begin( ), m_logs.end( ),
    boost::bind(&Log::getName, boost::bind(&LogPtr::get, _1)) == name);
}
but is there are way to use the significantly cleaner & clearer member
pointer operator syntax while using shared_ptr's?
Thanks,
MBC



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