|
Boost Users : |
From: Alexander Borghgraef (alexander.borghgraef.rma_at_[hidden])
Date: 2005-09-27 09:17:45
On 9/27/05, Stuart Dootson <stuart.dootson_at_[hidden]> wrote:
> That's not going to work because the operator() call in the loop (i.e.
> m(...)) is evaluated when the lambda expression is created, not each
> time the lambda expression is evaluated.
>
> Try replacing
>
> var( m( c / m.w, c % m.w ) )
>
> with
>
> bind(&MyMatrix::operator(), var(m), var(c) / m->*&MyMatrix::w, var(c)
> % m->*&MyMatrix::w)
>
> This makes all accesses to m & c lazy (I think), so should update m as you
> want.
>
Ok, that fixes it. Now, hardcore algorithmism aside, I don't see any
advantage in this over the
for loop: it's slower, and can hardly be called an improvement in
readability. So I think I'll stick to
the old-fashioned syntax in this case. Still, interesting to know that
boost::lambda actually can do
this.
-- Alex Borghgraef
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