list_fold_right_d_old.html 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <html>
  2. <head>
  3. <title>BOOST_PP_LIST_FOLD_RIGHT_D</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_LIST_FOLD_RIGHT_D</b> macro folds (or accumulates) the elements of a <i>list</i> right-to-left.&nbsp;
  9. It reenters <b>BOOST_PP_WHILE</b> with maximum efficiency.
  10. </div>
  11. <h4>Usage</h4>
  12. <div class="code">
  13. <b>BOOST_PP_LIST_FOLD_RIGHT_D</b>(<i>d</i>, <i>op</i>, <i>state</i>, <i>list</i>)
  14. </div>
  15. <h4>Arguments</h4>
  16. <dl>
  17. <dt>d</dt>
  18. <dd>
  19. The next available <b>BOOST_PP_WHILE</b> iteration.
  20. </dd>
  21. <dt>op</dt>
  22. <dd>
  23. A ternary operation of the form <i>op</i>(<i>d</i>, <i>state</i>, <i>elem</i>).&nbsp;
  24. This macro is called for each element in <i>list</i>--each time returning a new <i>state</i>.&nbsp;
  25. This operation is expanded by <b>BOOST_PP_LIST_FOLD_RIGHT</b> with the next available <b>BOOST_PP_WHILE</b> iteration,
  26. the current <i>state</i>, and the current element.
  27. </dd>
  28. <dt>state</dt>
  29. <dd>
  30. The initial state of the fold.
  31. </dd>
  32. <dt>list</dt>
  33. <dd>
  34. The <i>list</i> to be folded.
  35. </dd>
  36. </dl>
  37. <h4>Remarks</h4>
  38. <div>
  39. This macro does not have the same signature as it previously did.&nbsp;
  40. The arguments have been swapped to provide a uniform interface with <b>BOOST_PP_LIST_FOLD_LEFT</b>.
  41. </div>
  42. <div>
  43. For the <i>list</i>, (<i>0</i>, (<i>1</i>, (<i>2</i>, <b>BOOST_PP_NIL</b>))), this macro expands to:
  44. <div>
  45. <i>op</i>(<i>d</i>, <i>op</i>(<i>d</i>, <i>op</i>(<i>d</i>, <i>state</i>, <i>2</i>), <i>1</i>), <i>0</i>)
  46. </div>
  47. </div>
  48. <div>
  49. This macro has been superceded by <b>BOOST_PP_LIST_FOLD_RIGHT_<i>d</i></b> and is deprecated.&nbsp;
  50. It only allows a single reentry into <b>BOOST_PP_LIST_FOLD_RIGHT</b>.
  51. </div>
  52. <h4>See Also</h4>
  53. <ul>
  54. <li><a href="list_fold_right.html">BOOST_PP_LIST_FOLD_RIGHT</a></li>
  55. <li><a href="list_fold_right_d.html">BOOST_PP_LIST_FOLD_RIGHT_<i>d</i></a></li>
  56. </ul>
  57. <h4>Requirements</h4>
  58. <div>
  59. <b>Header:</b> &nbsp;<a href="../headers/list/fold_right.html">&lt;boost/preprocessor/list/fold_right.hpp&gt;</a>
  60. </div>
  61. <h4>Sample Code</h4>
  62. <div><pre>
  63. #include &lt;<a href="../headers/cat.html">boost/preprocessor/cat.hpp</a>&gt;
  64. #include &lt;<a href="../headers/list/fold_right.html">boost/preprocessor/list/fold_right.hpp</a>&gt;
  65. #define L1 (a, (b, (c, <a href="nil.html">BOOST_PP_NIL</a>)))
  66. #define L2 (L1, (L1, (L1, <a href="nil.html">BOOST_PP_NIL</a>)))
  67. #define OP(d, state, x) (<a href="list_fold_right_d_old.html">BOOST_PP_LIST_FOLD_RIGHT_D</a>(d, OP_2, _, x), state)
  68. #define OP_2(d, state, x) <a href="cat.html">BOOST_PP_CAT</a>(state, x)
  69. <a href="list_fold_right.html">BOOST_PP_LIST_FOLD_RIGHT</a>(OP, <a href="nil.html">BOOST_PP_NIL</a>, L2)
  70. /*
  71. expands to:
  72. (_cba, (_cba, (_cba, <a href="nil.html">BOOST_PP_NIL</a>)))
  73. */
  74. </pre></div>
  75. <hr size="1">
  76. <div style="margin-left: 0px;">
  77. <i>© Copyright <a href="http://www.housemarque.com" target="_top">Housemarque Oy</a> 2002</i>
  78. </br><i>© Copyright Paul Mensonides 2002</i>
  79. </div>
  80. <div style="margin-left: 0px;">
  81. <p><small>Distributed under the Boost Software License, Version 1.0. (See
  82. accompanying file <a href="../../../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or
  83. copy at <a href=
  84. "http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</small></p>
  85. </div>
  86. </body>
  87. </html>