[Boost Lambda] Simple problem using argument as object: part III

, boost::tuples::tuple<std::string (A::*const)(), const boost::lambda::lambda_functor<boost::lambda::placeholder<1> >, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> > >)'
Ok. I'm still not getting it. Sorry for the inconvenience. Another piece of sample code that doesn't compile. Thanks. #include <boost/lambda/lambda.hpp> #include <boost/lambda/bind.hpp> #include <boost/lambda/if.hpp> #include <vector> #include <set> #include <string> #include <iostream> using boost::lambda::_1; using boost::lambda::bind; class A { std::string s; public: A(std::string sIn):s(sIn){} void print_A() { std::cout<<"A="<<s<<std::endl; } bool isLong() { return s.length()>5; } std::string get(){return s;} }; typedef std::vector<A *> AList; typedef std::set<std::string> StrList; int main() { std::string in; AList alist; StrList excluded; while(in!="end") { in=""; std::getline(std::cin,in); alist.push_back(new A(in)); } std::for_each(alist.begin(),alist.end(), boost::lambda::if_then((bind(&StrList::find,&excluded,bind(&A::get,_1))) !=excluded.end()), bind(&StrList::insert,&excluded,bind(&A::get,_1))); std::for_each(alist.begin(),alist.end(), bind(&A::print_A,_1)); return 1; } ----------------------------------- main2.cpp:43: error: no matching function for call to `bind(<unknown type>, StrList*, const boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::action<2, boost::lambda::function_action<2, boost::lambda::detail::unspecified> main2.cpp:45: error: no matching function for call to `bind(<unknown type>, StrList*, const boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::action<2, boost::lambda::function_action<2, boost::lambda::detail::unspecified>
, boost::tuples::tuple<std::string (A::*const)(), const boost::lambda::lambda_functor<boost::lambda::placeholder<1> >, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> > >)'
-- Thad

Hi, The first thing that jumps to mind is that you need to disambiguate which find and insert methods you mean. Untested code... --- typedef StrList::const_iterator (StrList::* StrListFind)(const StrList::key_type&) const; typedef std::pair <StrList::iterator,bool> (StrList::* StrListInsert)(const StrList::value_type& _Val); std::for_each( alist.begin(), alist.end(), boost::lambda::if_then( bind( static_cast<StrListFind>(&StrList::find),&excluded,bind(&A::get,1))!=exclude d.end(), bind( static_cast<StrListInsert>(&StrList::insert),&excluded,bind(&A::get,_1) ) ) ); ---- HTH, Richard. //-----Original Message----- //From: boost-users-bounces@lists.boost.org //[mailto:boost-users-bounces@lists.boost.org] On Behalf Of //Thaddeus Olczyk //Sent: 28 July 2005 11:12 //To: boost-users@lists.boost.org //Subject: [Boost-users] [Boost Lambda] Simple problem using //argument asobject: part III // //Ok. I'm still not getting it. Sorry for the inconvenience. //Another piece of sample code that doesn't compile. Thanks.
participants (2)
-
Richard Crossley
-
Thaddeus Olczyk