iter-fold.html 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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.7: http://docutils.sourceforge.net/" />
  7. <title>The MPL Reference Manual: iter_fold</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="./fold.html" class="navigation-link">Prev</a>&nbsp;<a href="./reverse-fold.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./fold.html" class="navigation-link">Back</a>&nbsp;<a href="./reverse-fold.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./iteration-algorithms.html" class="navigation-link">Up</a>&nbsp;<a href="../refmanual.html" class="navigation-link">Home</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</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="./iter-fold.html" class="navigation-link">iter_fold</a></td>
  13. </tr></table><div class="header-separator"></div>
  14. <div class="section" id="iter-fold">
  15. <h1><a class="toc-backref" href="./iteration-algorithms.html#id1470">iter_fold</a></h1>
  16. <div class="section" id="id501">
  17. <h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
  18. <pre class="literal-block">
  19. template&lt;
  20. typename Sequence
  21. , typename State
  22. , typename ForwardOp
  23. &gt;
  24. struct <a href="./iter-fold.html" class="identifier">iter_fold</a>
  25. {
  26. typedef <em>unspecified</em> type;
  27. };
  28. </pre>
  29. </div>
  30. <div class="section" id="id502">
  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 result
  33. 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) and each
  34. iterator in the range [<tt class="literal"><span class="pre"><a href="./begin.html" class="identifier">begin</a>&lt;Sequence&gt;::type</span></tt>, <tt class="literal"><span class="pre"><a href="./end.html" class="identifier">end</a>&lt;Sequence&gt;::type</span></tt>) in order.</p>
  35. </div>
  36. <div class="section" id="id503">
  37. <h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
  38. <pre class="literal-block">
  39. #include &lt;<a href="../../../../boost/mpl/iter_fold.hpp" class="header">boost/mpl/iter_fold.hpp</a>&gt;
  40. </pre>
  41. </div>
  42. <div class="section" id="id504">
  43. <h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
  44. <table border="1" class="docutils table">
  45. <colgroup>
  46. <col width="15%" />
  47. <col width="32%" />
  48. <col width="53%" />
  49. </colgroup>
  50. <thead valign="bottom">
  51. <tr><th class="head">Parameter</th>
  52. <th class="head">Requirement</th>
  53. <th class="head">Description</th>
  54. </tr>
  55. </thead>
  56. <tbody valign="top">
  57. <tr><td><tt class="literal"><span class="pre">Sequence</span></tt></td>
  58. <td><a class="reference internal" href="./forward-sequence.html">Forward Sequence</a></td>
  59. <td>A sequence to iterate.</td>
  60. </tr>
  61. <tr><td><tt class="literal"><span class="pre">State</span></tt></td>
  62. <td>Any type</td>
  63. <td>The initial state for the first <tt class="literal"><span class="pre">ForwardOp</span></tt>
  64. application.</td>
  65. </tr>
  66. <tr><td><tt class="literal"><span class="pre">ForwardOp</span></tt></td>
  67. <td>Binary <a class="reference internal" href="./lambda-expression.html">Lambda Expression</a></td>
  68. <td>The operation to be executed on forward
  69. traversal.</td>
  70. </tr>
  71. </tbody>
  72. </table>
  73. </div>
  74. <div class="section" id="id505">
  75. <h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
  76. <p>For any <a class="reference internal" href="./forward-sequence.html">Forward Sequence</a> <tt class="literal"><span class="pre">s</span></tt>, binary <a class="reference internal" href="./lambda-expression.html">Lambda Expression</a> <tt class="literal"><span class="pre">op</span></tt>, and an
  77. arbitrary type <tt class="literal"><span class="pre">state</span></tt>:</p>
  78. <pre class="literal-block">
  79. typedef <a href="./iter-fold.html" class="identifier">iter_fold</a>&lt;s,state,op&gt;::type t;
  80. </pre>
  81. <table class="docutils 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"><p class="first">A type.</p>
  86. </td>
  87. </tr>
  88. <tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Equivalent to</p>
  89. <pre class="literal-block">
  90. typedef <a href="./begin.html" class="identifier">begin</a>&lt;s&gt;::type i<sub>1</sub>;
  91. typedef <a href="./apply.html" class="identifier">apply</a>&lt;op,state,i<sub>1</sub>&gt;::type state<sub>1</sub>;
  92. typedef <a href="./next.html" class="identifier">next</a>&lt;i<sub>1</sub>&gt;::type i<sub>2</sub>;
  93. typedef <a href="./apply.html" class="identifier">apply</a>&lt;op,state<sub>1</sub>,i<sub>2</sub>&gt;::type state<sub>2</sub>;
  94. <em>...</em>
  95. typedef <a href="./apply.html" class="identifier">apply</a>&lt;op,state<sub>n-1</sub>,i<sub>n</sub>&gt;::type state<sub>n</sub>;
  96. typedef <a href="./next.html" class="identifier">next</a>&lt;i<sub>n</sub>&gt;::type last;
  97. typedef state<sub>n</sub> t;
  98. </pre>
  99. <p class="last">where <tt class="literal"><span class="pre">n</span> <span class="pre">==</span> <span class="pre"><a href="./size.html" class="identifier">size</a>&lt;s&gt;::value</span></tt> and <tt class="literal"><span class="pre">last</span></tt> is identical to <tt class="literal"><span class="pre"><a href="./end.html" class="identifier">end</a>&lt;s&gt;::type</span></tt>; equivalent
  100. to <tt class="literal"><span class="pre">typedef</span> <span class="pre">state</span> <span class="pre">t;</span></tt> if <tt class="literal"><span class="pre"><a href="./empty.html" class="identifier">empty</a>&lt;s&gt;::value</span> <span class="pre">==</span> <span class="pre">true</span></tt>.</p>
  101. </td>
  102. </tr>
  103. </tbody>
  104. </table>
  105. </div>
  106. <div class="section" id="id506">
  107. <h3><a class="subsection-title" href="#complexity" name="complexity">Complexity</a></h3>
  108. <p>Linear. Exactly <tt class="literal"><span class="pre"><a href="./size.html" class="identifier">size</a>&lt;s&gt;::value</span></tt> applications of <tt class="literal"><span class="pre">op</span></tt>.</p>
  109. </div>
  110. <div class="section" id="id507">
  111. <h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
  112. <pre class="literal-block">
  113. typedef <a href="./vector-c.html" class="identifier">vector_c</a>&lt;int,5,-1,0,7,2,0,-5,4&gt; numbers;
  114. typedef <a href="./iter-fold.html" class="identifier">iter_fold</a>&lt;
  115. numbers
  116. , <a href="./begin.html" class="identifier">begin</a>&lt;numbers&gt;::type
  117. , <a href="./if.html" class="identifier">if_</a>&lt; <a href="./less.html" class="identifier">less</a>&lt; <a href="./deref.html" class="identifier">deref</a>&lt;<a href="./placeholders.html" class="identifier">_1</a>&gt;, <a href="./deref.html" class="identifier">deref</a>&lt;<a href="./placeholders.html" class="identifier">_2</a>&gt; &gt;,<a href="./placeholders.html" class="identifier">_2</a>,<a href="./placeholders.html" class="identifier">_1</a> &gt;
  118. &gt;::type max_element_iter;
  119. <a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( <a href="./deref.html" class="identifier">deref</a>&lt;max_element_iter&gt;::type::value, ==, 7 );
  120. </pre>
  121. </div>
  122. <div class="section" id="id508">
  123. <h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
  124. <p><a class="reference internal" href="./algorithms.html">Algorithms</a>, <a class="reference internal" href="./reverse-iter-fold.html">reverse_iter_fold</a>, <a class="reference internal" href="./fold.html">fold</a>, <a class="reference internal" href="./reverse-fold.html">reverse_fold</a>, <a class="reference internal" href="./copy.html">copy</a></p>
  125. <!-- Algorithms/Iteration Algorithms//reverse_fold -->
  126. </div>
  127. </div>
  128. <div class="footer-separator"></div>
  129. <table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./fold.html" class="navigation-link">Prev</a>&nbsp;<a href="./reverse-fold.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./fold.html" class="navigation-link">Back</a>&nbsp;<a href="./reverse-fold.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./iteration-algorithms.html" class="navigation-link">Up</a>&nbsp;<a href="../refmanual.html" class="navigation-link">Home</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./refmanual_toc.html" class="navigation-link">Full TOC</a></span></td>
  130. <td><div class="copyright-footer"><div class="copyright">Copyright © 2001-2009 Aleksey Gurtovoy and David Abrahams</div>
  131. Distributed under the Boost Software License, Version 1.0. (See accompanying
  132. file LICENSE_1_0.txt or copy at <a class="reference external" href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)</div></td></tr></table></body>
  133. </html>