seq_fold_right_s.html 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <html>
  2. <head>
  3. <title>BOOST_PP_SEQ_FOLD_RIGHT_s</title>
  4. <link rel="stylesheet" type="text/css" href="../styles.css">
  5. </head>
  6. <body>
  7. <div style="margin-left: 0px;">
  8. The <b>BOOST_PP_SEQ_FOLD_RIGHT_<i>s</i></b> macro folds (or accumulates) the
  9. elements of a <i>seq</i> right-to-left.&nbsp; It reenters <b>BOOST_PP_SEQ_FOLD_RIGHT</b>
  10. with maximum efficiency.
  11. </div>
  12. <h4>
  13. Usage
  14. </h4>
  15. <div class="code">
  16. <b>BOOST_PP_SEQ_FOLD_RIGHT_</b> ## <i>s</i>(<i>op</i>, <i>state</i>, <i>seq</i>)
  17. </div>
  18. <h4>
  19. Arguments
  20. </h4>
  21. <dl>
  22. <dt>s</dt>
  23. <dd>
  24. The next available <b>BOOST_PP_SEQ_FOLD_LEFT</b> fold step.
  25. </dd>
  26. <dt>op</dt>
  27. <dd>
  28. A ternary operation of the form <i>op</i>(<i>s</i>, <i>state</i>, <i>elem</i>).&nbsp;
  29. This macro is called for each element in <i>seq</i>--each time returning a new <i>state</i>.&nbsp;
  30. This operation is expanded by <b>BOOST_PP_SEQ_FOLD_RIGHT</b> with the next
  31. available fold step, the current <i>state</i>, and the current element.
  32. </dd>
  33. <dt>state</dt>
  34. <dd>
  35. The initial state of the fold.
  36. </dd>
  37. <dt>seq</dt>
  38. <dd>
  39. The <i>seq</i> to be folded.
  40. </dd>
  41. </dl>
  42. <h4>
  43. Remarks
  44. </h4>
  45. <div>
  46. For the <i>seq</i>, (<i>0</i>)(<i>1</i>)(<i>2</i>), this macro expands to:
  47. <div>
  48. <i>op</i>(<i>s</i>, <i>op</i>(<i>s</i>, <i>op</i>(<i>s</i>, <i>state</i>, <i>2</i>),
  49. <i>1</i>), <i>0</i>)
  50. </div>
  51. </div>
  52. <h4>
  53. See Also
  54. </h4>
  55. <ul>
  56. <li>
  57. <a href="seq_fold_right.html">BOOST_PP_SEQ_FOLD_RIGHT</a></li>
  58. </ul>
  59. <h4>
  60. Requirements
  61. </h4>
  62. <div>
  63. <b>Header:</b> &nbsp;<a href="../headers/seq/fold_right.html">&lt;boost/preprocessor/seq/fold_right.hpp&gt;</a>
  64. </div>
  65. <h4>
  66. Sample Code
  67. </h4>
  68. <div>
  69. <pre>
  70. #include &lt;<a href="../headers/cat.html">boost/preprocessor/cat.hpp</a>&gt;
  71. #include &lt;<a href="../headers/seq/fold_left.html">boost/preprocessor/seq/fold_left.hpp</a>&gt;
  72. #include &lt;<a href="../headers/seq/fold_right.html">boost/preprocessor/seq/fold_right.hpp</a>&gt;
  73. #include &lt;<a href="../headers/seq/seq.html">boost/preprocessor/seq/seq.hpp</a>&gt;
  74. #define S1 (a)(b)(c)
  75. #define S2 (S1)(S1)(S1)
  76. #define OP(s, state, x) state (<a href="seq_fold_left_s.html">BOOST_PP_SEQ_FOLD_RIGHT_</a> ## s(OP_2, _, x))
  77. #define OP_2(s, state, x) <a href="cat.html">BOOST_PP_CAT</a>(state, x)
  78. <a href="seq_fold_left.html">BOOST_PP_SEQ_FOLD_LEFT</a>(OP, <a href="seq_nil.html">BOOST_PP_SEQ_NIL</a>, S2)
  79. // expands to (_cba)(_cba)(_cba)
  80. </pre>
  81. </div>
  82. <hr size="1">
  83. <div style="margin-left: 0px;">
  84. <i>© Copyright <a href="http://www.housemarque.com" target="_top">Housemarque Oy</a> 2002</i>
  85. </br><i>© Copyright Paul Mensonides 2002</i>
  86. </div>
  87. <div style="margin-left: 0px;">
  88. <p><small>Distributed under the Boost Software License, Version 1.0. (See
  89. accompanying file <a href="../../../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or
  90. copy at <a href=
  91. "http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</small></p>
  92. </div>
  93. </body>
  94. </html>