seq_for_each_product.html 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <html>
  2. <head>
  3. <title>BOOST_PP_SEQ_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_SEQ_FOR_EACH_PRODUCT</b> macro repeats a macro for each
  9. cartesian product of several <i>seqs</i>.
  10. </div>
  11. <h4>
  12. Usage
  13. </h4>
  14. <div class="code">
  15. <b>BOOST_PP_SEQ_FOR_EACH_PRODUCT</b>(<i>macro</i>, <i>seqs</i>)
  16. </div>
  17. <h4>
  18. Arguments
  19. </h4>
  20. <dl>
  21. <dt>macro</dt>
  22. <dd>
  23. The binary macro of the form <i>macro</i>(<i>r</i>, <i>product</i>).&nbsp; This
  24. macro is expanded by <b>BOOST_PP_FOR_EACH_PRODUCT</b> with each cartesian
  25. product in <i>seqs</i>.&nbsp; It is expanded with the next available <b>BOOST_PP_FOR</b>
  26. repetition and a <i>seq</i> containing a cartesian product.&nbsp;
  27. </dd>
  28. <dt>seqs</dt>
  29. <dd>
  30. A <i>seq</i> of <i>seqs</i> from which cartesian products are obtained.
  31. </dd>
  32. </dl>
  33. <h4>
  34. Remarks
  35. </h4>
  36. <div>
  37. This macro is a repetition construct.&nbsp; If two <i>seqs</i> are (<i>a</i>)(<i>b</i>)(<i>c</i>)
  38. and (<i>x</i>)(<i>y</i>)(<i>z</i>), this macro will produce the following
  39. sequence:
  40. <div>
  41. <i>macro</i>(<i>r</i>, (<i>a</i>)(<i>x</i>)) <i>macro</i>(<i>r</i>, (<i>a</i>)(<i>y</i>))
  42. <i>macro</i>(<i>r</i>, (<i>a</i>)(<i>z</i>)) \
  43. <br>
  44. <i>macro</i>(<i>r</i>, (<i>b</i>)(<i>x</i>)) <i>macro</i>(<i>r</i>, (<i>b</i>)(<i>y</i>))
  45. <i>macro</i>(<i>r</i>, (<i>b</i>)(<i>z</i>)) \
  46. <br>
  47. <i>macro</i>(<i>r</i>, (<i>c</i>)(<i>x</i>)) <i>macro</i>(<i>r</i>, (<i>c</i>)(<i>y</i>))
  48. <i>macro</i>(<i>r</i>, (<i>c</i>)(<i>z</i>))
  49. </div>
  50. </div>
  51. <div>
  52. For maximum efficiency, use <b>BOOST_PP_SEQ_FOR_EACH_PRODUCT_R</b>.
  53. </div>
  54. <h4>
  55. See Also
  56. </h4>
  57. <ul>
  58. <li>
  59. <a href="seq_for_each_product_r.html">BOOST_PP_SEQ_FOR_EACH_PRODUCT_R</a></li>
  60. </ul>
  61. <h4>
  62. Requirements
  63. </h4>
  64. <div>
  65. <b>Header:</b> &nbsp;<a href="../headers/seq/for_each_product.html">&lt;boost/preprocessor/seq/for_each_product.hpp&gt;</a>
  66. </div>
  67. <h4>
  68. Sample Code
  69. </h4>
  70. <div>
  71. <pre>
  72. #include &lt;<a href="../headers/seq/for_each_product.html">boost/preprocessor/seq/for_each_product.hpp</a>&gt;
  73. #include &lt;<a href="../headers/seq/to_tuple.html">boost/preprocessor/seq/to_tuple.hpp</a>&gt;
  74. #define S1 (a)(b)(c)
  75. #define S2 (x)(y)(z)
  76. #define S3 (p)(q)
  77. #define MACRO(r, product) <a href="seq_to_tuple.html">BOOST_PP_SEQ_TO_TUPLE</a>(product)
  78. <a href="seq_for_each_product.html">BOOST_PP_SEQ_FOR_EACH_PRODUCT</a>(MACRO, (S1)(S2)(S3))
  79. // expands to:
  80. // (a, x, p) (a, x, q) (a, y, p) (a, y, q) (a, z, p) (a, z, q)
  81. // (b, x, p) (b, x, q) (b, y, p) (b, y, q) (b, z, p) (b, z, q)
  82. // (c, x, p) (c, x, q) (c, y, p) (c, y, q) (c, z, p) (c, z, q)
  83. </pre>
  84. </div>
  85. <hr size="1">
  86. <div style="margin-left: 0px;">
  87. <i>© Copyright <a href="http://www.housemarque.com" target="_top">Housemarque Oy</a> 2002</i>
  88. </br><i>© Copyright Paul Mensonides 2002</i>
  89. </div>
  90. <div style="margin-left: 0px;">
  91. <p><small>Distributed under the Boost Software License, Version 1.0. (See
  92. accompanying file <a href="../../../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or
  93. copy at <a href=
  94. "http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</small></p>
  95. </div>
  96. </body>
  97. </html>