|
Boost Users : |
From: Thaddeus Olczyk (doctlo-boost_at_[hidden])
Date: 2005-08-08 06:21:56
Here I go again.
This time the code is:
#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;
typedef StrList::const_iterator (StrList::* StrListFind)(const
StrList::key_type&) const;
typedef std::pair <StrList::iterator,bool> (StrList::*
StrListInsert)(const
StrList::value_type& _Val);
StrListFind strListFind=&StrList::find;
StrListInsert strListInsert=&StrList::insert;
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(strListFind,&excluded,bind(&A::get,_1)))
!=excluded.end()),
bind(strListInsert,&excluded,bind(&A::get,_1)));
std::for_each(alist.begin(),alist.end(),
bind(&A::print_A,_1));
return 1;
}
The compiler output is:
g++ -g -o test.exe
-I/cy/f/Programs/development/boost_1_32_0/nocygwin/include/boost-1_32/
main2.cpp
main2.cpp: In function `int main()':
main2.cpp:50: error: no matching function for call to `if_then(const
boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::relational_action<boost::lambda::notequal_action>,
boost::tuples::tuple<boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::action<3,
boost::lambda::function_action<3, boost::lambda::detail::unspecified>
>, boost::tuples::tuple<std::_Rb_tree_const_iterator<std::string>
(std::set<std::string, std::less<std::string>,
std::allocator<std::string> >::*const)(const std::string&) const,
StrList* const, 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> > >,
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> > >, const
std::_Rb_tree_const_iterator<std::string>, 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> > >)'
make: *** [test.exe] Error 1
Any idea what is wrong?
Thanks
-- 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