| 1 | <?xml version="1.0" encoding="utf-8" ?> |
|---|
| 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|---|
| 3 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
|---|
| 4 | <!-- Copyright Aleksey Gurtovoy 2006. Distributed under the Boost --> |
|---|
| 5 | <!-- Software License, Version 1.0. (See accompanying --> |
|---|
| 6 | <!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) --> |
|---|
| 7 | <head> |
|---|
| 8 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
|---|
| 9 | <meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" /> |
|---|
| 10 | <title>The MPL Reference Manual: accumulate</title> |
|---|
| 11 | <link rel="stylesheet" href="../style.css" type="text/css" /> |
|---|
| 12 | </head> |
|---|
| 13 | <body class="docframe refmanual"> |
|---|
| 14 | <table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./reverse-iter-fold.html" class="navigation-link">Prev</a> <a href="./querying-algorithms.html" class="navigation-link">Next</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./reverse-iter-fold.html" class="navigation-link">Back</a> Along</span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./iteration-algorithms.html" class="navigation-link">Up</a> <a href="../refmanual.html" class="navigation-link">Home</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./refmanual_toc.html" class="navigation-link">Full TOC</a></span></td> |
|---|
| 15 | <td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./algorithms.html" class="navigation-link">Algorithms</a> / <a href="./iteration-algorithms.html" class="navigation-link">Iteration Algorithms</a> / <a href="./accumulate.html" class="navigation-link">accumulate</a></td> |
|---|
| 16 | </tr></table><div class="header-separator"></div> |
|---|
| 17 | <div class="section" id="accumulate"> |
|---|
| 18 | <h1><a class="toc-backref" href="./iteration-algorithms.html#id401" name="accumulate">accumulate</a></h1> |
|---|
| 19 | <div class="section" id="accumulate-synopsis"> |
|---|
| 20 | <h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3> |
|---|
| 21 | <pre class="literal-block"> |
|---|
| 22 | template< |
|---|
| 23 | typename Sequence |
|---|
| 24 | , typename State |
|---|
| 25 | , typename ForwardOp |
|---|
| 26 | > |
|---|
| 27 | struct <a href="./accumulate.html" class="identifier">accumulate</a> |
|---|
| 28 | { |
|---|
| 29 | typedef <em>unspecified</em> type; |
|---|
| 30 | }; |
|---|
| 31 | </pre> |
|---|
| 32 | </div> |
|---|
| 33 | <div class="section" id="accumulate-description"> |
|---|
| 34 | <h3><a class="subsection-title" href="#description" name="description">Description</a></h3> |
|---|
| 35 | <p>Returns the result of the successive application of binary <tt class="literal"><span class="pre">ForwardOp</span></tt> to the |
|---|
| 36 | result of the previous <tt class="literal"><span class="pre">ForwardOp</span></tt> invocation (<tt class="literal"><span class="pre">State</span></tt> if it's the first call) |
|---|
| 37 | and every element of the sequence in the range [<tt class="literal"><span class="pre"><a href="./begin.html" class="identifier">begin</a><Sequence>::type</span></tt>, <tt class="literal"><span class="pre"><a href="./end.html" class="identifier">end</a><Sequence>::type</span></tt>) in order. |
|---|
| 38 | [<em>Note:</em> <tt class="literal"><span class="pre"><a href="./accumulate.html" class="identifier">accumulate</a></span></tt> is a synonym for <a class="refentry reference" href="./fold.html"><tt class="refentry literal"><span class="pre">fold</span></tt></a> — <em>end note</em>]</p> |
|---|
| 39 | </div> |
|---|
| 40 | <div class="section" id="accumulate-header"> |
|---|
| 41 | <h3><a class="subsection-title" href="#header" name="header">Header</a></h3> |
|---|
| 42 | <pre class="literal-block"> |
|---|
| 43 | #include <<a href="../../../../boost/mpl/accumulate.hpp" class="header">boost/mpl/accumulate.hpp</a>> |
|---|
| 44 | </pre> |
|---|
| 45 | </div> |
|---|
| 46 | <div class="section" id="accumulate-parameters"> |
|---|
| 47 | <h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3> |
|---|
| 48 | <table border="1" class="table"> |
|---|
| 49 | <colgroup> |
|---|
| 50 | <col width="15%" /> |
|---|
| 51 | <col width="32%" /> |
|---|
| 52 | <col width="53%" /> |
|---|
| 53 | </colgroup> |
|---|
| 54 | <thead valign="bottom"> |
|---|
| 55 | <tr><th>Parameter</th> |
|---|
| 56 | <th>Requirement</th> |
|---|
| 57 | <th>Description</th> |
|---|
| 58 | </tr> |
|---|
| 59 | </thead> |
|---|
| 60 | <tbody valign="top"> |
|---|
| 61 | <tr><td><tt class="literal"><span class="pre">Sequence</span></tt></td> |
|---|
| 62 | <td><a class="reference" href="./forward-sequence.html">Forward Sequence</a></td> |
|---|
| 63 | <td>A sequence to iterate.</td> |
|---|
| 64 | </tr> |
|---|
| 65 | <tr><td><tt class="literal"><span class="pre">State</span></tt></td> |
|---|
| 66 | <td>Any type</td> |
|---|
| 67 | <td>The initial state for the first <tt class="literal"><span class="pre">ForwardOp</span></tt> |
|---|
| 68 | application.</td> |
|---|
| 69 | </tr> |
|---|
| 70 | <tr><td><tt class="literal"><span class="pre">ForwardOp</span></tt></td> |
|---|
| 71 | <td>Binary <a class="reference" href="./lambda-expression.html">Lambda Expression</a></td> |
|---|
| 72 | <td>The operation to be executed on forward |
|---|
| 73 | traversal.</td> |
|---|
| 74 | </tr> |
|---|
| 75 | </tbody> |
|---|
| 76 | </table> |
|---|
| 77 | </div> |
|---|
| 78 | <div class="section" id="accumulate-expression-semantics"> |
|---|
| 79 | <h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3> |
|---|
| 80 | <p>For any <a class="reference" href="./forward-sequence.html">Forward Sequence</a> <tt class="literal"><span class="pre">s</span></tt>, binary <a class="reference" href="./lambda-expression.html">Lambda Expression</a> <tt class="literal"><span class="pre">op</span></tt>, and arbitrary type <tt class="literal"><span class="pre">state</span></tt>:</p> |
|---|
| 81 | <pre class="literal-block"> |
|---|
| 82 | typedef <a href="./accumulate.html" class="identifier">accumulate</a><s,state,op>::type t; |
|---|
| 83 | </pre> |
|---|
| 84 | <table class="field-list" frame="void" rules="none"> |
|---|
| 85 | <col class="field-name" /> |
|---|
| 86 | <col class="field-body" /> |
|---|
| 87 | <tbody valign="top"> |
|---|
| 88 | <tr class="field"><th class="field-name">Return type:</th><td class="field-body">A type.</td> |
|---|
| 89 | </tr> |
|---|
| 90 | <tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Equivalent to</p> |
|---|
| 91 | <pre class="last literal-block"> |
|---|
| 92 | typedef <a href="./fold.html" class="identifier">fold</a><s,state,op>::type t; |
|---|
| 93 | </pre> |
|---|
| 94 | </td> |
|---|
| 95 | </tr> |
|---|
| 96 | </tbody> |
|---|
| 97 | </table> |
|---|
| 98 | </div> |
|---|
| 99 | <div class="section" id="accumulate-complexity"> |
|---|
| 100 | <h3><a class="subsection-title" href="#complexity" name="complexity">Complexity</a></h3> |
|---|
| 101 | <p>Linear. Exactly <tt class="literal"><span class="pre"><a href="./size.html" class="identifier">size</a><s>::value</span></tt> applications of <tt class="literal"><span class="pre">op</span></tt>.</p> |
|---|
| 102 | </div> |
|---|
| 103 | <div class="section" id="accumulate-example"> |
|---|
| 104 | <h3><a class="subsection-title" href="#example" name="example">Example</a></h3> |
|---|
| 105 | <pre class="literal-block"> |
|---|
| 106 | typedef <a href="./vector.html" class="identifier">vector</a><long,float,short,double,float,long,long double> types; |
|---|
| 107 | typedef <a href="./accumulate.html" class="identifier">accumulate</a>< |
|---|
| 108 | types |
|---|
| 109 | , <a href="./int.html" class="identifier">int_</a><0> |
|---|
| 110 | , <a href="./if.html" class="identifier">if_</a>< is_float<_2>,<a href="./next.html" class="identifier">next</a><_1>,_1 > |
|---|
| 111 | >::type number_of_floats; |
|---|
| 112 | |
|---|
| 113 | <a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( number_of_floats::value, ==, 4 ); |
|---|
| 114 | </pre> |
|---|
| 115 | </div> |
|---|
| 116 | <div class="section" id="accumulate-see-also"> |
|---|
| 117 | <h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3> |
|---|
| 118 | <p><a class="reference" href="./algorithms.html">Algorithms</a>, <a class="refentry reference" href="./fold.html"><tt class="refentry literal"><span class="pre">fold</span></tt></a>, <a class="refentry reference" href="./reverse-fold.html"><tt class="refentry literal"><span class="pre">reverse_fold</span></tt></a>, <a class="refentry reference" href="./iter-fold.html"><tt class="refentry literal"><span class="pre">iter_fold</span></tt></a>, <a class="refentry reference" href="./reverse-iter-fold.html"><tt class="refentry literal"><span class="pre">reverse_iter_fold</span></tt></a>, <a class="refentry reference" href="./copy.html"><tt class="refentry literal"><span class="pre">copy</span></tt></a>, <a class="refentry reference" href="./copy-if.html"><tt class="refentry literal"><span class="pre">copy_if</span></tt></a></p> |
|---|
| 119 | <!-- modtime: November 10, 2004 04:25:46 +0000 --> |
|---|
| 120 | </div> |
|---|
| 121 | </div> |
|---|
| 122 | |
|---|
| 123 | <div class="footer-separator"></div> |
|---|
| 124 | <table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./reverse-iter-fold.html" class="navigation-link">Prev</a> <a href="./querying-algorithms.html" class="navigation-link">Next</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./reverse-iter-fold.html" class="navigation-link">Back</a> Along</span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./iteration-algorithms.html" class="navigation-link">Up</a> <a href="../refmanual.html" class="navigation-link">Home</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./refmanual_toc.html" class="navigation-link">Full TOC</a></span></td> |
|---|
| 125 | </tr></table></body> |
|---|
| 126 | </html> |
|---|