Files
preprocessor/docs.1/ref/list_cons.html
Paul Mensonides cdc4be5256 initial revision
[SVN r15198]
2002-09-08 09:40:56 +00:00

78 lines
2.2 KiB
HTML

<html>
<head>
<title>BOOST_PP_LIST_CONS</title>
<link rel="stylesheet" type="text/css" href="../styles.css">
<script language="javascript" type="text/javascript" src="../scripts.js"></script>
</head>
<body onload="init('sample');">
<div style="margin-left: 0px;">
The <b>BOOST_PP_LIST_CONS</b> macro is a <i>list</i> constructor.
</div>
<h4>Usage</h4>
<div class="code">
<b>BOOST_PP_LIST_CONS</b>(<i>head</i>, <i>tail</i>)
</div>
<h4>Arguments</h4>
<dl>
<dt>head</dt>
<dd>
An element in a <i>list</i>.
</dd>
<dt>tail</dt>
<dd>
Either a <i>list</i>, <b>BOOST_PP_LIST_NIL</b>, or <b>BOOST_PP_NIL</b>.
</dd>
</dl>
<h4>Remarks</h4>
<div>
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>.
</div>
<div>
This macro is no longer necessary.&nbsp;
For example...
<div>
<b>BOOST_PP_LIST_CONS</b>(a, <b>BOOST_PP_LIST_CONS</b>(b, <b>BOOST_PP_LIST_NIL</b>)))
</div>
...is just an explicit way of writing the following:
<div>
(a, (b, <b>BOOST_PP_NIL</b>))
</div>
Because of this, this macro is deprecated.
</div>
<h4>See Also</h4>
<ul>
<li><a href="list_nil.html">BOOST_PP_LIST_NIL</a></li>
<li><a href="nil.html">BOOST_PP_NIL</a></li>
</ul>
<h4>Requirements</h4>
<div>
<b>Header:</b> &nbsp;<a href="../headers/list/adt.hpp.html">&lt;boost/preprocessor/list/adt.hpp&gt;</a>
</div>
<h4><a class="local" onclick="toggle('sample');" onmouseover="change(this);" onmouseout="revert(this);">Sample Code</a></h4>
<div id="sample"><pre>
#include &lt;boost/preprocessor/list/adt.hpp&gt;
#define OLD /* ........... */ \
BOOST_PP_LIST_CONS( \
a, \
BOOST_PP_LIST_CONS( \
b, \
BOOST_PP_LIST_CONS( \
c, \
BOOST_PP_LIST_NIL \
) \
) \
) \
/**/
#define NEW (a, (b, (c, BOOST_PP_NIL)))
BOOST_PP_LIST_FIRST(OLD) == BOOST_PP_LIST_FIRST(NEW)
// expands to a == a
BOOST_PP_LIST_REST(OLD) == BOOST_PP_LIST_REST(NEW)
// expands to (b, (c, BOOST_PP_NIL)) == (b, (c, BOOST_PP_NIL))
<pre></div>
</body>
</html>