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
Michael Crawford wrote:
(boost::lambda::_1 ->* &Log::getName) == name
This should be (boost::lambda::_1 ->* &Log::getName)() == name because getName is a function.
boost::bind(&Log::getName, boost::bind(&LogPtr::get, _1)) == name
boost::bind( &Log::getName, _1 ) == name is enough; boost::bind handles shared_ptr directly. With lambda, you need lambda::bind( &Log::getName, *_1 ) == name
participants (2)
-
Michael Crawford
-
Peter Dimov