seq_filter.html 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <html>
  2. <head>
  3. <title>BOOST_PP_SEQ_FILTER</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_FILTER</b> macro filters a <i>seq</i> according to a
  9. supplied criterion.
  10. </div>
  11. <h4>
  12. Usage
  13. </h4>
  14. <div class="code">
  15. <b>BOOST_PP_SEQ_FILTER</b>(<i>pred</i>, <i>data</i>, <i>seq</i>)
  16. </div>
  17. <h4>
  18. Arguments
  19. </h4>
  20. <dl>
  21. <dt>pred</dt>
  22. <dd>
  23. A ternary predicate of the form <i>pred</i>(<i>s</i>, <i>data</i>, <i>elem</i>).&nbsp;
  24. This predicate is expanded by <b>BOOST_PP_SEQ_FILTER</b> for each element in <i>seq</i>
  25. with the next available <b>BOOST_PP_SEQ_FOLD_LEFT</b> fold step, the auxiliary <i>data</i>,
  26. and the current element in <i>seq</i>.&nbsp; This macro must return a integral
  27. value in the range of <i>0</i> to <b>BOOST_PP_LIMIT_MAG</b>.&nbsp; If this
  28. predicate expands to non-zero for a certain element, that element is included
  29. in the resulting <i>seq</i>.
  30. </dd>
  31. <dt>data</dt>
  32. <dd>
  33. Auxiliary data passed to <i>pred</i>.
  34. </dd>
  35. <dt>seq</dt>
  36. <dd>
  37. The <i>seq</i> to be filtered.
  38. </dd>
  39. </dl>
  40. <h4>
  41. Remarks
  42. </h4>
  43. <div>
  44. This macro expands <i>pred</i> for each element in <i>seq</i>.&nbsp; It builds
  45. a new <i>seq</i> out of each element for which <i>pred</i> returns non-zero.
  46. </div>
  47. <div>
  48. For maximum efficiency, use <b>BOOST_PP_SEQ_FILTER_S</b>.
  49. </div>
  50. <h4>
  51. See Also
  52. </h4>
  53. <ul>
  54. <li>
  55. <a href="limit_mag.html">BOOST_PP_LIMIT_MAG</a></li>
  56. <li>
  57. <a href="seq_filter_s.html">BOOST_PP_SEQ_FILTER_S</a></li>
  58. </ul>
  59. <h4>
  60. Requirements
  61. </h4>
  62. <div>
  63. <b>Header:</b> &nbsp;<a href="../headers/seq/filter.html">&lt;boost/preprocessor/seq/filter.hpp&gt;</a>
  64. </div>
  65. <h4>
  66. Sample Code
  67. </h4>
  68. <div>
  69. <pre>
  70. #include &lt;<a href="../headers/comparison/less_equal.html">boost/preprocessor/comparison/less_equal.hpp</a>&gt;
  71. #include &lt;<a href="../headers/seq/filter.html">boost/preprocessor/seq/filter.hpp</a>&gt;
  72. #define SEQ (1)(3)(2)(5)
  73. #define PRED(s, data, elem) <a href="less_equal.html">BOOST_PP_LESS_EQUAL</a>(elem, data)
  74. <a href="seq_filter.html">BOOST_PP_SEQ_FILTER</a>(PRED, 3, SEQ)
  75. // expands to (1)(3)(2)
  76. </pre>
  77. </div>
  78. <hr size="1">
  79. <div style="margin-left: 0px;">
  80. <i>© Copyright <a href="http://www.housemarque.com" target="_top">Housemarque Oy</a> 2002</i>
  81. </br><i>© Copyright Paul Mensonides 2002</i>
  82. </div>
  83. <div style="margin-left: 0px;">
  84. <p><small>Distributed under the Boost Software License, Version 1.0. (See
  85. accompanying file <a href="../../../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or
  86. copy at <a href=
  87. "http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</small></p>
  88. </div>
  89. </body>
  90. </html>