Call for_each with boost::lambda library
Hi, I am trying to Call for_each with boost::lambda library to print out the return value of a function: vector<A> aList; for_each(aList.begin(), aList.end(), cout << bind(&A::getPriority, _1) ); This can't compile. can yo please tell me what did I do wrong? __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
On 3/8/06, yinglcs2@yahoo.com <yinglcs2@yahoo.com> wrote:
Hi,
I am trying to Call for_each with boost::lambda library to print out the return value of a function:
vector<A> aList;
for_each(aList.begin(), aList.end(), cout << bind(&A::getPriority, _1) );
This can't compile. can yo please tell me what did I do wrong?
Without more detail (e.g. error message, what does A look like...), it's difficult to tell.... Here's a minimal example that *does* compile - where is your code different... #include <vector> #include <iostream> #include <algorithm> #include <boost/lambda/lambda.hpp> #include <boost/lambda/bind.hpp> using namespace std; using namespace boost::lambda; class A { public: int getPriority() const { return 1; } }; void x() { vector<A> aList; for_each(aList.begin(), aList.end(), cout << bind(&A::getPriority, _1) ); } Stuart Dootson
participants (2)
-
Stuart Dootson
-
yinglcs2@yahoo.com