Subject: Re: [boost] [mpl]iter_fold_if Forward Backward rationale?
From: Larry Evans (cppljevans_at_[hidden])
Date: 2009-04-02 15:34:38
On 03/13/09 18:49, David Abrahams wrote:
> On Mar 9, 2009, at 10:00 AM, Larry Evans wrote:
>> Why is there both a ForwardOp and BackwardOp template argument to
>> I would have thought that only 1 was needed.
> Yeah, only one is needed if you are only interested in traversing the
> list forward (or backward).
> Remember that list structures can only be built backwards, and
> think about the use of inserters and such with the sequence
> constructing algorithms.
Lists can only be constructed backwards because lists don't have a
push_back? IOW, with only a push_front, the lists have to be
to create list<i1,i2,i3>? So, a traversal from back to front,
(i3->i1), is needed, and, for example,
fold<vector<i1,i2,i3>,list<>, push_front<_,_> >
Instead, to create list<i1,i2,i3> from some sequence, S<i1,i2,i3>,
reverse_fold would be needed:
reverse_fold<S<i1,i2,i3>,list<>, push_front<_,_> >
Is that about what you mean?
Yes. Thank you, David.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk