Boost logo

Boost Users :

From: Daniel James (daniel_at_[hidden])
Date: 2004-07-29 12:38:42


On Wed, 28 Jul 2004 16:19:21 +0200, Mattias Brändström wrote:

> To me it seems that this is something that I should be able to do with
> the BLL. If someone could point me in the right direction here I would
> be really greatful!

Hi,

You're almost there. The problem is that you're using boost::bind
instead of boost::lambda::bind. I think that boost::bind is more
portable, but it doesn't support lambda expressions. Here's a working
version of your code:

#include <algorithm>
#include <vector>
#include <boost/lambda/lambda.hpp> // needed for lambda operators
#include <boost/lambda/bind.hpp> // not boost/bind.hpp

class Foo {
public:
   int bar() { return 42; }
};

int main()
{
   std::vector<Foo> v;
   v.push_back(Foo());

   using namespace boost::lambda;
   std::count_if(v.begin(), v.end(), bind(&Foo::bar, _1) == 42);

   return 0;
}

Daniel


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