list_cons.html 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <html>
  2. <head>
  3. <title>BOOST_PP_LIST_CONS</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_CONS</b> macro is a <i>list</i> constructor.
  9. </div>
  10. <h4>Usage</h4>
  11. <div class="code">
  12. <b>BOOST_PP_LIST_CONS</b>(<i>head</i>, <i>tail</i>)
  13. </div>
  14. <h4>Arguments</h4>
  15. <dl>
  16. <dt>head</dt>
  17. <dd>
  18. An element in a <i>list</i>.
  19. </dd>
  20. <dt>tail</dt>
  21. <dd>
  22. Either a <i>list</i>, <b>BOOST_PP_LIST_NIL</b>, or <b>BOOST_PP_NIL</b>.
  23. </dd>
  24. </dl>
  25. <h4>Remarks</h4>
  26. <div>
  27. This macro appends a new head to an existing <i>list</i> or creates a <i>list</i> from <b>BOOST_PP_LIST_NIL</b>.
  28. </div>
  29. <div>
  30. This macro is no longer necessary.&nbsp;
  31. For example...
  32. <div>
  33. <b>BOOST_PP_LIST_CONS</b>(a, <b>BOOST_PP_LIST_CONS</b>(b, <b>BOOST_PP_LIST_NIL</b>)))
  34. </div>
  35. ...is just an explicit way of writing the following:
  36. <div>
  37. (a, (b, <b>BOOST_PP_NIL</b>))
  38. </div>
  39. Because of this, this macro is deprecated.
  40. </div>
  41. <h4>See Also</h4>
  42. <ul>
  43. <li><a href="list_nil.html">BOOST_PP_LIST_NIL</a></li>
  44. <li><a href="nil.html">BOOST_PP_NIL</a></li>
  45. </ul>
  46. <h4>Requirements</h4>
  47. <div>
  48. <b>Header:</b> &nbsp;<a href="../headers/list/adt.html">&lt;boost/preprocessor/list/adt.hpp&gt;</a>
  49. </div>
  50. <h4>Sample Code</h4>
  51. <div><pre>
  52. #include &lt;<a href="../headers/list/adt.html">boost/preprocessor/list/adt.hpp</a>&gt;
  53. #define OLD \
  54. <a href="list_cons.html">BOOST_PP_LIST_CONS</a>( \
  55. a, \
  56. <a href="list_cons.html">BOOST_PP_LIST_CONS</a>( \
  57. b, \
  58. <a href="list_cons.html">BOOST_PP_LIST_CONS</a>( \
  59. c, \
  60. <a href="list_nil.html">BOOST_PP_LIST_NIL</a> \
  61. ) \
  62. ) \
  63. ) \
  64. /**/
  65. #define NEW (a, (b, (c, <a href="nil.html">BOOST_PP_NIL</a>)))
  66. <a href="list_first.html">BOOST_PP_LIST_FIRST</a>(OLD) == <a href="list_first.html">BOOST_PP_LIST_FIRST</a>(NEW)
  67. // expands to a == a
  68. <a href="list_rest.html">BOOST_PP_LIST_REST</a>(OLD) == <a href="list_rest.html">BOOST_PP_LIST_REST</a>(NEW)
  69. // expands to (b, (c, <a href="nil.html">BOOST_PP_NIL</a>)) == (b, (c, <a href="nil.html">BOOST_PP_NIL</a>))
  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>