Boost logo

Boost Users :

Subject: [Boost-users] lambda::bind and abstract class - how to?
From: Archie14 (admin_at_[hidden])
Date: 2010-03-05 08:33:41


Here is the sample that fails to compile. Complain is about foo being abstract
in IA. Any advise of how to make it work will be greatly appreciated.

#include <boost/lambda/lambda.hpp>
#include <boost/lambda/bind.hpp>
#include <boost/ptr_container/ptr_vector.hpp>

class IA
{
public:
        virtual int foo() const = 0;
};

class B : public IA
{
public:
        B (int a) : _a(a) {};
        int foo() const {return _a;}
private:
        int _a;
};

int _tmain(int argc, _TCHAR* argv[])
{
        boost::ptr_vector<IA> lst;
        lst.push_back(new B(1));
        lst.push_back(new B(2));

        boost::ptr_vector<IA>::iterator it =
                std::find_if (lst.begin(),
                                lst.end(),
                                boost::lambda::bind(&IA::foo,
boost::lambda::_1) == 1);
        return 0;
}


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