Boost lambda question
Hi I have a Boost lambda question, I appreciate is someone can help me out: I have a class A: class A{ private: B& getB() {return _b;} B& _b; }; vector<A> aList; void aFunction (A& a, B& b); how can I write a loop to walk thru a list of A and call aFunction. for (vector<A>::iterator itr = aList.begin; itr != end; itr++) { A a = (*itr); aFunction (a, a->getB()); } __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
On 2/27/06, yinglcs2@yahoo.com
Hi I have a Boost lambda question, I appreciate is someone can help me out:
I have a class A: class A{ private: B& getB() {return _b;} B& _b; };
vector<A> aList;
void aFunction (A& a, B& b);
how can I write a loop to walk thru a list of A and call aFunction.
for (vector<A>::iterator itr = aList.begin; itr != end; itr++) { A a = (*itr); aFunction (a, a->getB()); }
For a start, shouldn't it be aFunction(a, a.getB()); - a's got no operator->. If so, use this std::for_each(aList.begin(), aList.end(),bind(&aFunction, _1, bind(&A::getB, _1))); HTH Stuart Dootson
participants (2)
-
Stuart Dootson
-
yinglcs2@yahoo.com