list_for_each_product.html 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <html>
  2. <head>
  3. <title>BOOST_PP_LIST_FOR_EACH_PRODUCT</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_PRODUCT</b> macro repeats a macro for each cartesian product of several <i>lists</i>.
  9. </div>
  10. <h4>Usage</h4>
  11. <div class="code">
  12. <b>BOOST_PP_LIST_FOR_EACH_PRODUCT</b>(<i>macro</i>, <i>size</i>, <i>tuple</i>)
  13. </div>
  14. <h4>Arguments</h4>
  15. <dl>
  16. <dt>macro</dt>
  17. <dd>
  18. The binary macro of the form <i>macro</i>(<i>r</i>, <i>product</i>).&nbsp;
  19. This macro is expanded by <b>BOOST_PP_FOR_EACH_PRODUCT</b> with each cartesian product in <i>tuple</i>.&nbsp;
  20. It is expanded with the next available <b>BOOST_PP_FOR</b> repetition and a <i>tuple</i> containing a cartesian product.&nbsp;
  21. This <i>tuple</i> will have <i>size</i> elements.
  22. </dd>
  23. <dt>size</dt>
  24. <dd>
  25. The size of <i>tuple</i>.
  26. </dd>
  27. <dt>tuple</dt>
  28. <dd>
  29. A <i>tuple</i> of <i>lists</i> from which cartesian products are obtained.
  30. </dd>
  31. </dl>
  32. <h4>Remarks</h4>
  33. <div>
  34. This macro is a repetition construct.&nbsp;
  35. If two <i>lists</i> are (<i>a</i>, (<i>b</i>, (<i>c</i>, <b>BOOST_PP_NIL</b>))) and (<i>x</i>, (<i>y</i>, (<i>z</i>, <b>BOOST_PP_NIL</b>))),
  36. this macro will produce the following sequence:
  37. <div>
  38. <i>macro</i>(<i>r</i>, (<i>a</i>, <i>x</i>))
  39. <i>macro</i>(<i>r</i>, (<i>a</i>, <i>y</i>))
  40. <i>macro</i>(<i>r</i>, (<i>a</i>, <i>z</i>))<br>
  41. <i>macro</i>(<i>r</i>, (<i>b</i>, <i>x</i>))
  42. <i>macro</i>(<i>r</i>, (<i>b</i>, <i>y</i>))
  43. <i>macro</i>(<i>r</i>, (<i>b</i>, <i>z</i>))<br>
  44. <i>macro</i>(<i>r</i>, (<i>c</i>, <i>x</i>))
  45. <i>macro</i>(<i>r</i>, (<i>c</i>, <i>y</i>))
  46. <i>macro</i>(<i>r</i>, (<i>c</i>, <i>z</i>))
  47. </div>
  48. </div>
  49. <div>
  50. Previously, this macro could not be used inside <b>BOOST_PP_FOR</b>.&nbsp;
  51. There is no longer any such restriction.&nbsp;
  52. It is more efficient, however, to use <b>BOOST_PP_LIST_FOR_EACH_PRODUCT_R</b> in such a situation.
  53. </div>
  54. <h4>See Also</h4>
  55. <ul>
  56. <li><a href="list_for_each_product_r.html">BOOST_PP_LIST_FOR_EACH_PRODUCT_R</a></li>
  57. </ul>
  58. <h4>Requirements</h4>
  59. <div>
  60. <b>Header:</b> &nbsp;<a href="../headers/list/for_each_product.html">&lt;boost/preprocessor/list/for_each_product.hpp&gt;</a>
  61. </div>
  62. <h4>Sample Code</h4>
  63. <div><pre>
  64. #include &lt;<a href="../headers/list/for_each_product.html">boost/preprocessor/list/for_each_product.hpp</a>&gt;
  65. #define L1 (a, (b, (c, <a href="nil.html">BOOST_PP_NIL</a>)))
  66. #define L2 (x, (y, (z, <a href="nil.html">BOOST_PP_NIL</a>)))
  67. #define MACRO(r, product) product
  68. <a href="list_for_each_product.html">BOOST_PP_LIST_FOR_EACH_PRODUCT</a>(MACRO, 2, (L1, L2))
  69. // expands to (a, x) (a, y) (a, z) (b, x) (b, y) (b, z) (c, x) (c, y) (c, z)
  70. </pre></div>
  71. <hr size="1">
  72. <div style="margin-left: 0px;">
  73. <i>© Copyright <a href="http://www.housemarque.com" target="_top">Housemarque Oy</a> 2002</i>
  74. </br><i>© Copyright Paul Mensonides 2002</i>
  75. </div>
  76. <div style="margin-left: 0px;">
  77. <p><small>Distributed under the Boost Software License, Version 1.0. (See
  78. accompanying file <a href="../../../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or
  79. copy at <a href=
  80. "http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</small></p>
  81. </div>
  82. </body>
  83. </html>