Files
preprocessor/doc/reference/list_adt.htm
Vesa Karvonen 2b9fee0cff How to make longer lists
[SVN r13037]
2002-03-03 08:39:30 +00:00

135 lines
4.9 KiB
HTML

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Boost.Preprocessor - Reference</title>
</head>
<body bgcolor="#FFFFFF" link="#0000ff" vlink="#800080">
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
"header">
<tr>
<td valign="top" width="300">
<h3><a href="../../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../../c++boost.gif" border="0"></a></h3>
</td>
<td valign="top">
<h1 align="center">Boost.Preprocessor</h1>
<h2 align="center">Reference</h2>
</td>
</tr>
</table>
<hr>
<a href="list.htm">Prev</a> <a href="list_append.htm">Next</a> <a href="index.htm#Macros">Macros</a> <a href="index.htm#Headers">Headers</a>
<hr>
<h1>#include &lt;<a href="../../../../boost/preprocessor/list/adt.hpp">boost/preprocessor/list/adt.hpp</a>&gt;</h1>
<p>This header defines the fundamental list operations.</p>
<h3>Note</h3>
<ul>
<li>The internal representation of lists is hidden. Although there aren't
compelling reasons to change the representation, you should avoid
writing code that depends on the internal representation details.</li>
</ul>
<hr>
<h2><a name="BOOST_PP_LIST_CONS">#define BOOST_PP_LIST_CONS</a>(H,T)</h2>
<p>List constructor.</p>
<p>Lists are build using list constructors <a href="list_adt.htm#BOOST_PP_LIST_NIL">BOOST_PP_LIST_NIL</a> and
<a href="list_adt.htm#BOOST_PP_LIST_CONS">BOOST_PP_LIST_CONS</a>(). For example,</p>
<pre>
<a href="list_adt.htm#BOOST_PP_LIST_CONS">BOOST_PP_LIST_CONS</a>(1,
<a href="list_adt.htm#BOOST_PP_LIST_CONS">BOOST_PP_LIST_CONS</a>(2,
<a href="list_adt.htm#BOOST_PP_LIST_CONS">BOOST_PP_LIST_CONS</a>(3,
<a href="list_adt.htm#BOOST_PP_LIST_CONS">BOOST_PP_LIST_CONS</a>(4,
<a href="list_adt.htm#BOOST_PP_LIST_CONS">BOOST_PP_LIST_CONS</a>(5,
<a href="list_adt.htm#BOOST_PP_LIST_NIL">BOOST_PP_LIST_NIL</a>)))))
</pre>
<p>Short lists can also be build from tuples:</p>
<pre>
<a href="tuple_to_list.htm#BOOST_PP_TUPLE_TO_LIST">BOOST_PP_TUPLE_TO_LIST</a>(5,(1,2,3,4,5))
</pre>
<p>Both of the above lists contain 5 elements: 1, 2, 3, 4 and 5.</p>
<p>Longer lists can be built from short lists with <a href="list_append.htm#BOOST_PP_LIST_APPEND_D">BOOST_PP_LIST_APPEND_D</a>()
and <a href="list_fold_right_2nd.htm#BOOST_PP_LIST_FOLD_RIGHT_2ND">BOOST_PP_LIST_FOLD_RIGHT_2ND</a>():</p>
<pre>
<a href="list_fold_right_2nd.htm#BOOST_PP_LIST_FOLD_RIGHT_2ND">BOOST_PP_LIST_FOLD_RIGHT_2ND</a>
( <a href="list_append.htm#BOOST_PP_LIST_APPEND_D">BOOST_PP_LIST_APPEND_D</a>
, <a href="tuple_to_list.htm#BOOST_PP_TUPLE_TO_LIST">BOOST_PP_TUPLE_TO_LIST</a>
( N
, <a href="tuple_to_list.htm#BOOST_PP_TUPLE_TO_LIST">BOOST_PP_TUPLE_TO_LIST</a>(M, (E11, E12, ..., E1M) )
, <a href="tuple_to_list.htm#BOOST_PP_TUPLE_TO_LIST">BOOST_PP_TUPLE_TO_LIST</a>(M, (E21, E22, ..., E2M) )
, ...
, <a href="tuple_to_list.htm#BOOST_PP_TUPLE_TO_LIST">BOOST_PP_TUPLE_TO_LIST</a>(M, (EN1, EN2, ..., ENM) )
)
)
</pre>
<hr>
<h2><a name="BOOST_PP_LIST_NIL">#define BOOST_PP_LIST_NIL</a></h2>
<p>List nil constructor.</p>
<hr>
<h2><a name="BOOST_PP_LIST_IS_CONS">#define BOOST_PP_LIST_IS_CONS</a>(L)</h2>
<p>Expands to 1 if the list is not nil and 0 otherwise.</p>
<hr>
<h2><a name="BOOST_PP_LIST_IS_NIL">#define BOOST_PP_LIST_IS_NIL</a>(L)</h2>
<p>Expands to 1 if the list is nil and 0 otherwise.</p>
<hr>
<h2><a name="BOOST_PP_LIST_FIRST">#define BOOST_PP_LIST_FIRST</a>(L)</h2>
<p>Expands to the first element of the list. The list must not be nil.</p>
<p>For example,</p>
<pre>
<a href="list_adt.htm#BOOST_PP_LIST_FIRST">BOOST_PP_LIST_FIRST</a>(<a href="tuple_to_list.htm#BOOST_PP_TUPLE_TO_LIST">BOOST_PP_TUPLE_TO_LIST</a>(5,(1,2,3,4,5)))
</pre>
<p>expands to 1.</p>
<hr>
<h2><a name="BOOST_PP_LIST_REST">#define BOOST_PP_LIST_REST</a>(L)</h2>
<p>Expands to a list of all but the first element of the list.</p>
<p>The list must not be nil.</p>
<p>For example,</p>
<pre>
<a href="list_adt.htm#BOOST_PP_LIST_REST">BOOST_PP_LIST_REST</a>(<a href="tuple_to_list.htm#BOOST_PP_TUPLE_TO_LIST">BOOST_PP_TUPLE_TO_LIST</a>(5,(1,2,3,4,5)))
</pre>
<p>expands to the same as:</p>
<pre>
<a href="tuple_to_list.htm#BOOST_PP_TUPLE_TO_LIST">BOOST_PP_TUPLE_TO_LIST</a>(4,(2,3,4,5))
</pre>
<hr>
<a href="list.htm">Prev</a> <a href="list_append.htm">Next</a> <a href="index.htm#Macros">Macros</a> <a href="index.htm#Headers">Headers</a>
<hr>
<p>Revised <!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %b %Y" startspan --><!--webbot bot="Timestamp" endspan i-checksum="15246" --></p>
<p><i>&copy; Copyright <a href="http://www.housemarque.com">Housemarque Oy</a> 2002</i></p>
<p><i>Permission to copy, use, modify, sell and distribute this document is granted
provided this copyright notice appears in all copies. This document is provided
"as is" without express or implied warranty, and with no claim as to its suitability
for any purpose.</i></p>
</body></html>