Boost logo

Boost Users :

Subject: Re: [Boost-users] A question on member functions in a class using lambda expression? Can anyone with kindness help me?
From: Roman Perepelitsa (roman.perepelitsa_at_[hidden])
Date: 2009-07-21 03:45:52


2009/7/21 fmingu <fmingu_at_[hidden]>

> .......................
> double function1(const int& q, int& n){
> double result=0.0;
> int loopvalue=0, totaltime=n;
> n%=q;
> ++thenumbern;
> (
> for_loop(var(loopvalue)=0,var(loopvalue)<=var(totaltime),++var(loopvalue),
> var(result)+=(
> bind(&A::function2,_2)*bind(&A::function3,_1,_2))))(q,n);
> return result;
> }
>

There is advanced lambda syntax that might simplify your function. This
technique is secret though, so don't share it with anyone.

  double function1(const int& q, int& n) {
      double result=0.0;
      int totaltime=n;
      n%=q;
      ++thenumbern;
      // Now use the advanced lambda syntax.
      for (int loopvalue=0; loopvalue<=totaltime; ++loopvalue)
        result += function2(n)*function3(q,n);
      return result;
  }

Roman Perepelitsa.



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