Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/doc/html/array.html @ 12

Last change on this file since 12 was 12, checked in by landauf, 18 years ago

added boost

File size: 7.0 KB
RevLine 
[12]1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
4<title>Chapter 2. Boost.Array</title>
5<link rel="stylesheet" href="boostbook.css" type="text/css">
6<meta name="generator" content="DocBook XSL Stylesheets V1.69.1">
7<link rel="start" href="index.html" title="The Boost C++ Libraries">
8<link rel="up" href="libraries.html" title="Part I. The Boost C++ Libraries">
9<link rel="prev" href="any/s04.html" title="Acknowledgements">
10<link rel="next" href="array/reference.html" title="Reference">
11</head>
12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13<table cellpadding="2" width="100%">
14<td valign="top"><img alt="boost.png (6897 bytes)" width="277" height="86" src="../../boost.png"></td>
15<td align="center"><a href="../../index.htm">Home</a></td>
16<td align="center"><a href="../../libs/libraries.htm">Libraries</a></td>
17<td align="center"><a href="../../people/people.htm">People</a></td>
18<td align="center"><a href="../../more/faq.htm">FAQ</a></td>
19<td align="center"><a href="../../more/index.htm">More</a></td>
20</table>
21<hr>
22<div class="spirit-nav">
23<a accesskey="p" href="any/s04.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="libraries.html"><img src="images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="images/home.png" alt="Home"></a><a accesskey="n" href="array/reference.html"><img src="images/next.png" alt="Next"></a>
24</div>
25<div class="chapter" lang="en">
26<div class="titlepage"><div>
27<div><h2 class="title">
28<a name="array"></a>Chapter 2. Boost.Array</h2></div>
29<div><div class="author"><h3 class="author">
30<span class="firstname">Nicolai</span> <span class="surname">Josuttis</span>
31</h3></div></div>
32<div><p class="copyright">Copyright © 2001-2004 Nicolai M. Josuttis</p></div>
33<div><div class="legalnotice">
34<a name="id2572269"></a><p>Permission to copy, use, modify, sell and distribute this
35      software is granted provided this copyright notice appears in
36      all copies. This software is provided "as is" without express or
37      implied warranty, and with no claim as to its suitability for
38      any purpose.</p>
39</div></div>
40</div></div>
41<div class="toc">
42<p><b>Table of Contents</b></p>
43<dl>
44<dt><span class="section"><a href="array.html#array.intro">Introduction</a></span></dt>
45<dt><span class="section"><a href="array/reference.html">Reference</a></span></dt>
46<dd><dl><dt><span class="section"><a href="array/reference.html#header.boost.array.hpp">Header &lt;boost/array.hpp&gt;</a></span></dt></dl></dd>
47<dt><span class="section"><a href="array/rationale.html">Design Rationale</a></span></dt>
48<dt><span class="section"><a href="array/more/info.html">For more information...</a></span></dt>
49<dt><span class="section"><a href="array/ack.html">Acknowledgements</a></span></dt>
50</dl>
51</div>
52<div class="section" lang="en">
53<div class="titlepage"><div><div><h3 class="title">
54<a name="array.intro"></a>Introduction</h3></div></div></div>
55<p>The C++ Standard Template Library STL as part of the C++
56    Standard Library provides a framework for processing algorithms on
57    different kind of containers. However, ordinary arrays don't
58    provide the interface of STL containers (although, they provide
59    the iterator interface of STL containers).</p>
60<p>As replacement for ordinary arrays, the STL provides class
61    <code class="computeroutput">std::vector</code>.  However,
62    <code class="computeroutput">std::vector&lt;&gt;</code> provides
63    the semantics of dynamic arrays. Thus, it manages data to be able
64    to change the number of elements. This results in some overhead in
65    case only arrays with static size are needed.</p>
66<p>In his book, <span class="emphasis"><em>Generic Programming and the
67    STL</em></span>, Matthew H. Austern introduces a useful wrapper
68    class for ordinary arrays with static size, called
69    <code class="computeroutput">block</code>.  It is safer and has no worse performance than
70    ordinary arrays. In <span class="emphasis"><em>The C++ Programming
71    Language</em></span>, 3rd edition, Bjarne Stroustrup introduces a
72    similar class, called <code class="computeroutput">c_array</code>, which I (<a href="http://www.josuttis.com" target="_top">Nicolai Josuttis</a>) present
73    slightly modified in my book <span class="emphasis"><em>The C++ Standard Library -
74    A Tutorial and Reference</em></span>, called
75    <code class="computeroutput">carray</code>. This is the essence of these approaches
76    spiced with many feedback from <a href="http://www.boost.org" target="_top">boost</a>.</p>
77<p>After considering different names, we decided to name this
78    class simply <code class="computeroutput"><a href="boost/array.html" title="Class template array">array</a></code>.</p>
79<p>Note that this class is suggested to be part of the next
80    Technical Report, which will extend the C++ Standard (see
81    <a href="http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1548.htm" target="_top">http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1548.htm</a>).</p>
82<p>Class <code class="computeroutput"><a href="boost/array.html" title="Class template array">array</a></code> fulfills most
83    but not all of the requirements of "reversible containers" (see
84    Section 23.1, [lib.container.requirements] of the C++
85    Standard). The reasons array is not an reversible STL container is
86    because:
87      </p>
88<div class="itemizedlist"><ul type="disc" compact>
89<li>No constructors are provided.</li>
90<li>Elements may have an undetermined initial value (see <a href="array/rationale.html" title="Design Rationale">the section called &#8220;Design Rationale&#8221;</a>).</li>
91<li>
92<code class="computeroutput"><a href="boost/array.html#id2383066">swap</a></code>() has no constant complexity.</li>
93<li>
94<code class="computeroutput"><a href="boost/array.html#id2355750-bb">size</a></code>() is always constant, based on the second template argument of the type.</li>
95<li>The container provides no allocator support.</li>
96</ul></div>
97<p>It doesn't fulfill the requirements of a "sequence" (see Section 23.1.1, [lib.sequence.reqmts] of the C++ Standard), except that:
98      </p>
99<div class="itemizedlist"><ul type="disc" compact>
100<li>
101<code class="computeroutput"><a href="boost/array.html#id2365761-bb">front</a></code>() and <code class="computeroutput"><a href="boost/array.html#id2365801-bb">back</a></code>() are provided.</li>
102<li>
103<code class="computeroutput"><a href="boost/array.html#id2365634-bb">operator[]</a></code> and <code class="computeroutput"><a href="boost/array.html#id2365698-bb">at</a></code>() are provided.</li>
104</ul></div>
105</div>
106</div>
107<table width="100%"><tr>
108<td align="left"><small><p>Last revised: December 01, 2005 at 04:52:03 GMT</p></small></td>
109<td align="right"><small></small></td>
110</tr></table>
111<hr>
112<div class="spirit-nav">
113<a accesskey="p" href="any/s04.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="libraries.html"><img src="images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="images/home.png" alt="Home"></a><a accesskey="n" href="array/reference.html"><img src="images/next.png" alt="Next"></a>
114</div>
115</body>
116</html>
Note: See TracBrowser for help on using the repository browser.