02abc8c9a4
Whatever version of xsltproc I'm not using generates even longer id numbers, which means that the base id needs to be further truncated to make space for them.
311 lines
62 KiB
Plaintext
311 lines
62 KiB
Plaintext
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
|
|
<chapter xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" id="array" rev:last-revision="$Date$">
|
|
<chapterinfo><author>
|
|
<firstname>Nicolai</firstname>
|
|
<surname>Josuttis</surname>
|
|
</author><copyright>
|
|
<year>2001</year>
|
|
<year>2002</year>
|
|
<year>2003</year>
|
|
<year>2004</year>
|
|
<holder>Nicolai M. Josuttis</holder>
|
|
</copyright><legalnotice>
|
|
<para>Distributed under the Boost Software License, Version 1.0.
|
|
(See accompanying file <filename>LICENSE_1_0.txt</filename> or copy at
|
|
<ulink url="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</ulink>)
|
|
</para>
|
|
</legalnotice></chapterinfo>
|
|
|
|
<title>Boost.Array</title>
|
|
|
|
<section id="array.intro">
|
|
<title>Introduction</title>
|
|
|
|
|
|
|
|
|
|
<para>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).</para>
|
|
|
|
<para>As replacement for ordinary arrays, the STL provides class
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude">std::vector</computeroutput>. However,
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude">std::vector<></computeroutput> 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.</para>
|
|
|
|
<para>In his book, <emphasis>Generic Programming and the
|
|
STL</emphasis>, Matthew H. Austern introduces a useful wrapper
|
|
class for ordinary arrays with static size, called
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude">block</computeroutput>. It is safer and has no worse performance than
|
|
ordinary arrays. In <emphasis>The C++ Programming
|
|
Language</emphasis>, 3rd edition, Bjarne Stroustrup introduces a
|
|
similar class, called <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude">c_array</computeroutput>, which I (<ulink url="http://www.josuttis.com">Nicolai Josuttis</ulink>) present
|
|
slightly modified in my book <emphasis>The C++ Standard Library -
|
|
A Tutorial and Reference</emphasis>, called
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude">carray</computeroutput>. This is the essence of these approaches
|
|
spiced with many feedback from <ulink url="http://www.boost.org">boost</ulink>.</para>
|
|
|
|
<para>After considering different names, we decided to name this
|
|
class simply <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.array">array</link></computeroutput>.</para>
|
|
|
|
<para>Note that this class is suggested to be part of the next
|
|
Technical Report, which will extend the C++ Standard (see
|
|
<ulink url="http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1548.htm">http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1548.htm</ulink>).</para>
|
|
|
|
<para>Class <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.array">array</link></computeroutput> 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:
|
|
<itemizedlist spacing="compact">
|
|
<listitem><simpara>No constructors are provided.</simpara></listitem>
|
|
<listitem><simpara>Elements may have an undetermined initial value (see <xref linkend="array.rationale"/>).</simpara></listitem>
|
|
<listitem><simpara><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.array.swap">swap</link></computeroutput>() has no constant complexity.</simpara></listitem>
|
|
<listitem><simpara><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="id17-bb">size</link></computeroutput>() is always constant, based on the second template argument of the type.</simpara></listitem>
|
|
<listitem><simpara>The container provides no allocator support.</simpara></listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
|
|
<para>It doesn't fulfill the requirements of a "sequence" (see Section 23.1.1, [lib.sequence.reqmts] of the C++ Standard), except that:
|
|
<itemizedlist spacing="compact">
|
|
<listitem><simpara><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="id27-bb">front</link></computeroutput>() and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="id30-bb">back</link></computeroutput>() are provided.</simpara></listitem>
|
|
<listitem><simpara><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="id21-bb">operator[]</link></computeroutput> and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="id24-bb">at</link></computeroutput>() are provided.</simpara></listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
</section>
|
|
|
|
<section id="array.reference"><title>Reference</title>
|
|
<section id="header.boost.array_hpp"><title>Header <<ulink url="../../boost/array.hpp">boost/array.hpp</ulink>></title><synopsis xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase>
|
|
<phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">typename</phrase> T<phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> N<phrase role="special">></phrase> <phrase role="keyword">class</phrase> <link linkend="boost.array">array</link><phrase role="special">;</phrase>
|
|
<phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">typename</phrase> T<phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> N<phrase role="special">></phrase> <phrase role="keyword">void</phrase> <link linkend="boost.array.swap"><phrase role="identifier">swap</phrase></link><phrase role="special">(</phrase><link linkend="boost.array">array</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase><phrase role="special">&</phrase><phrase role="special">,</phrase> <link linkend="boost.array">array</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase><phrase role="special">&</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
|
|
<phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">typename</phrase> T<phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> N<phrase role="special">></phrase>
|
|
<phrase role="keyword">bool</phrase> <link linkend="boost.array.operator=="><phrase role="keyword">operator</phrase><phrase role="special">==</phrase></link><phrase role="special">(</phrase><phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase><phrase role="special">&</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase><phrase role="special">&</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
|
|
<phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">typename</phrase> T<phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> N<phrase role="special">></phrase>
|
|
<phrase role="keyword">bool</phrase> <link linkend="boost.array.operator!="><phrase role="keyword">operator</phrase><phrase role="special">!=</phrase></link><phrase role="special">(</phrase><phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase><phrase role="special">&</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase><phrase role="special">&</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
|
|
<phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">typename</phrase> T<phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> N<phrase role="special">></phrase>
|
|
<phrase role="keyword">bool</phrase> <link linkend="boost.array.operato_id1"><phrase role="keyword">operator</phrase><phrase role="special"><</phrase></link><phrase role="special">(</phrase><phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase><phrase role="special">&</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase><phrase role="special">&</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
|
|
<phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">typename</phrase> T<phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> N<phrase role="special">></phrase>
|
|
<phrase role="keyword">bool</phrase> <link linkend="boost.array.operato_id2"><phrase role="keyword">operator</phrase><phrase role="special">></phrase></link><phrase role="special">(</phrase><phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase><phrase role="special">&</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase><phrase role="special">&</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
|
|
<phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">typename</phrase> T<phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> N<phrase role="special">></phrase>
|
|
<phrase role="keyword">bool</phrase> <link linkend="boost.array.operato_id3"><phrase role="keyword">operator</phrase><phrase role="special"><=</phrase></link><phrase role="special">(</phrase><phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase><phrase role="special">&</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase><phrase role="special">&</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
|
|
<phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">typename</phrase> T<phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> N<phrase role="special">></phrase>
|
|
<phrase role="keyword">bool</phrase> <link linkend="boost.array.operato_id4"><phrase role="keyword">operator</phrase><phrase role="special">>=</phrase></link><phrase role="special">(</phrase><phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase><phrase role="special">&</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase><phrase role="special">&</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
|
|
<phrase role="special">}</phrase></synopsis>
|
|
<refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="boost.array"><refmeta><refentrytitle>Class template array</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>boost::array</refname><refpurpose>STL compliant container wrapper for arrays of constant size</refpurpose></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: <<link linkend="header.boost.array_hpp">boost/array.hpp</link>>
|
|
|
|
</phrase><phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">typename</phrase> T<phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> N<phrase role="special">></phrase>
|
|
<phrase role="keyword">class</phrase> <link linkend="boost.array">array</link> <phrase role="special">{</phrase>
|
|
<phrase role="keyword">public</phrase><phrase role="special">:</phrase>
|
|
<phrase role="comment">// types</phrase>
|
|
<phrase role="keyword">typedef</phrase> <phrase role="identifier">T</phrase> <anchor id="boost.array.value_type"/><phrase role="identifier">value_type</phrase><phrase role="special">;</phrase>
|
|
<phrase role="keyword">typedef</phrase> <phrase role="identifier">T</phrase><phrase role="special">*</phrase> <anchor id="boost.array.iterator"/><phrase role="identifier">iterator</phrase><phrase role="special">;</phrase>
|
|
<phrase role="keyword">typedef</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">T</phrase><phrase role="special">*</phrase> <anchor id="boost.array.const_iterator"/><phrase role="identifier">const_iterator</phrase><phrase role="special">;</phrase>
|
|
<phrase role="keyword">typedef</phrase> std::reverse_iterator<phrase role="special"><</phrase><phrase role="identifier">iterator</phrase><phrase role="special">></phrase> <anchor id="boost.array.reverse_iterator"/><phrase role="identifier">reverse_iterator</phrase><phrase role="special">;</phrase>
|
|
<phrase role="keyword">typedef</phrase> std::reverse_iterator<phrase role="special"><</phrase><phrase role="identifier">const_iterator</phrase><phrase role="special">></phrase> <anchor id="boost.array.const_reverse_iterator"/><phrase role="identifier">const_reverse_iterator</phrase><phrase role="special">;</phrase>
|
|
<phrase role="keyword">typedef</phrase> <phrase role="identifier">T</phrase><phrase role="special">&</phrase> <anchor id="boost.array.reference"/><phrase role="identifier">reference</phrase><phrase role="special">;</phrase>
|
|
<phrase role="keyword">typedef</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">T</phrase><phrase role="special">&</phrase> <anchor id="boost.array.const_reference"/><phrase role="identifier">const_reference</phrase><phrase role="special">;</phrase>
|
|
<phrase role="keyword">typedef</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <anchor id="boost.array.size_type"/><phrase role="identifier">size_type</phrase><phrase role="special">;</phrase>
|
|
<phrase role="keyword">typedef</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">ptrdiff_t</phrase> <anchor id="boost.array.difference_type"/><phrase role="identifier">difference_type</phrase><phrase role="special">;</phrase>
|
|
|
|
<phrase role="comment">// static constants</phrase>
|
|
<phrase role="keyword">static</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">size_type</phrase> <phrase role="identifier">static_size</phrase> = <phrase role="identifier">N</phrase><phrase role="special">;</phrase>
|
|
|
|
<phrase role="comment">// <link linkend="boost.arrayconstruct-copy-destruct">construct/copy/destruct</link></phrase>
|
|
<phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">typename</phrase> U<phrase role="special">></phrase> array& <link linkend="id1-bb"><phrase role="keyword">operator</phrase><phrase role="special">=</phrase></link><phrase role="special">(</phrase><phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special"><</phrase><phrase role="identifier">U</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase><phrase role="special">&</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
|
|
|
|
<phrase role="comment">// <link linkend="id2-bb">iterator support</link></phrase>
|
|
<phrase role="identifier">iterator</phrase> <link linkend="id4-bb"><phrase role="identifier">begin</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
|
|
<phrase role="identifier">const_iterator</phrase> <link linkend="id5-bb"><phrase role="identifier">begin</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
|
|
<phrase role="identifier">iterator</phrase> <link linkend="id7-bb"><phrase role="identifier">end</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
|
|
<phrase role="identifier">const_iterator</phrase> <link linkend="id8-bb"><phrase role="identifier">end</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
|
|
|
|
<phrase role="comment">// <link linkend="id9-bb">reverse iterator support</link></phrase>
|
|
<phrase role="identifier">reverse_iterator</phrase> <link linkend="id11-bb"><phrase role="identifier">rbegin</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
|
|
<phrase role="identifier">const_reverse_iterator</phrase> <link linkend="id12-bb"><phrase role="identifier">rbegin</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
|
|
<phrase role="identifier">reverse_iterator</phrase> <link linkend="id14-bb"><phrase role="identifier">rend</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
|
|
<phrase role="identifier">const_reverse_iterator</phrase> <link linkend="id15-bb"><phrase role="identifier">rend</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
|
|
|
|
<phrase role="comment">// <link linkend="id16-bb">capacity</link></phrase>
|
|
<phrase role="identifier">size_type</phrase> <link linkend="id17-bb"><phrase role="identifier">size</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
|
|
<phrase role="keyword">bool</phrase> <link linkend="id18-bb"><phrase role="identifier">empty</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
|
|
<phrase role="identifier">size_type</phrase> <link linkend="id19-bb"><phrase role="identifier">max_size</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
|
|
|
|
<phrase role="comment">// <link linkend="id20-bb">element access</link></phrase>
|
|
<phrase role="identifier">reference</phrase> <link linkend="id22-bb"><phrase role="keyword">operator</phrase><phrase role="special">[</phrase><phrase role="special">]</phrase></link><phrase role="special">(</phrase><phrase role="identifier">size_type</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
|
|
<phrase role="identifier">const_reference</phrase> <link linkend="id23-bb"><phrase role="keyword">operator</phrase><phrase role="special">[</phrase><phrase role="special">]</phrase></link><phrase role="special">(</phrase><phrase role="identifier">size_type</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
|
|
<phrase role="identifier">reference</phrase> <link linkend="id25-bb"><phrase role="identifier">at</phrase></link><phrase role="special">(</phrase><phrase role="identifier">size_type</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
|
|
<phrase role="identifier">const_reference</phrase> <link linkend="id26-bb"><phrase role="identifier">at</phrase></link><phrase role="special">(</phrase><phrase role="identifier">size_type</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
|
|
<phrase role="identifier">reference</phrase> <link linkend="id28-bb"><phrase role="identifier">front</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
|
|
<phrase role="identifier">const_reference</phrase> <link linkend="id29-bb"><phrase role="identifier">front</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
|
|
<phrase role="identifier">reference</phrase> <link linkend="id31-bb"><phrase role="identifier">back</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
|
|
<phrase role="identifier">const_reference</phrase> <link linkend="id32-bb"><phrase role="identifier">back</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
|
|
<phrase role="keyword">const</phrase> <phrase role="identifier">T</phrase><phrase role="special">*</phrase> <link linkend="id33-bb"><phrase role="identifier">data</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
|
|
<phrase role="identifier">T</phrase><phrase role="special">*</phrase> <link linkend="id34-bb"><phrase role="identifier">c_array</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
|
|
|
|
<phrase role="comment">// <link linkend="id35-bb">modifiers</link></phrase>
|
|
<phrase role="keyword">void</phrase> <link linkend="id36-bb"><phrase role="identifier">swap</phrase></link><phrase role="special">(</phrase><link linkend="boost.array">array</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase><phrase role="special">&</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
|
|
<phrase role="keyword">void</phrase> <link linkend="id37-bb"><phrase role="identifier">assign</phrase></link><phrase role="special">(</phrase><phrase role="keyword">const</phrase> <phrase role="identifier">T</phrase><phrase role="special">&</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
|
|
|
|
<phrase role="comment">// public data members</phrase>
|
|
<phrase role="identifier">T</phrase> <phrase role="identifier">elems[N]</phrase><phrase role="special">;</phrase>
|
|
<phrase role="special">}</phrase><phrase role="special">;</phrase>
|
|
|
|
<phrase role="comment">// <link linkend="id38-bb">specialized algorithms</link></phrase>
|
|
<phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">typename</phrase> T<phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> N<phrase role="special">></phrase> <phrase role="keyword">void</phrase> <link linkend="boost.array.swap"><phrase role="identifier">swap</phrase></link><phrase role="special">(</phrase><link linkend="boost.array">array</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase><phrase role="special">&</phrase><phrase role="special">,</phrase> <link linkend="boost.array">array</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase><phrase role="special">&</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
|
|
|
|
<phrase role="comment">// <link linkend="id39-bb">comparisons</link></phrase>
|
|
<phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">typename</phrase> T<phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> N<phrase role="special">></phrase>
|
|
<phrase role="keyword">bool</phrase> <link linkend="boost.array.operator=="><phrase role="keyword">operator</phrase><phrase role="special">==</phrase></link><phrase role="special">(</phrase><phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase><phrase role="special">&</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase><phrase role="special">&</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
|
|
<phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">typename</phrase> T<phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> N<phrase role="special">></phrase>
|
|
<phrase role="keyword">bool</phrase> <link linkend="boost.array.operator!="><phrase role="keyword">operator</phrase><phrase role="special">!=</phrase></link><phrase role="special">(</phrase><phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase><phrase role="special">&</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase><phrase role="special">&</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
|
|
<phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">typename</phrase> T<phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> N<phrase role="special">></phrase>
|
|
<phrase role="keyword">bool</phrase> <link linkend="boost.array.operato_id1"><phrase role="keyword">operator</phrase><phrase role="special"><</phrase></link><phrase role="special">(</phrase><phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase><phrase role="special">&</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase><phrase role="special">&</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
|
|
<phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">typename</phrase> T<phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> N<phrase role="special">></phrase>
|
|
<phrase role="keyword">bool</phrase> <link linkend="boost.array.operato_id2"><phrase role="keyword">operator</phrase><phrase role="special">></phrase></link><phrase role="special">(</phrase><phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase><phrase role="special">&</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase><phrase role="special">&</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
|
|
<phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">typename</phrase> T<phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> N<phrase role="special">></phrase>
|
|
<phrase role="keyword">bool</phrase> <link linkend="boost.array.operato_id3"><phrase role="keyword">operator</phrase><phrase role="special"><=</phrase></link><phrase role="special">(</phrase><phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase><phrase role="special">&</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase><phrase role="special">&</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
|
|
<phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">typename</phrase> T<phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> N<phrase role="special">></phrase>
|
|
<phrase role="keyword">bool</phrase> <link linkend="boost.array.operato_id4"><phrase role="keyword">operator</phrase><phrase role="special">>=</phrase></link><phrase role="special">(</phrase><phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase><phrase role="special">&</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase><phrase role="special">&</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase></synopsis></refsynopsisdiv><refsect1><title>Description</title><refsect2><title><anchor id="boost.arrayconstruct-copy-destruct"/><computeroutput>array</computeroutput>
|
|
public
|
|
construct/copy/destruct</title><orderedlist><listitem><para><literallayout class="monospaced"><phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">typename</phrase> U<phrase role="special">></phrase> array& <anchor id="id1-bb"/><phrase role="keyword">operator</phrase><phrase role="special">=</phrase><phrase role="special">(</phrase><phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special"><</phrase><phrase role="identifier">U</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase><phrase role="special">&</phrase> other<phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para><variablelist spacing="compact"><?dbhtml
|
|
list-presentation="table"
|
|
?><varlistentry><term>Effects:</term><listitem><simpara><computeroutput>std::copy(rhs.<link linkend="id3-bb">begin</link>(),rhs.<link linkend="id6-bb">end</link>(), <link linkend="id3-bb">begin</link>())</computeroutput></simpara></listitem></varlistentry></variablelist></listitem></orderedlist></refsect2><refsect2><title><anchor id="id2-bb"/><computeroutput>array</computeroutput> iterator support</title><orderedlist><listitem><para><literallayout class="monospaced"><anchor id="id3-bb"/><phrase role="identifier">iterator</phrase> <anchor id="id4-bb"/><phrase role="identifier">begin</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
|
|
<phrase role="identifier">const_iterator</phrase> <anchor id="id5-bb"/><phrase role="identifier">begin</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase></literallayout></para><variablelist spacing="compact"><?dbhtml
|
|
list-presentation="table"
|
|
?><varlistentry><term>Returns:</term><listitem><simpara>iterator for the first element</simpara></listitem></varlistentry><varlistentry><term>Throws:</term><listitem><simpara>will not throw</simpara></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><anchor id="id6-bb"/><phrase role="identifier">iterator</phrase> <anchor id="id7-bb"/><phrase role="identifier">end</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
|
|
<phrase role="identifier">const_iterator</phrase> <anchor id="id8-bb"/><phrase role="identifier">end</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase></literallayout></para><variablelist spacing="compact"><?dbhtml
|
|
list-presentation="table"
|
|
?><varlistentry><term>Returns:</term><listitem><simpara>iterator for position after the last element</simpara></listitem></varlistentry><varlistentry><term>Throws:</term><listitem><simpara>will not throw</simpara></listitem></varlistentry></variablelist></listitem></orderedlist></refsect2><refsect2><title><anchor id="id9-bb"/><computeroutput>array</computeroutput> reverse iterator support</title><orderedlist><listitem><para><literallayout class="monospaced"><anchor id="id10-bb"/><phrase role="identifier">reverse_iterator</phrase> <anchor id="id11-bb"/><phrase role="identifier">rbegin</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
|
|
<phrase role="identifier">const_reverse_iterator</phrase> <anchor id="id12-bb"/><phrase role="identifier">rbegin</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase></literallayout></para><variablelist spacing="compact"><?dbhtml
|
|
list-presentation="table"
|
|
?><varlistentry><term>Returns:</term><listitem><simpara>reverse iterator for the first element of reverse iteration</simpara></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><anchor id="id13-bb"/><phrase role="identifier">reverse_iterator</phrase> <anchor id="id14-bb"/><phrase role="identifier">rend</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
|
|
<phrase role="identifier">const_reverse_iterator</phrase> <anchor id="id15-bb"/><phrase role="identifier">rend</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase></literallayout></para><variablelist spacing="compact"><?dbhtml
|
|
list-presentation="table"
|
|
?><varlistentry><term>Returns:</term><listitem><simpara>reverse iterator for position after the last element in reverse iteration</simpara></listitem></varlistentry></variablelist></listitem></orderedlist></refsect2><refsect2><title><anchor id="id16-bb"/><computeroutput>array</computeroutput> capacity</title><orderedlist><listitem><para><literallayout class="monospaced"><phrase role="identifier">size_type</phrase> <anchor id="id17-bb"/><phrase role="identifier">size</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para><variablelist spacing="compact"><?dbhtml
|
|
list-presentation="table"
|
|
?><varlistentry><term>Returns:</term><listitem><simpara><computeroutput>N</computeroutput></simpara></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><phrase role="keyword">bool</phrase> <anchor id="id18-bb"/><phrase role="identifier">empty</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para><variablelist spacing="compact"><?dbhtml
|
|
list-presentation="table"
|
|
?><varlistentry><term>Returns:</term><listitem><simpara><computeroutput>N==0</computeroutput></simpara></listitem></varlistentry><varlistentry><term>Throws:</term><listitem><simpara>will not throw</simpara></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><phrase role="identifier">size_type</phrase> <anchor id="id19-bb"/><phrase role="identifier">max_size</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para><variablelist spacing="compact"><?dbhtml
|
|
list-presentation="table"
|
|
?><varlistentry><term>Returns:</term><listitem><simpara><computeroutput>N</computeroutput></simpara></listitem></varlistentry><varlistentry><term>Throws:</term><listitem><simpara>will not throw</simpara></listitem></varlistentry></variablelist></listitem></orderedlist></refsect2><refsect2><title><anchor id="id20-bb"/><computeroutput>array</computeroutput> element access</title><orderedlist><listitem><para><literallayout class="monospaced"><anchor id="id21-bb"/><phrase role="identifier">reference</phrase> <anchor id="id22-bb"/><phrase role="keyword">operator</phrase><phrase role="special">[</phrase><phrase role="special">]</phrase><phrase role="special">(</phrase><phrase role="identifier">size_type</phrase> i<phrase role="special">)</phrase><phrase role="special">;</phrase>
|
|
<phrase role="identifier">const_reference</phrase> <anchor id="id23-bb"/><phrase role="keyword">operator</phrase><phrase role="special">[</phrase><phrase role="special">]</phrase><phrase role="special">(</phrase><phrase role="identifier">size_type</phrase> i<phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase></literallayout></para><variablelist spacing="compact"><?dbhtml
|
|
list-presentation="table"
|
|
?><varlistentry><term>Requires:</term><listitem><simpara><computeroutput>i < N</computeroutput></simpara></listitem></varlistentry><varlistentry><term>Returns:</term><listitem><simpara>element with index <computeroutput>i</computeroutput></simpara></listitem></varlistentry><varlistentry><term>Throws:</term><listitem><simpara>will not throw.</simpara></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><anchor id="id24-bb"/><phrase role="identifier">reference</phrase> <anchor id="id25-bb"/><phrase role="identifier">at</phrase><phrase role="special">(</phrase><phrase role="identifier">size_type</phrase> i<phrase role="special">)</phrase><phrase role="special">;</phrase>
|
|
<phrase role="identifier">const_reference</phrase> <anchor id="id26-bb"/><phrase role="identifier">at</phrase><phrase role="special">(</phrase><phrase role="identifier">size_type</phrase> i<phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase></literallayout></para><variablelist spacing="compact"><?dbhtml
|
|
list-presentation="table"
|
|
?><varlistentry><term>Returns:</term><listitem><simpara>element with index <computeroutput>i</computeroutput></simpara></listitem></varlistentry><varlistentry><term>Throws:</term><listitem><simpara><computeroutput>std::range_error</computeroutput> if <computeroutput>i >= N</computeroutput></simpara></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><anchor id="id27-bb"/><phrase role="identifier">reference</phrase> <anchor id="id28-bb"/><phrase role="identifier">front</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
|
|
<phrase role="identifier">const_reference</phrase> <anchor id="id29-bb"/><phrase role="identifier">front</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase></literallayout></para><variablelist spacing="compact"><?dbhtml
|
|
list-presentation="table"
|
|
?><varlistentry><term>Requires:</term><listitem><simpara><computeroutput>N > 0</computeroutput></simpara></listitem></varlistentry><varlistentry><term>Returns:</term><listitem><simpara>the first element</simpara></listitem></varlistentry><varlistentry><term>Throws:</term><listitem><simpara>will not throw</simpara></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><anchor id="id30-bb"/><phrase role="identifier">reference</phrase> <anchor id="id31-bb"/><phrase role="identifier">back</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
|
|
<phrase role="identifier">const_reference</phrase> <anchor id="id32-bb"/><phrase role="identifier">back</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase></literallayout></para><variablelist spacing="compact"><?dbhtml
|
|
list-presentation="table"
|
|
?><varlistentry><term>Requires:</term><listitem><simpara><computeroutput>N > 0</computeroutput></simpara></listitem></varlistentry><varlistentry><term>Returns:</term><listitem><simpara>the last element</simpara></listitem></varlistentry><varlistentry><term>Throws:</term><listitem><simpara>will not throw</simpara></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><phrase role="keyword">const</phrase> <phrase role="identifier">T</phrase><phrase role="special">*</phrase> <anchor id="id33-bb"/><phrase role="identifier">data</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase></literallayout></para><variablelist spacing="compact"><?dbhtml
|
|
list-presentation="table"
|
|
?><varlistentry><term>Returns:</term><listitem><simpara><computeroutput>elems</computeroutput></simpara></listitem></varlistentry><varlistentry><term>Throws:</term><listitem><simpara>will not throw</simpara></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><phrase role="identifier">T</phrase><phrase role="special">*</phrase> <anchor id="id34-bb"/><phrase role="identifier">c_array</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para><variablelist spacing="compact"><?dbhtml
|
|
list-presentation="table"
|
|
?><varlistentry><term>Returns:</term><listitem><simpara><computeroutput>elems</computeroutput></simpara></listitem></varlistentry><varlistentry><term>Throws:</term><listitem><simpara>will not throw</simpara></listitem></varlistentry></variablelist></listitem></orderedlist></refsect2><refsect2><title><anchor id="id35-bb"/><computeroutput>array</computeroutput> modifiers</title><orderedlist><listitem><para><literallayout class="monospaced"><phrase role="keyword">void</phrase> <anchor id="id36-bb"/><phrase role="identifier">swap</phrase><phrase role="special">(</phrase><link linkend="boost.array">array</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase><phrase role="special">&</phrase> other<phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para><variablelist spacing="compact"><?dbhtml
|
|
list-presentation="table"
|
|
?><varlistentry><term>Effects:</term><listitem><simpara><computeroutput>std::swap_ranges(<link linkend="id3-bb">begin</link>(), <link linkend="id6-bb">end</link>(), other.<link linkend="id3-bb">begin</link>())</computeroutput></simpara></listitem></varlistentry><varlistentry><term>Complexity:</term><listitem><simpara>linear in <computeroutput>N</computeroutput></simpara></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><phrase role="keyword">void</phrase> <anchor id="id37-bb"/><phrase role="identifier">assign</phrase><phrase role="special">(</phrase><phrase role="keyword">const</phrase> <phrase role="identifier">T</phrase><phrase role="special">&</phrase> value<phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para><variablelist spacing="compact"><?dbhtml
|
|
list-presentation="table"
|
|
?><varlistentry><term>Effects:</term><listitem><simpara><computeroutput>std::fill_n(<link linkend="id3-bb">begin</link>(), N, value)</computeroutput></simpara></listitem></varlistentry></variablelist></listitem></orderedlist></refsect2><refsect2><title><anchor id="id38-bb"/><computeroutput>array</computeroutput> specialized algorithms</title><orderedlist><listitem><para><literallayout class="monospaced"><phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">typename</phrase> T<phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> N<phrase role="special">></phrase> <phrase role="keyword">void</phrase> <anchor id="boost.array.swap"/><phrase role="identifier">swap</phrase><phrase role="special">(</phrase><link linkend="boost.array">array</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase><phrase role="special">&</phrase> x<phrase role="special">,</phrase> <link linkend="boost.array">array</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase><phrase role="special">&</phrase> y<phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para><variablelist spacing="compact"><?dbhtml
|
|
list-presentation="table"
|
|
?><varlistentry><term>Effects:</term><listitem><simpara><computeroutput>x.<link linkend="id36-bb">swap</link>(y)</computeroutput></simpara></listitem></varlistentry><varlistentry><term>Throws:</term><listitem><simpara>will not throw.</simpara></listitem></varlistentry></variablelist></listitem></orderedlist></refsect2><refsect2><title><anchor id="id39-bb"/><computeroutput>array</computeroutput> comparisons</title><orderedlist><listitem><para><literallayout class="monospaced"><phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">typename</phrase> T<phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> N<phrase role="special">></phrase>
|
|
<phrase role="keyword">bool</phrase> <anchor id="boost.array.operator=="/><phrase role="keyword">operator</phrase><phrase role="special">==</phrase><phrase role="special">(</phrase><phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase><phrase role="special">&</phrase> x<phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase><phrase role="special">&</phrase> y<phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para><variablelist spacing="compact"><?dbhtml
|
|
list-presentation="table"
|
|
?><varlistentry><term>Returns:</term><listitem><simpara><computeroutput>std::equal(x.<link linkend="id3-bb">begin</link>(), x.<link linkend="id6-bb">end</link>(), y.<link linkend="id3-bb">begin</link>())</computeroutput></simpara></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">typename</phrase> T<phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> N<phrase role="special">></phrase>
|
|
<phrase role="keyword">bool</phrase> <anchor id="boost.array.operator!="/><phrase role="keyword">operator</phrase><phrase role="special">!=</phrase><phrase role="special">(</phrase><phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase><phrase role="special">&</phrase> x<phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase><phrase role="special">&</phrase> y<phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para><variablelist spacing="compact"><?dbhtml
|
|
list-presentation="table"
|
|
?><varlistentry><term>Returns:</term><listitem><simpara><computeroutput>!(x == y)</computeroutput></simpara></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">typename</phrase> T<phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> N<phrase role="special">></phrase>
|
|
<phrase role="keyword">bool</phrase> <anchor id="boost.array.operato_id1"/><phrase role="keyword">operator</phrase><phrase role="special"><</phrase><phrase role="special">(</phrase><phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase><phrase role="special">&</phrase> x<phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase><phrase role="special">&</phrase> y<phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para><variablelist spacing="compact"><?dbhtml
|
|
list-presentation="table"
|
|
?><varlistentry><term>Returns:</term><listitem><simpara><computeroutput>std::lexicographical_compare(x.<link linkend="id3-bb">begin</link>(), x.<link linkend="id6-bb">end</link>(), y.<link linkend="id3-bb">begin</link>(), y.<link linkend="id6-bb">end</link>())</computeroutput></simpara></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">typename</phrase> T<phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> N<phrase role="special">></phrase>
|
|
<phrase role="keyword">bool</phrase> <anchor id="boost.array.operato_id2"/><phrase role="keyword">operator</phrase><phrase role="special">></phrase><phrase role="special">(</phrase><phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase><phrase role="special">&</phrase> x<phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase><phrase role="special">&</phrase> y<phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para><variablelist spacing="compact"><?dbhtml
|
|
list-presentation="table"
|
|
?><varlistentry><term>Returns:</term><listitem><simpara><computeroutput>y < x</computeroutput></simpara></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">typename</phrase> T<phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> N<phrase role="special">></phrase>
|
|
<phrase role="keyword">bool</phrase> <anchor id="boost.array.operato_id3"/><phrase role="keyword">operator</phrase><phrase role="special"><=</phrase><phrase role="special">(</phrase><phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase><phrase role="special">&</phrase> x<phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase><phrase role="special">&</phrase> y<phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para><variablelist spacing="compact"><?dbhtml
|
|
list-presentation="table"
|
|
?><varlistentry><term>Returns:</term><listitem><simpara><computeroutput>!(y < x)</computeroutput></simpara></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">typename</phrase> T<phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> N<phrase role="special">></phrase>
|
|
<phrase role="keyword">bool</phrase> <anchor id="boost.array.operato_id4"/><phrase role="keyword">operator</phrase><phrase role="special">>=</phrase><phrase role="special">(</phrase><phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase><phrase role="special">&</phrase> x<phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase><phrase role="special">&</phrase> y<phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para><variablelist spacing="compact"><?dbhtml
|
|
list-presentation="table"
|
|
?><varlistentry><term>Returns:</term><listitem><simpara><computeroutput>!(x < y)</computeroutput></simpara></listitem></varlistentry></variablelist></listitem></orderedlist></refsect2></refsect1></refentry>
|
|
</section>
|
|
</section>
|
|
|
|
<section id="array.rationale">
|
|
<title>Design Rationale</title>
|
|
|
|
<para>There was an important design tradeoff regarding the
|
|
constructors: We could implement array as an "aggregate" (see
|
|
Section 8.5.1, [dcl.init.aggr], of the C++ Standard). This would
|
|
mean:
|
|
<itemizedlist>
|
|
<listitem><simpara>An array can be initialized with a
|
|
brace-enclosing, comma-separated list of initializers for the
|
|
elements of the container, written in increasing subscript
|
|
order:</simpara>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><computeroutput><link linkend="boost.array">boost::array</link></computeroutput><int,4> a = { { 1, 2, 3 } };</programlisting>
|
|
|
|
<simpara>Note that if there are fewer elements in the
|
|
initializer list, then each remaining element gets
|
|
default-initialized (thus, it has a defined value).</simpara>
|
|
</listitem></itemizedlist></para>
|
|
|
|
<para>However, this approach has its drawbacks: <emphasis role="bold"> passing no initializer list means that the elements
|
|
have an indetermined initial value</emphasis>, because the rule says
|
|
that aggregates may have:
|
|
<itemizedlist>
|
|
<listitem><simpara>No user-declared constructors.</simpara></listitem>
|
|
<listitem><simpara>No private or protected non-static data members.</simpara></listitem>
|
|
<listitem><simpara>No base classes.</simpara></listitem>
|
|
<listitem><simpara>No virtual functions.</simpara></listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
|
|
<para>Nevertheless, The current implementation uses this approach.</para>
|
|
|
|
<para>Note that for standard conforming compilers it is possible to
|
|
use fewer braces (according to 8.5.1 (11) of the Standard). That is,
|
|
you can initialize an array as follows:</para>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude">
|
|
<computeroutput><link linkend="boost.array">boost::array</link></computeroutput><int,4> a = { 1, 2, 3 };
|
|
</programlisting>
|
|
|
|
<para>I'd appreciate any constructive feedback. <emphasis role="bold">Please note: I don't have time to read all boost
|
|
mails. Thus, to make sure that feedback arrives to me, please send
|
|
me a copy of each mail regarding this class.</emphasis></para>
|
|
|
|
<para>The code is provided "as is" without expressed or implied
|
|
warranty.</para>
|
|
|
|
</section>
|
|
|
|
<section id="array.more.info">
|
|
<title>For more information...</title>
|
|
<para>To find more details about using ordinary arrays in C++ and
|
|
the framework of the STL, see e.g.
|
|
|
|
<literallayout>The C++ Standard Library - A Tutorial and Reference
|
|
by Nicolai M. Josuttis
|
|
Addison Wesley Longman, 1999
|
|
ISBN 0-201-37926-0</literallayout>
|
|
</para>
|
|
|
|
<para><ulink url="http://www.josuttis.com/">Home Page of Nicolai
|
|
Josuttis</ulink></para>
|
|
</section>
|
|
|
|
<section id="array.ack">
|
|
<title>Acknowledgements</title>
|
|
|
|
<para>Doug Gregor ported the documentation to the BoostBook format.</para>
|
|
</section>
|
|
|
|
|
|
|
|
</chapter> |