lambda::bind and abstract class - how to?

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

On Fri, Mar 5, 2010 at 1:33 PM, Archie14
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
#include #include 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; }
Replacing boost::lambda::_1 with &boost::lambda::_1 makes my compiler (gcc 4.1.1) stop complaining. Is that what you need? - Rob.
participants (2)
-
Archie14
-
Robert Jones