list_for_each_i.html 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <html>
  2. <head>
  3. <title>BOOST_PP_LIST_FOR_EACH_I</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_FOR_EACH_I</b> macro repeats a macro for each element in a <i>list</i>.
  9. </div>
  10. <h4>Usage</h4>
  11. <div class="code">
  12. <b>BOOST_PP_LIST_FOR_EACH_I</b>(<i>macro</i>, <i>data</i>, <i>list</i>)
  13. </div>
  14. <h4>Arguments</h4>
  15. <dl>
  16. <dt>macro</dt>
  17. <dd>
  18. A macro of the form <i>macro</i>(<i>r</i>, <i>data</i>, <i>i</i>, <i>elem</i>).&nbsp;
  19. This macro is expanded by <b>BOOST_PP_LIST_FOR_EACH_I</b> with each element in <i>list</i>.&nbsp;
  20. It is expanded with the next available <b>BOOST_PP_FOR</b> repetition, the auxiliary <i>data</i>, the index of the current element, and the current element.
  21. </dd>
  22. <dt>data</dt>
  23. <dd>
  24. Auxiliary data passed to <i>macro</i>.
  25. </dd>
  26. <dt>list</dt>
  27. <dd>
  28. The <i>list</i> for which <i>macro</i> will be invoked on each element.
  29. </dd>
  30. </dl>
  31. <h4>Remarks</h4>
  32. <div>
  33. This macro is a repetition construct.&nbsp;
  34. If <i>list</i> is (<i>a</i>, (<i>b</i>, (<i>c</i>, <b>BOOST_PP_NIL</b>))), it expands to the sequence:
  35. <div>
  36. <i>macro</i>(<i>r</i>, <i>data</i>, <i>0</i>, <i>a</i>) <i>macro</i>(<i>r</i>, <i>data</i>, <i>1</i>, <i>b</i>) <i>macro</i>(<i>r</i>, <i>data</i>, <i>2</i>, <i>c</i>)
  37. </div>
  38. </div>
  39. <div>
  40. Previously, this macro could not be used inside <b>BOOST_PP_FOR</b>.&nbsp;
  41. There is no longer any such restriction.&nbsp;
  42. It is more efficient, however, to use <b>BOOST_PP_LIST_FOR_EACH_I_R</b> in such a situation.
  43. </div>
  44. <h4>See Also</h4>
  45. <ul>
  46. <li><a href="list_for_each_i_r.html">BOOST_PP_LIST_FOR_EACH_I_R</a></li>
  47. </ul>
  48. <h4>Requirements</h4>
  49. <div>
  50. <b>Header:</b> &nbsp;<a href="../headers/list/for_each_i.html">&lt;boost/preprocessor/list/for_each_i.hpp&gt;</a>
  51. </div>
  52. <h4>Sample Code</h4>
  53. <div><pre>
  54. #include &lt;<a href="../headers/cat.html">boost/preprocessor/cat.hpp</a>&gt;
  55. #include &lt;<a href="../headers/list/for_each_i.html">boost/preprocessor/list/for_each_i.hpp</a>&gt;
  56. #define LIST (w, (x, (y, (z, <a href="nil.html">BOOST_PP_NIL</a>))))
  57. #define MACRO(r, data, i, elem) <a href="cat.html">BOOST_PP_CAT</a>(elem, <a href="cat.html">BOOST_PP_CAT</a>(data, i))
  58. <a href="list_for_each_i.html">BOOST_PP_LIST_FOR_EACH_I</a>(MACRO, _, LIST) // expands to w_0 x_1 y_2 z_3
  59. </pre></div>
  60. <hr size="1">
  61. <div style="margin-left: 0px;">
  62. <i>© Copyright <a href="http://www.housemarque.com" target="_top">Housemarque Oy</a> 2002</i>
  63. </br><i>© Copyright Paul Mensonides 2002</i>
  64. </div>
  65. <div style="margin-left: 0px;">
  66. <p><small>Distributed under the Boost Software License, Version 1.0. (See
  67. accompanying file <a href="../../../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or
  68. copy at <a href=
  69. "http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</small></p>
  70. </div>
  71. </body>
  72. </html>