[prev in list] [next in list] [prev in thread] [next in thread]
List: boost-users
Subject: Re: [Boost-users] Boost lambda question
From: "Stuart Dootson" <stuart.dootson () gmail ! com>
Date: 2006-02-28 7:31:39
Message-ID: 8b56cad40602272331i6bcced7qcff4add4c58427d1 () mail ! gmail ! com
[Download RAW message or body]
On 2/27/06, yinglcs2@yahoo.com <yinglcs2@yahoo.com> wrote:
> 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
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic