Boost logo

Boost Users :

From: Thaddeus Olczyk (doctlo-boost_at_[hidden])
Date: 2005-07-26 15:09:14


Thank you for your quick replies, and apologies for asking what
are probably quite simple questions. However I find the documentation
of Lambda a bit confusing.

Another sample I am having problems with:
#include <boost/lambda/lambda.hpp>
#include <boost/lambda/bind.hpp>
#include <boost/lambda/if.hpp>
#include <vector>
#include <string>
#include <iostream>

using boost::lambda::_1;

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;
  }
};

int main()
{
 std::string in;
 std::vector<A *> alist;
 std::vector<A *> longAList;
 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(&A::isLong,_1),longAList.push_back(_1)));
 return 1;
}

--------------------------------------
main.cpp: In function `int main()':
main.cpp:37: error: no matching function for call to `std::vector<A*,
std::allocator<A*> >::push_back(const
boost::lambda::lambda_functor<boost::lambda::placeholder<1> >&)'

Suggestions?
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