1 .. Algorithms/Iteration Algorithms//fold
18 typedef |unspecified| type;
26 Returns the result of the successive application of binary ``ForwardOp`` to the
27 result of the previous ``ForwardOp`` invocation (``State`` if it's the first call)
28 and every element of the sequence in the range |begin/end<Sequence>| in order.
36 #include <boost/mpl/fold.hpp>
42 +---------------+-------------------------------+---------------------------------------------------+
43 | Parameter | Requirement | Description |
44 +===============+===============================+===================================================+
45 | ``Sequence`` | |Forward Sequence| | A sequence to iterate. |
46 +---------------+-------------------------------+---------------------------------------------------+
47 | ``State`` | Any type | The initial state for the first ``ForwardOp`` |
49 +---------------+-------------------------------+---------------------------------------------------+
50 | ``ForwardOp`` | Binary |Lambda Expression| | The operation to be executed on forward |
52 +---------------+-------------------------------+---------------------------------------------------+
58 For any |Forward Sequence| ``s``, binary |Lambda Expression| ``op``, and arbitrary type ``state``:
63 typedef fold<s,state,op>::type t;
76 , apply_wrap2< lambda<op>::type, _1, deref<_2> >
83 Linear. Exactly ``size<s>::value`` applications of ``op``.
91 typedef vector<long,float,short,double,float,long,long double> types;
95 , if_< is_float<_2>,next<_1>,_1 >
96 >::type number_of_floats;
98 BOOST_MPL_ASSERT_RELATION( number_of_floats::value, ==, 4 );
104 |Algorithms|, |accumulate|, |reverse_fold|, |iter_fold|, |reverse_iter_fold|, |copy|, |copy_if|
107 .. copyright:: Copyright © 2001-2009 Aleksey Gurtovoy and David Abrahams
108 Distributed under the Boost Software License, Version 1.0. (See accompanying
109 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)