identity_n.html 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <html>
  2. <head>
  3. <title>BOOST_PP_IDENTITY_N</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_IDENTITY_N</b> macro expands to its first argument when invoked.
  9. </div>
  10. <h4>Usage</h4>
  11. <div class="code">
  12. <b>BOOST_PP_IDENTITY_N</b>(<i>item,n</i>)(n-arguments)
  13. </div>
  14. <h4>Arguments</h4>
  15. <dl>
  16. <dt>item</dt>
  17. <dd>
  18. The result of the expansion.
  19. </dd>
  20. <dt>n</dt>
  21. <dd>
  22. The number of arguments when invoked.
  23. </dd>
  24. </dl>
  25. <h4>Remarks</h4>
  26. <div>
  27. This macro is designed to be used with <b>BOOST_PP_IF</b> and <b>BOOST_PP_IIF</b> when only one of the clauses needs to be invoked.
  28. </div>
  29. <h4>See Also</h4>
  30. <ul>
  31. <li><a href="if.html">BOOST_PP_IF</a></li>
  32. <li><a href="iif.html">BOOST_PP_IIF</a></li>
  33. </ul>
  34. <h4>Requirements</h4>
  35. <div>
  36. <b>Header:</b> &nbsp;<a href="../headers/facilities/identity.html">&lt;boost/preprocessor/facilities/identity.hpp&gt;</a>
  37. </div>
  38. <h4>Sample Code</h4>
  39. <div><pre>
  40. #include &lt;<a href="../headers/control/if.html">boost/preprocessor/control/if.hpp</a>&gt;
  41. #include &lt;<a href="../headers/facilities/identity.html">boost/preprocessor/facilities/identity.hpp</a>&gt;
  42. #define MACRO_CAT(y,z) y ## z
  43. #define MACRO(n) <a href="if.html">BOOST_PP_IF</a>(n, <a href="identity_n.html">BOOST_PP_IDENTITY_N</a>(x,2), MACRO_CAT)(a,b)
  44. MACRO(0) // expands to ab
  45. MACRO(1) // expands to x
  46. </pre></div>
  47. <hr size="1">
  48. <div style="margin-left: 0px"><i>&copy; Copyright Edward Diener 2015</i></div>
  49. <div style="margin-left: 0px;">
  50. <p><small>Distributed under the Boost Software License, Version 1.0. (See
  51. accompanying file <a href="../../../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or
  52. copy at <a href=
  53. "http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</small></p>
  54. </div>
  55. </body>
  56. </html>