Boost logo

Boost Users :

From: (vkrasovsky_at_[hidden])
Date: 2004-07-29 02:15:48

Hello Mattias,

Wednesday, July 28, 2004, 6:19:21 PM, you wrote:

MB> Hello!

MB> I am new to the boost lambda library so this might be a naive question.
MB> Here goes. This is what I want to do:

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

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

MB> count_if(v.begin(), v.end(), boost::bind(&Foo::bar, _1) == 42);

MB> return 0;
MB> }

You may try something like this:

#include <vector>
#include <boost/bind.hpp>
#include <functional>

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

int main(int argc, char* argv[])
        std::vector<Foo> v;

        size_t c =
                                boost::bind(Foo::bar, _1),

        return 0;

This compiles ok on MS VC7.1, but it doesn't use lambda, only bind.

Best regards,

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at