
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

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