...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 / iter_fold |
template< typename Sequence , typename State , typename ForwardOp > struct iter_fold { typedef unspecified type; };
Returns the result of the successive application of binary ForwardOp to the result of the previous ForwardOp invocation (State if it's the first call) and each iterator in the range [begin<Sequence>::type, end<Sequence>::type) in order.
#include <boost/mpl/iter_fold.hpp>
Parameter | Requirement | Description |
---|---|---|
Sequence | Forward Sequence | A sequence to iterate. |
State | Any type | The initial state for the first ForwardOp application. |
ForwardOp | Binary Lambda Expression | The operation to be executed on forward traversal. |
For any Forward Sequence s, binary Lambda Expression op, and an arbitrary type state:
typedef iter_fold<s,state,op>::type t;
Return type: | A type. |
---|---|
Semantics: | Equivalent to typedef begin<Sequence>::type i1; typedef apply<op,state,i1>::type state1; typedef next<i1>::type i2; typedef apply<op,state1,i2>::type state2; ... typedef apply<op,staten-1,in>::type staten; typedef next<in>::type last; typedef staten t; where n == size<s>::value and last is identical to end<s>::type; equivalent to typedef state t; if empty<s>::value == true. |
Linear. Exactly size<s>::value applications of op.