Boost logo

Boost Users :

Subject: Re: [Boost-users] Odd limitation in Fusion design ?
From: Larry Evans (cppljevans_at_[hidden])
Date: 2010-07-07 21:26:46


On 07/07/10 19:40, John Dlugosz wrote:

> I see that the "Cons" sequence is Forward-only. reverse_view
> requires a Bidirectional sequence, at least. The for_each iteration
> function goes forward.

> However, hand-written recursive loop on a cons-like thing can do
> stuff before and other stuff after the recursive call to the cdr
> portion. Putting stuff "after" will give a reversed processing.
> So, in general, a reversed_for_each is not out of the question, and
> can be specialized for Cons when the general form of iterating
> backwards does not work.
>

> I also ponder that a more general form that indeed does stuff before
> AND other stuff after recursing the tail would be a useful addition.
> It might actually perform one operation iterating forward, then
> perform the other operation iterating backward back to the
> beginning; or use recursion; depending on the nature of the
> container.

[snip]

Sounds like the if_recur template metaprogram found here:

http://svn.boost.org/svn/boost/sandbox/variadic_templates/boost/mpl/if_recur.hpp

does what your asking, except for templates, not values.
I'd guess it could serve as a guide on how to do it for values.

-regards,

Larry


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