...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Front Page / Algorithms / Iteration Algorithms / reverse_iter_fold |
template< typename Sequence , typename State , typename BackwardOp , typename ForwardOp = _1 > struct reverse_iter_fold { typedef unspecified type; };
Returns the result of the successive application of binary BackwardOp to the
result of the previous BackwardOp invocation (State if it's the first call)
and each iterator in the range [begin
#include <boost/mpl/reverse_iter_fold.hpp>
Parameter | Requirement | Description |
---|---|---|
Sequence | Forward Sequence | A sequence to iterate. |
State | Any type | The initial state for the first BackwardOp / ForwardOp application. |
BackwardOp | Binary Lambda Expression | The operation to be executed on backward traversal. |
ForwardOp | Binary Lambda Expression | The operation to be executed on forward traversal. |
For any Forward Sequence s, binary Lambda Expression backward_op and forward_op, and arbitrary type state:
typedef reverse_iter_fold< s,state,backward_op >::type t;
Return type: | A type. |
---|---|
Semantics: | Equivalent to typedef begin where n == size |
typedef reverse_iter_fold< s,state,backward_op,forward_op >::type t;
Return type: | A type. |
---|---|
Semantics: | Equivalent to typedef reverse_iter_fold< Sequence , iter_fold |
Linear. Exactly size::value applications of backward_op and forward_op.
Build a list of iterators to the negative elements in a sequence.
typedef vector_cnumbers; typedef list_c negatives; typedef reverse_iter_fold< numbers , list<> , if_< less< deref<_2>,int_<0> >, push_front<_1,_2>, _1 > >::type iters; BOOST_MPL_ASSERT(( equal< negatives , transform_view< iters,deref<_1> > > ));