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 | <head> |
---|
5 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
---|
6 | <meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" /> |
---|
7 | <title>The MPL Reference Manual: accumulate</title> |
---|
8 | <link rel="stylesheet" href="../style.css" type="text/css" /> |
---|
9 | </head> |
---|
10 | <body class="docframe refmanual"> |
---|
11 | <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> |
---|
12 | <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> |
---|
13 | </tr></table><div class="header-separator"></div> |
---|
14 | <div class="section" id="accumulate"> |
---|
15 | <h1><a class="toc-backref" href="./iteration-algorithms.html#id401" name="accumulate">accumulate</a></h1> |
---|
16 | <div class="section" id="accumulate-synopsis"> |
---|
17 | <h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3> |
---|
18 | <pre class="literal-block"> |
---|
19 | template< |
---|
20 | typename Sequence |
---|
21 | , typename State |
---|
22 | , typename ForwardOp |
---|
23 | > |
---|
24 | struct <a href="./accumulate.html" class="identifier">accumulate</a> |
---|
25 | { |
---|
26 | typedef <em>unspecified</em> type; |
---|
27 | }; |
---|
28 | </pre> |
---|
29 | </div> |
---|
30 | <div class="section" id="accumulate-description"> |
---|
31 | <h3><a class="subsection-title" href="#description" name="description">Description</a></h3> |
---|
32 | <p>Returns the result of the successive application of binary <tt class="literal"><span class="pre">ForwardOp</span></tt> to the |
---|
33 | 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) |
---|
34 | 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. |
---|
35 | [<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> |
---|
36 | </div> |
---|
37 | <div class="section" id="accumulate-header"> |
---|
38 | <h3><a class="subsection-title" href="#header" name="header">Header</a></h3> |
---|
39 | <pre class="literal-block"> |
---|
40 | #include <<a href="../../../../boost/mpl/accumulate.hpp" class="header">boost/mpl/accumulate.hpp</a>> |
---|
41 | </pre> |
---|
42 | </div> |
---|
43 | <div class="section" id="accumulate-parameters"> |
---|
44 | <h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3> |
---|
45 | <table border="1" class="table"> |
---|
46 | <colgroup> |
---|
47 | <col width="15%" /> |
---|
48 | <col width="32%" /> |
---|
49 | <col width="53%" /> |
---|
50 | </colgroup> |
---|
51 | <thead valign="bottom"> |
---|
52 | <tr><th>Parameter</th> |
---|
53 | <th>Requirement</th> |
---|
54 | <th>Description</th> |
---|
55 | </tr> |
---|
56 | </thead> |
---|
57 | <tbody valign="top"> |
---|
58 | <tr><td><tt class="literal"><span class="pre">Sequence</span></tt></td> |
---|
59 | <td><a class="reference" href="./forward-sequence.html">Forward Sequence</a></td> |
---|
60 | <td>A sequence to iterate.</td> |
---|
61 | </tr> |
---|
62 | <tr><td><tt class="literal"><span class="pre">State</span></tt></td> |
---|
63 | <td>Any type</td> |
---|
64 | <td>The initial state for the first <tt class="literal"><span class="pre">ForwardOp</span></tt> |
---|
65 | application.</td> |
---|
66 | </tr> |
---|
67 | <tr><td><tt class="literal"><span class="pre">ForwardOp</span></tt></td> |
---|
68 | <td>Binary <a class="reference" href="./lambda-expression.html">Lambda Expression</a></td> |
---|
69 | <td>The operation to be executed on forward |
---|
70 | traversal.</td> |
---|
71 | </tr> |
---|
72 | </tbody> |
---|
73 | </table> |
---|
74 | </div> |
---|
75 | <div class="section" id="accumulate-expression-semantics"> |
---|
76 | <h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3> |
---|
77 | <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> |
---|
78 | <pre class="literal-block"> |
---|
79 | typedef <a href="./accumulate.html" class="identifier">accumulate</a><s,state,op>::type t; |
---|
80 | </pre> |
---|
81 | <table class="field-list" frame="void" rules="none"> |
---|
82 | <col class="field-name" /> |
---|
83 | <col class="field-body" /> |
---|
84 | <tbody valign="top"> |
---|
85 | <tr class="field"><th class="field-name">Return type:</th><td class="field-body">A type.</td> |
---|
86 | </tr> |
---|
87 | <tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Equivalent to</p> |
---|
88 | <pre class="last literal-block"> |
---|
89 | typedef <a href="./fold.html" class="identifier">fold</a><s,state,op>::type t; |
---|
90 | </pre> |
---|
91 | </td> |
---|
92 | </tr> |
---|
93 | </tbody> |
---|
94 | </table> |
---|
95 | </div> |
---|
96 | <div class="section" id="accumulate-complexity"> |
---|
97 | <h3><a class="subsection-title" href="#complexity" name="complexity">Complexity</a></h3> |
---|
98 | <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> |
---|
99 | </div> |
---|
100 | <div class="section" id="accumulate-example"> |
---|
101 | <h3><a class="subsection-title" href="#example" name="example">Example</a></h3> |
---|
102 | <pre class="literal-block"> |
---|
103 | typedef <a href="./vector.html" class="identifier">vector</a><long,float,short,double,float,long,long double> types; |
---|
104 | typedef <a href="./accumulate.html" class="identifier">accumulate</a>< |
---|
105 | types |
---|
106 | , <a href="./int.html" class="identifier">int_</a><0> |
---|
107 | , <a href="./if.html" class="identifier">if_</a>< is_float<_2>,<a href="./next.html" class="identifier">next</a><_1>,_1 > |
---|
108 | >::type number_of_floats; |
---|
109 | |
---|
110 | <a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( number_of_floats::value, ==, 4 ); |
---|
111 | </pre> |
---|
112 | </div> |
---|
113 | <div class="section" id="accumulate-see-also"> |
---|
114 | <h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3> |
---|
115 | <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> |
---|
116 | <!-- modtime: November 10, 2004 04:25:46 +0000 --> |
---|
117 | </div> |
---|
118 | </div> |
---|
119 | |
---|
120 | <div class="footer-separator"></div> |
---|
121 | <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> |
---|
122 | </tr></table></body> |
---|
123 | </html> |
---|