56 lines
2.9 KiB
HTML
56 lines
2.9 KiB
HTML
<html>
|
||
<head>
|
||
<meta content="text/html; charset=windows-1252" http-equiv="content-type">
|
||
<title>arrays.html</title>
|
||
<link rel="stylesheet" type="text/css" href="../styles.css">
|
||
</head>
|
||
<body>
|
||
<h4>Arrays</h4>
|
||
<div> An <i>array</i> is a data structure consisting of a two-element <i>tuple</i>.
|
||
The first element is the number of elements in the <i>array</i>.
|
||
The second element is another <i>tuple</i> of the elements in the <i>array</i>.
|
||
For example, </div>
|
||
<div class="code"> (<i>3</i>, (<i>a</i>, <i>b</i>, <i>c</i>)) </div>
|
||
<div> ...is an <i>array</i> of <i>3</i> elements--<i>a</i>, <i>b</i>, and
|
||
<i>c</i>. </div>
|
||
<div> The primary strength of <i>arrays</i> is that they store their own
|
||
size. Because of this, access to elements does not require the
|
||
size. It only requires that an element exists at a certain index. </div>
|
||
<div> This allows macro parameters to be variable in size and allows data
|
||
states to change size without the user explicitly keeping track of the
|
||
size independently.<br>
|
||
<br>
|
||
An <i>array </i>can be empty and have no elements. An empty array has a
|
||
0 size. The notation for an empty array is '(0,())'.<br>
|
||
<br>
|
||
<span style="font-style: italic;"> </span></div>
|
||
<div>With variadic macro support a <i>tuple </i>has all of the
|
||
functionality as an <i>array</i>, knows its own size, and is easier
|
||
syntactically to use. Because of that an <i>array</i> should be used, as
|
||
opposed to a <i>tuple</i>, only if your compiler does not support
|
||
variadic macros. The only advantage an <i>array </i>has over a <i>tuple
|
||
</i>is that an <i>array </i>can be empty while a <i>tuple </i>always
|
||
has at least one element and therefore can never have a size of 0.<br>
|
||
<br>
|
||
Elements of an <i>array</i> can be extracted with <b>BOOST_PP_ARRAY_ELEM</b>,
|
||
an <i>array's</i> size can be extracted with <b>BOOST_PP_ARRAY_SIZE</b>,
|
||
and an <i>array</i> can be converted to the more primitive <i>tuple</i>
|
||
data structure with <b>BOOST_PP_ARRAY_DATA</b>. </div>
|
||
<h4>Primitives</h4>
|
||
<ul>
|
||
<li><a href="../ref/array_data.html">BOOST_PP_ARRAY_DATA</a></li>
|
||
<li><a href="../ref/array_elem.html">BOOST_PP_ARRAY_ELEM</a></li>
|
||
<li><a href="../ref/array_size.html">BOOST_PP_ARRAY_SIZE</a></li>
|
||
</ul>
|
||
<hr size="1">
|
||
<div style="margin-left: 0px;"> <i><EFBFBD> Copyright <a href="http://www.housemarque.com"
|
||
target="_top">Housemarque Oy</a> 2002</i> <br>
|
||
<i><EFBFBD> Copyright Paul Mensonides 2002</i> </div>
|
||
<div style="margin-left: 0px;">
|
||
<p><small>Distributed under the Boost Software License, Version 1.0. (See
|
||
accompanying file <a href="../../../../LICENSE_1_0.txt">LICENSE_1_0.txt</a>
|
||
or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</small></p>
|
||
</div>
|
||
</body>
|
||
</html>
|