| Front Page / Algorithms / Iteration Algorithms / fold |
fold
Synopsis
template<
typename Sequence
, typename State
, typename ForwardOp
>
struct fold
{
typedef unspecified type;
};
Description
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 every element of the sequence in the range [begin<Sequence>::type, end<Sequence>::type) in order.
Header
#include <boost/mpl/fold.hpp>
Parameters
| 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. |
Expression semantics
For any Forward Sequence s, binary Lambda Expression op, and arbitrary type state:
typedef fold<s,state,op>::type t;
| Return type: | A type. |
|---|---|
| Semantics: | Equivalent to typedef iter_fold< s,state,apply<op,_1,deref<_2> > >::type t; |
Complexity
Linear. Exactly size<s>::value applications of op.
