Boost logo

Boost :

Subject: Re: [boost] [mpl]iter_fold_if Forward Backward rationale?
From: David Abrahams (dave_at_[hidden])
Date: 2009-04-03 22:31:04


on Thu Apr 02 2009, Larry Evans <cppljevans-AT-suddenlink.net> wrote:

> One reason I'm interested is that I can't figure out how reverse_fold
> would work on a sequence, S, such that begin<S>::type with just a
> forward iterator. I would have thought that you'd need a
> bidirectional iterator in order to traverse backwards; yet:
>
> https://svn.boost.org/trac/boost/browser/trunk/libs/mpl/test/fold.cpp#L46
>
> shows that it works on lists.

More later, but remember there's recursion involved. You apply the
forward function "on the way in" and the reverse one "on the way out" of
the recursion.

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk