Boost logo

Boost Users :

From: David Abrahams (dave_at_[hidden])
Date: 2006-04-08 10:42:36


"chun ping wang" <cablepuff_at_[hidden]> writes:

> std::for_each(
> // iterate through (Need, Alloc, Finish).
> boost::make_zip_iterator(boost::make_tuple(beg1, beg2, beg3)),
> boost::make_zip_iterator(boost::make_tuple(end1, end2, end3)),
> (
> Parts where i wish to use lambda for abstraction .
> Assume:
> _1 = Need[i],
> _2 = Alloc[i],
> _3 = Finish[i],
> if (_1 == false && _3 <= Work)
> {
> _3 = true;
> Work += _2;
> }
> ++var(ind)
> )
> );

Ah. What you want is a way to wrap a lambda expression so that it accepts
a single tuple argument and exposes each element of the tuple to the
wrapped lambda expression as a separate argument. It should be
possible, but we'll have to ask Jaakko and Gary for details. I'm
pretty sure it's possible using Fusion and Spirit-2, but you'd need a
different version of zip_iterator.hpp (one that's checked in on a
branch of Boost's CVS).

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

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