|
Boost : |
Subject: [boost] [mpl]iter_fold_if Forward Backward rationale?
From: Larry Evans (cppljevans_at_[hidden])
Date: 2009-03-09 13:00:41
Why is there both a ForwardOp and BackwardOp template argument to
iter_fold_if?
https://svn.boost.org/trac/boost/browser/trunk/boost/mpl/iter_fold_if.hpp#L62
I would have thought that only 1 was needed.
Since iter_fold_if is not documented here:
http://www.boost.org/doc/libs/1_38_0/libs/mpl/doc/refmanual/refmanual_toc.html
I assume it's not meant to be used by the user, but is only an
implementation detail; however, it, or a variation, might be useful to
implement the and_seq mentioned here:
http://article.gmane.org/gmane.comp.lib.boost.devel/186204
As shown in that post, the template, while_if_then was used, and it
does not require anything like both a ForwardOp and BackwardOp, it
just requires the If and Then unary metafunctions. One problem I
encountered with while_if_then was moving to the end of the sequence,
at which time the Then metafunction couldn't be called; hence, I had
to make it lazy to avoid dereferencing the end iterator. Is that
somehow related to the need for BackwardOp in iter_fold_if. IOW,
because iter_fold_if might reach the end iterator, it has to backup?
I'm really asking because in the variadic template version of mpl, I
wondering if iter_fold_if could be replaced with something like
while_if_then (which may be renamed fold_if to be more consistent with
other names with similar function).
Any insight about the rationale for the iter_fold_if would probably
save me considerable time in deciding whether it can be replaced with
the proposed fold_if.
-regards,
Larry
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk