| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
- <title>Chapter 2. Boost.Array</title>
- <link rel="stylesheet" href="boostbook.css" type="text/css">
- <meta name="generator" content="DocBook XSL Stylesheets V1.68.1">
- <link rel="start" href="index.html" title="The Boost C++ Libraries">
- <link rel="up" href="libraries.html" title="Part I. The Boost C++ Libraries">
- <link rel="prev" href="any/s04.html" title="Acknowledgements">
- <link rel="next" href="array/reference.html" title="Reference">
- </head>
- <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
- <table cellpadding="2" width="100%">
- <td valign="top"><img alt="boost.png (6897 bytes)" width="277" height="86" src="../../boost.png"></td>
- <td align="center"><a href="../../index.htm">Home</a></td>
- <td align="center"><a href="../../libs/libraries.htm">Libraries</a></td>
- <td align="center"><a href="../../people/people.htm">People</a></td>
- <td align="center"><a href="../../more/faq.htm">FAQ</a></td>
- <td align="center"><a href="../../more/index.htm">More</a></td>
- </table>
- <hr>
- <div class="spirit-nav">
- <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>
- </div>
- <div class="chapter" lang="en">
- <div class="titlepage"><div>
- <div><h2 class="title">
- <a name="array"></a>Chapter 2. Boost.Array</h2></div>
- <div><div class="author"><h3 class="author">
- <span class="firstname">Nicolai</span> <span class="surname">Josuttis</span>
- </h3></div></div>
- <div><p class="copyright">Copyright © 2001-2004 Nicolai M. Josuttis</p></div>
- <div><div class="legalnotice">
- <a name="id971681"></a><p>Permission to copy, use, modify, sell and distribute this
- software is granted provided this copyright notice appears in
- all copies. This software is provided "as is" without express or
- implied warranty, and with no claim as to its suitability for
- any purpose.</p>
- </div></div>
- </div></div>
- <div class="toc">
- <p><b>Table of Contents</b></p>
- <dl>
- <dt><span class="section"><a href="array.html#array.intro">Introduction</a></span></dt>
- <dt><span class="section"><a href="array/reference.html">Reference</a></span></dt>
- <dd><dl><dt><span class="section"><a href="array/reference.html#header.boost.array.hpp">Header <boost/array.hpp></a></span></dt></dl></dd>
- <dt><span class="section"><a href="array/rationale.html">Design Rationale</a></span></dt>
- <dt><span class="section"><a href="array/more/info.html">For more information...</a></span></dt>
- <dt><span class="section"><a href="array/ack.html">Acknowledgements</a></span></dt>
- </dl>
- </div>
- <div class="section" lang="en">
- <div class="titlepage"><div><div><h3 class="title">
- <a name="array.intro"></a>Introduction</h3></div></div></div>
- <p>The C++ Standard Template Library STL as part of the C++
- Standard Library provides a framework for processing algorithms on
- different kind of containers. However, ordinary arrays don't
- provide the interface of STL containers (although, they provide
- the iterator interface of STL containers).</p>
- <p>As replacement for ordinary arrays, the STL provides class
- <code class="computeroutput">std::vector</code>. However,
- <code class="computeroutput">std::vector<></code> provides
- the semantics of dynamic arrays. Thus, it manages data to be able
- to change the number of elements. This results in some overhead in
- case only arrays with static size are needed.</p>
- <p>In his book, <span class="emphasis"><em>Generic Programming and the
- STL</em></span>, Matthew H. Austern introduces a useful wrapper
- class for ordinary arrays with static size, called
- <code class="computeroutput">block</code>. It is safer and has no worse performance than
- ordinary arrays. In <span class="emphasis"><em>The C++ Programming
- Language</em></span>, 3rd edition, Bjarne Stroustrup introduces a
- similar class, called <code class="computeroutput">c_array</code>, which I (<a href="http://www.josuttis.com" target="_top">Nicolai Josuttis</a>) present
- slightly modified in my book <span class="emphasis"><em>The C++ Standard Library -
- A Tutorial and Reference</em></span>, called
- <code class="computeroutput">carray</code>. This is the essence of these approaches
- spiced with many feedback from <a href="http://www.boost.org" target="_top">boost</a>.</p>
- <p>After considering different names, we decided to name this
- class simply <code class="computeroutput"><a href="boost/array.html" title="Class template array">array</a></code>.</p>
- <p>Note that this class is suggested to be part of the next
- Technical Report, which will extend the C++ Standard (see
- <a href="" target="_top">http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1548.htm</a>).</p>
- <p>Class <code class="computeroutput"><a href="boost/array.html" title="Class template array">array</a></code> fulfills most
- but not all of the requirements of "reversible containers" (see
- Section 23.1, [lib.container.requirements] of the C++
- Standard). The reasons array is not an reversible STL container is
- because:
- </p>
- <div class="itemizedlist"><ul type="disc" compact>
- <li>No constructors are provided.</li>
- <li>Elements may have an undetermined initial value (see <a href="array/rationale.html" title="Design Rationale">the section called “Design Rationale”</a>).</li>
- <li>
- <code class="computeroutput"><a href="boost/array.html#id763420">swap</a></code>() has no constant complexity.</li>
- <li>
- <code class="computeroutput"><a href="boost/array.html#id686133-bb">size</a></code>() is always constant, based on the second template argument of the type.</li>
- <li>The container provides no allocator support.</li>
- </ul></div>
- <p>It doesn't fulfill the requirements of a "sequence" (see Section 23.1.1, [lib.sequence.reqmts] of the C++ Standard), except that:
- </p>
- <div class="itemizedlist"><ul type="disc" compact>
- <li>
- <code class="computeroutput"><a href="boost/array.html#id763241-bb">front</a></code>() and <code class="computeroutput"><a href="boost/array.html#id763273-bb">back</a></code>() are provided.</li>
- <li>
- <code class="computeroutput"><a href="boost/array.html#id685146-bb">operator[]</a></code> and <code class="computeroutput"><a href="boost/array.html#id726524-bb">at</a></code>() are provided.</li>
- </ul></div>
- </div>
- </div>
- <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
- <td align="left"><small><p>Last revised: January 30, 2004 at 03:51:06 GMT</p></small></td>
- <td align="right"><small></small></td>
- </tr></table>
- <hr>
- <div class="spirit-nav">
- <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>
- </div>
- </body>
- </html>
|