3rdParty/boost/1.78.0/libs/mpl/doc/refmanual/iter-fold.html
| Prev Next | Back Along | Up Home | Full TOC | Front Page / Algorithms / Iteration Algorithms / iter_fold |
template<
typename Sequence
, typename State
, typename ForwardOp
>
struct[iter\_fold](./iter-fold.html){
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](../../../../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](./iter-fold.html)<s,state,op>::type t;
| Return type: |
A type.
| | Semantics: |
Equivalent to
typedef[begin](./begin.html)<s>::type i1;
typedef[apply](./apply.html)<op,state,i1>::type state1;
typedef[next](./next.html)<i1>::type i2;
typedef[apply](./apply.html)<op,state1,i2>::type state2;_..._typedef[apply](./apply.html)<op,staten-1,in>::type staten;
typedef[next](./next.html)<in>::type last;
typedef statent;
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.
typedef[vector\_c](./vector-c.html)<int,5,-1,0,7,2,0,-5,4> numbers;
typedef[iter\_fold](./iter-fold.html)<
numbers
,[begin](./begin.html)<numbers>::type
,[if\_](./if.html)<[less](./less.html)<[deref](./deref.html)<[\_1](./placeholders.html)>,[deref](./deref.html)<[\_2](./placeholders.html)> >,[\_2](./placeholders.html),[\_1](./placeholders.html)>
>::type max_element_iter;[BOOST\_MPL\_ASSERT\_RELATION](./assert-relation.html)([deref](./deref.html)<max_element_iter>::type::value, ==, 7 );
Algorithms, reverse_iter_fold, fold, reverse_fold, copy
| Prev Next | Back Along | Up Home | Full TOC |
Copyright © 2001-2009 Aleksey Gurtovoy and David Abrahams Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |