|
Boost Users : |
From: Thaddeus Olczyk (doctlo-boost_at_[hidden])
Date: 2005-07-28 05:12:25
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>
>, 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> > >)'
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
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