• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
2<chapter xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" id="array" rev:last-revision="$Date$">
3  <chapterinfo><author>
4      <firstname>Nicolai</firstname>
5      <surname>Josuttis</surname>
6    </author><copyright>
7      <year>2001</year>
8      <year>2002</year>
9      <year>2003</year>
10      <year>2004</year>
11      <holder>Nicolai M. Josuttis</holder>
12    </copyright><legalnotice>
13      <para>Distributed under the Boost Software License, Version 1.0.
14      (See accompanying file <filename>LICENSE_1_0.txt</filename> or copy at
15      <ulink url="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</ulink>)
16      </para>
17    </legalnotice></chapterinfo>
18
19  <title>Boost.Array</title>
20
21  <section id="array.intro">
22    <title>Introduction</title>
23
24
25
26
27    <para>The C++ Standard Template Library STL as part of the C++
28    Standard Library provides a framework for processing algorithms on
29    different kind of containers. However, ordinary arrays don't
30    provide the interface of STL containers (although, they provide
31    the iterator interface of STL containers).</para>
32
33    <para>As replacement for ordinary arrays, the STL provides class
34    <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude">std::vector</computeroutput>.  However,
35    <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude">std::vector&lt;&gt;</computeroutput> provides
36    the semantics of dynamic arrays. Thus, it manages data to be able
37    to change the number of elements. This results in some overhead in
38    case only arrays with static size are needed.</para>
39
40    <para>In his book, <emphasis>Generic Programming and the
41    STL</emphasis>, Matthew H. Austern introduces a useful wrapper
42    class for ordinary arrays with static size, called
43    <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude">block</computeroutput>.  It is safer and has no worse performance than
44    ordinary arrays. In <emphasis>The C++ Programming
45    Language</emphasis>, 3rd edition, Bjarne Stroustrup introduces a
46    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
47    slightly modified in my book <emphasis>The C++ Standard Library -
48    A Tutorial and Reference</emphasis>, called
49    <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude">carray</computeroutput>. This is the essence of these approaches
50    spiced with many feedback from <ulink url="http://www.boost.org">boost</ulink>.</para>
51
52    <para>After considering different names, we decided to name this
53    class simply <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.array">array</link></computeroutput>.</para>
54
55    <para>Note that this class is suggested to be part of the next
56    Technical Report, which will extend the C++ Standard (see
57    <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>
58
59    <para>Class <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost.array">array</link></computeroutput> fulfills most
60    but not all of the requirements of "reversible containers" (see
61    Section 23.1, [lib.container.requirements] of the C++
62    Standard). The reasons array is not an reversible STL container is
63    because:
64      <itemizedlist spacing="compact">
65        <listitem><simpara>No constructors are provided.</simpara></listitem>
66        <listitem><simpara>Elements may have an undetermined initial value (see <xref linkend="array.rationale"/>).</simpara></listitem>
67        <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>
68        <listitem><simpara><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="id-1_4_1_1_1_16_1-bb">size</link></computeroutput>() is always constant, based on the second template argument of the type.</simpara></listitem>
69        <listitem><simpara>The container provides no allocator support.</simpara></listitem>
70      </itemizedlist>
71    </para>
72
73    <para>It doesn't fulfill the requirements of a "sequence" (see Section 23.1.1, [lib.sequence.reqmts] of the C++ Standard), except that:
74      <itemizedlist spacing="compact">
75        <listitem><simpara><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="id-1_4_1_1_1_17_3-bb">front</link></computeroutput>() and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="id-1_4_1_1_1_17_4-bb">back</link></computeroutput>() are provided.</simpara></listitem>
76        <listitem><simpara><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="id-1_4_1_1_1_17_1-bb">operator[]</link></computeroutput> and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="id-1_4_1_1_1_17_2-bb">at</link></computeroutput>() are provided.</simpara></listitem>
77      </itemizedlist>
78    </para>
79  </section>
80
81  <section id="array.reference"><title>Reference</title>
82    <section id="header.boost.array_hpp"><title>Header &lt;<ulink url="../../boost/array.hpp">boost/array.hpp</ulink>&gt;</title><synopsis xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase>
83  <phrase role="keyword">template</phrase><phrase role="special">&lt;</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">&gt;</phrase> <phrase role="keyword">class</phrase> <link linkend="boost.array">array</link><phrase role="special">;</phrase>
84  <phrase role="keyword">template</phrase><phrase role="special">&lt;</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">&gt;</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">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">&gt;</phrase><phrase role="special">&amp;</phrase><phrase role="special">,</phrase> <link linkend="boost.array">array</link><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">&gt;</phrase><phrase role="special">&amp;</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
85  <phrase role="keyword">template</phrase><phrase role="special">&lt;</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">&gt;</phrase>
86    <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">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">&gt;</phrase><phrase role="special">&amp;</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">&gt;</phrase><phrase role="special">&amp;</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
87  <phrase role="keyword">template</phrase><phrase role="special">&lt;</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">&gt;</phrase>
88    <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">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">&gt;</phrase><phrase role="special">&amp;</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">&gt;</phrase><phrase role="special">&amp;</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
89  <phrase role="keyword">template</phrase><phrase role="special">&lt;</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">&gt;</phrase>
90    <phrase role="keyword">bool</phrase> <link linkend="boost.array.operator_1_4_1_1_1_21_3"><phrase role="keyword">operator</phrase><phrase role="special">&lt;</phrase></link><phrase role="special">(</phrase><phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">&gt;</phrase><phrase role="special">&amp;</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">&gt;</phrase><phrase role="special">&amp;</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
91  <phrase role="keyword">template</phrase><phrase role="special">&lt;</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">&gt;</phrase>
92    <phrase role="keyword">bool</phrase> <link linkend="boost.array.operator_1_4_1_1_1_21_4"><phrase role="keyword">operator</phrase><phrase role="special">&gt;</phrase></link><phrase role="special">(</phrase><phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">&gt;</phrase><phrase role="special">&amp;</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">&gt;</phrase><phrase role="special">&amp;</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
93  <phrase role="keyword">template</phrase><phrase role="special">&lt;</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">&gt;</phrase>
94    <phrase role="keyword">bool</phrase> <link linkend="boost.array.operator_=_1_4_1_1_1_21_5"><phrase role="keyword">operator</phrase><phrase role="special">&lt;=</phrase></link><phrase role="special">(</phrase><phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">&gt;</phrase><phrase role="special">&amp;</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">&gt;</phrase><phrase role="special">&amp;</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
95  <phrase role="keyword">template</phrase><phrase role="special">&lt;</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">&gt;</phrase>
96    <phrase role="keyword">bool</phrase> <link linkend="boost.array.operator_=_1_4_1_1_1_21_6"><phrase role="keyword">operator</phrase><phrase role="special">&gt;=</phrase></link><phrase role="special">(</phrase><phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">&gt;</phrase><phrase role="special">&amp;</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">&gt;</phrase><phrase role="special">&amp;</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
97<phrase role="special">}</phrase></synopsis>
98      <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: &lt;<link linkend="header.boost.array_hpp">boost/array.hpp</link>&gt;
99
100</phrase><phrase role="keyword">template</phrase><phrase role="special">&lt;</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">&gt;</phrase>
101<phrase role="keyword">class</phrase> <link linkend="boost.array">array</link> <phrase role="special">{</phrase>
102<phrase role="keyword">public</phrase><phrase role="special">:</phrase>
103  <phrase role="comment">// types</phrase>
104  <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>
105  <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>
106  <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>
107  <phrase role="keyword">typedef</phrase> std::reverse_iterator<phrase role="special">&lt;</phrase><phrase role="identifier">iterator</phrase><phrase role="special">&gt;</phrase>       <anchor id="boost.array.reverse_iterator"/><phrase role="identifier">reverse_iterator</phrase><phrase role="special">;</phrase>
108  <phrase role="keyword">typedef</phrase> std::reverse_iterator<phrase role="special">&lt;</phrase><phrase role="identifier">const_iterator</phrase><phrase role="special">&gt;</phrase> <anchor id="boost.array.const_reverse_iterator"/><phrase role="identifier">const_reverse_iterator</phrase><phrase role="special">;</phrase>
109  <phrase role="keyword">typedef</phrase> <phrase role="identifier">T</phrase><phrase role="special">&amp;</phrase>                                    <anchor id="boost.array.reference"/><phrase role="identifier">reference</phrase><phrase role="special">;</phrase>
110  <phrase role="keyword">typedef</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">T</phrase><phrase role="special">&amp;</phrase>                              <anchor id="boost.array.const_reference"/><phrase role="identifier">const_reference</phrase><phrase role="special">;</phrase>
111  <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>
112  <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>
113
114  <phrase role="comment">// static constants</phrase>
115  <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>
116
117  <phrase role="comment">// <link linkend="boost.arrayconstruct-copy-destruct">construct/copy/destruct</link></phrase>
118  <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> U<phrase role="special">&gt;</phrase> array&amp; <link linkend="id-1_4_1_1_1_13-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">&lt;</phrase><phrase role="identifier">U</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">&gt;</phrase><phrase role="special">&amp;</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
119
120  <phrase role="comment">// <link linkend="id-1_4_1_1_1_14-bb">iterator support</link></phrase>
121  <phrase role="identifier">iterator</phrase> <link linkend="id-1_4_1_1_1_14_1_1-bb"><phrase role="identifier">begin</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
122  <phrase role="identifier">const_iterator</phrase> <link linkend="id-1_4_1_1_1_14_1_2-bb"><phrase role="identifier">begin</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
123  <phrase role="identifier">iterator</phrase> <link linkend="id-1_4_1_1_1_14_2_1-bb"><phrase role="identifier">end</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
124  <phrase role="identifier">const_iterator</phrase> <link linkend="id-1_4_1_1_1_14_2_2-bb"><phrase role="identifier">end</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
125
126  <phrase role="comment">// <link linkend="id-1_4_1_1_1_15-bb">reverse iterator support</link></phrase>
127  <phrase role="identifier">reverse_iterator</phrase> <link linkend="id-1_4_1_1_1_15_1_1-bb"><phrase role="identifier">rbegin</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
128  <phrase role="identifier">const_reverse_iterator</phrase> <link linkend="id-1_4_1_1_1_15_1_2-bb"><phrase role="identifier">rbegin</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
129  <phrase role="identifier">reverse_iterator</phrase> <link linkend="id-1_4_1_1_1_15_2_1-bb"><phrase role="identifier">rend</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
130  <phrase role="identifier">const_reverse_iterator</phrase> <link linkend="id-1_4_1_1_1_15_2_2-bb"><phrase role="identifier">rend</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
131
132  <phrase role="comment">// <link linkend="id-1_4_1_1_1_16-bb">capacity</link></phrase>
133  <phrase role="identifier">size_type</phrase> <link linkend="id-1_4_1_1_1_16_1-bb"><phrase role="identifier">size</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
134  <phrase role="keyword">bool</phrase> <link linkend="id-1_4_1_1_1_16_2-bb"><phrase role="identifier">empty</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
135  <phrase role="identifier">size_type</phrase> <link linkend="id-1_4_1_1_1_16_3-bb"><phrase role="identifier">max_size</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
136
137  <phrase role="comment">// <link linkend="id-1_4_1_1_1_17-bb">element access</link></phrase>
138  <phrase role="identifier">reference</phrase> <link linkend="id-1_4_1_1_1_17_1_1-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>
139  <phrase role="identifier">const_reference</phrase> <link linkend="id-1_4_1_1_1_17_1_2-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>
140  <phrase role="identifier">reference</phrase> <link linkend="id-1_4_1_1_1_17_2_1-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>
141  <phrase role="identifier">const_reference</phrase> <link linkend="id-1_4_1_1_1_17_2_2-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>
142  <phrase role="identifier">reference</phrase> <link linkend="id-1_4_1_1_1_17_3_1-bb"><phrase role="identifier">front</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
143  <phrase role="identifier">const_reference</phrase> <link linkend="id-1_4_1_1_1_17_3_2-bb"><phrase role="identifier">front</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
144  <phrase role="identifier">reference</phrase> <link linkend="id-1_4_1_1_1_17_4_1-bb"><phrase role="identifier">back</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
145  <phrase role="identifier">const_reference</phrase> <link linkend="id-1_4_1_1_1_17_4_2-bb"><phrase role="identifier">back</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
146  <phrase role="keyword">const</phrase> <phrase role="identifier">T</phrase><phrase role="special">*</phrase> <link linkend="id-1_4_1_1_1_17_5-bb"><phrase role="identifier">data</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
147  <phrase role="identifier">T</phrase><phrase role="special">*</phrase> <link linkend="id-1_4_1_1_1_17_6-bb"><phrase role="identifier">c_array</phrase></link><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
148
149  <phrase role="comment">// <link linkend="id-1_4_1_1_1_18-bb">modifiers</link></phrase>
150  <phrase role="keyword">void</phrase> <link linkend="id-1_4_1_1_1_18_1-bb"><phrase role="identifier">swap</phrase></link><phrase role="special">(</phrase><link linkend="boost.array">array</link><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">&gt;</phrase><phrase role="special">&amp;</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
151  <phrase role="keyword">void</phrase> <link linkend="id-1_4_1_1_1_18_2-bb"><phrase role="identifier">assign</phrase></link><phrase role="special">(</phrase><phrase role="keyword">const</phrase> <phrase role="identifier">T</phrase><phrase role="special">&amp;</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
152
153  <phrase role="comment">// public data members</phrase>
154  <phrase role="identifier">T</phrase> <phrase role="identifier">elems[N]</phrase><phrase role="special">;</phrase>
155<phrase role="special">}</phrase><phrase role="special">;</phrase>
156
157<phrase role="comment">// <link linkend="id-1_4_1_1_1_20-bb">specialized algorithms</link></phrase>
158<phrase role="keyword">template</phrase><phrase role="special">&lt;</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">&gt;</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">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">&gt;</phrase><phrase role="special">&amp;</phrase><phrase role="special">,</phrase> <link linkend="boost.array">array</link><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">&gt;</phrase><phrase role="special">&amp;</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
159
160<phrase role="comment">// <link linkend="id-1_4_1_1_1_21-bb">comparisons</link></phrase>
161<phrase role="keyword">template</phrase><phrase role="special">&lt;</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">&gt;</phrase>
162  <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">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">&gt;</phrase><phrase role="special">&amp;</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">&gt;</phrase><phrase role="special">&amp;</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
163<phrase role="keyword">template</phrase><phrase role="special">&lt;</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">&gt;</phrase>
164  <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">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">&gt;</phrase><phrase role="special">&amp;</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">&gt;</phrase><phrase role="special">&amp;</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
165<phrase role="keyword">template</phrase><phrase role="special">&lt;</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">&gt;</phrase>
166  <phrase role="keyword">bool</phrase> <link linkend="boost.array.operator_1_4_1_1_1_21_3"><phrase role="keyword">operator</phrase><phrase role="special">&lt;</phrase></link><phrase role="special">(</phrase><phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">&gt;</phrase><phrase role="special">&amp;</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">&gt;</phrase><phrase role="special">&amp;</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
167<phrase role="keyword">template</phrase><phrase role="special">&lt;</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">&gt;</phrase>
168  <phrase role="keyword">bool</phrase> <link linkend="boost.array.operator_1_4_1_1_1_21_4"><phrase role="keyword">operator</phrase><phrase role="special">&gt;</phrase></link><phrase role="special">(</phrase><phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">&gt;</phrase><phrase role="special">&amp;</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">&gt;</phrase><phrase role="special">&amp;</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
169<phrase role="keyword">template</phrase><phrase role="special">&lt;</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">&gt;</phrase>
170  <phrase role="keyword">bool</phrase> <link linkend="boost.array.operator_=_1_4_1_1_1_21_5"><phrase role="keyword">operator</phrase><phrase role="special">&lt;=</phrase></link><phrase role="special">(</phrase><phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">&gt;</phrase><phrase role="special">&amp;</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">&gt;</phrase><phrase role="special">&amp;</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
171<phrase role="keyword">template</phrase><phrase role="special">&lt;</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">&gt;</phrase>
172  <phrase role="keyword">bool</phrase> <link linkend="boost.array.operator_=_1_4_1_1_1_21_6"><phrase role="keyword">operator</phrase><phrase role="special">&gt;=</phrase></link><phrase role="special">(</phrase><phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">&gt;</phrase><phrase role="special">&amp;</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">&gt;</phrase><phrase role="special">&amp;</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>
173        public
174       construct/copy/destruct</title><orderedlist><listitem><para><literallayout class="monospaced"><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">typename</phrase> U<phrase role="special">&gt;</phrase> array&amp; <anchor id="id-1_4_1_1_1_13-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">&lt;</phrase><phrase role="identifier">U</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">&gt;</phrase><phrase role="special">&amp;</phrase> other<phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para><variablelist spacing="compact"><?dbhtml
175          list-presentation="table"
176        ?><varlistentry><term>Effects:</term><listitem><simpara><computeroutput>std::copy(rhs.<link linkend="id-1_4_1_1_1_14_1-bb">begin</link>(),rhs.<link linkend="id-1_4_1_1_1_14_2-bb">end</link>(), <link linkend="id-1_4_1_1_1_14_1-bb">begin</link>())</computeroutput></simpara></listitem></varlistentry></variablelist></listitem></orderedlist></refsect2><refsect2><title><anchor id="id-1_4_1_1_1_14-bb"/><computeroutput>array</computeroutput> iterator support</title><orderedlist><listitem><para><literallayout class="monospaced"><anchor id="id-1_4_1_1_1_14_1-bb"/><phrase role="identifier">iterator</phrase> <anchor id="id-1_4_1_1_1_14_1_1-bb"/><phrase role="identifier">begin</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
177<phrase role="identifier">const_iterator</phrase> <anchor id="id-1_4_1_1_1_14_1_2-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
178          list-presentation="table"
179        ?><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="id-1_4_1_1_1_14_2-bb"/><phrase role="identifier">iterator</phrase> <anchor id="id-1_4_1_1_1_14_2_1-bb"/><phrase role="identifier">end</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
180<phrase role="identifier">const_iterator</phrase> <anchor id="id-1_4_1_1_1_14_2_2-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
181          list-presentation="table"
182        ?><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="id-1_4_1_1_1_15-bb"/><computeroutput>array</computeroutput> reverse iterator support</title><orderedlist><listitem><para><literallayout class="monospaced"><anchor id="id-1_4_1_1_1_15_1-bb"/><phrase role="identifier">reverse_iterator</phrase> <anchor id="id-1_4_1_1_1_15_1_1-bb"/><phrase role="identifier">rbegin</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
183<phrase role="identifier">const_reverse_iterator</phrase> <anchor id="id-1_4_1_1_1_15_1_2-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
184          list-presentation="table"
185        ?><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="id-1_4_1_1_1_15_2-bb"/><phrase role="identifier">reverse_iterator</phrase> <anchor id="id-1_4_1_1_1_15_2_1-bb"/><phrase role="identifier">rend</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
186<phrase role="identifier">const_reverse_iterator</phrase> <anchor id="id-1_4_1_1_1_15_2_2-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
187          list-presentation="table"
188        ?><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="id-1_4_1_1_1_16-bb"/><computeroutput>array</computeroutput> capacity</title><orderedlist><listitem><para><literallayout class="monospaced"><phrase role="identifier">size_type</phrase> <anchor id="id-1_4_1_1_1_16_1-bb"/><phrase role="identifier">size</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para><variablelist spacing="compact"><?dbhtml
189          list-presentation="table"
190        ?><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="id-1_4_1_1_1_16_2-bb"/><phrase role="identifier">empty</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para><variablelist spacing="compact"><?dbhtml
191          list-presentation="table"
192        ?><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="id-1_4_1_1_1_16_3-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
193          list-presentation="table"
194        ?><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="id-1_4_1_1_1_17-bb"/><computeroutput>array</computeroutput> element access</title><orderedlist><listitem><para><literallayout class="monospaced"><anchor id="id-1_4_1_1_1_17_1-bb"/><phrase role="identifier">reference</phrase> <anchor id="id-1_4_1_1_1_17_1_1-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>
195<phrase role="identifier">const_reference</phrase> <anchor id="id-1_4_1_1_1_17_1_2-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
196          list-presentation="table"
197        ?><varlistentry><term>Requires:</term><listitem><simpara><computeroutput>i &lt; 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="id-1_4_1_1_1_17_2-bb"/><phrase role="identifier">reference</phrase> <anchor id="id-1_4_1_1_1_17_2_1-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>
198<phrase role="identifier">const_reference</phrase> <anchor id="id-1_4_1_1_1_17_2_2-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
199          list-presentation="table"
200        ?><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 &gt;= N</computeroutput></simpara></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><anchor id="id-1_4_1_1_1_17_3-bb"/><phrase role="identifier">reference</phrase> <anchor id="id-1_4_1_1_1_17_3_1-bb"/><phrase role="identifier">front</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
201<phrase role="identifier">const_reference</phrase> <anchor id="id-1_4_1_1_1_17_3_2-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
202          list-presentation="table"
203        ?><varlistentry><term>Requires:</term><listitem><simpara><computeroutput>N &gt; 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="id-1_4_1_1_1_17_4-bb"/><phrase role="identifier">reference</phrase> <anchor id="id-1_4_1_1_1_17_4_1-bb"/><phrase role="identifier">back</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase><phrase role="special">;</phrase>
204<phrase role="identifier">const_reference</phrase> <anchor id="id-1_4_1_1_1_17_4_2-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
205          list-presentation="table"
206        ?><varlistentry><term>Requires:</term><listitem><simpara><computeroutput>N &gt; 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="id-1_4_1_1_1_17_5-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
207          list-presentation="table"
208        ?><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="id-1_4_1_1_1_17_6-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
209          list-presentation="table"
210        ?><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="id-1_4_1_1_1_18-bb"/><computeroutput>array</computeroutput> modifiers</title><orderedlist><listitem><para><literallayout class="monospaced"><phrase role="keyword">void</phrase> <anchor id="id-1_4_1_1_1_18_1-bb"/><phrase role="identifier">swap</phrase><phrase role="special">(</phrase><link linkend="boost.array">array</link><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">&gt;</phrase><phrase role="special">&amp;</phrase> other<phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para><variablelist spacing="compact"><?dbhtml
211          list-presentation="table"
212        ?><varlistentry><term>Effects:</term><listitem><simpara><computeroutput>std::swap_ranges(<link linkend="id-1_4_1_1_1_14_1-bb">begin</link>(), <link linkend="id-1_4_1_1_1_14_2-bb">end</link>(), other.<link linkend="id-1_4_1_1_1_14_1-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="id-1_4_1_1_1_18_2-bb"/><phrase role="identifier">assign</phrase><phrase role="special">(</phrase><phrase role="keyword">const</phrase> <phrase role="identifier">T</phrase><phrase role="special">&amp;</phrase> value<phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para><variablelist spacing="compact"><?dbhtml
213          list-presentation="table"
214        ?><varlistentry><term>Effects:</term><listitem><simpara><computeroutput>std::fill_n(<link linkend="id-1_4_1_1_1_14_1-bb">begin</link>(), N, value)</computeroutput></simpara></listitem></varlistentry></variablelist></listitem></orderedlist></refsect2><refsect2><title><anchor id="id-1_4_1_1_1_20-bb"/><computeroutput>array</computeroutput> specialized algorithms</title><orderedlist><listitem><para><literallayout class="monospaced"><phrase role="keyword">template</phrase><phrase role="special">&lt;</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">&gt;</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">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">&gt;</phrase><phrase role="special">&amp;</phrase> x<phrase role="special">,</phrase> <link linkend="boost.array">array</link><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">&gt;</phrase><phrase role="special">&amp;</phrase> y<phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para><variablelist spacing="compact"><?dbhtml
215          list-presentation="table"
216        ?><varlistentry><term>Effects:</term><listitem><simpara><computeroutput>x.<link linkend="id-1_4_1_1_1_18_1-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="id-1_4_1_1_1_21-bb"/><computeroutput>array</computeroutput> comparisons</title><orderedlist><listitem><para><literallayout class="monospaced"><phrase role="keyword">template</phrase><phrase role="special">&lt;</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">&gt;</phrase>
217  <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">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">&gt;</phrase><phrase role="special">&amp;</phrase> x<phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">&gt;</phrase><phrase role="special">&amp;</phrase> y<phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para><variablelist spacing="compact"><?dbhtml
218          list-presentation="table"
219        ?><varlistentry><term>Returns:</term><listitem><simpara><computeroutput>std::equal(x.<link linkend="id-1_4_1_1_1_14_1-bb">begin</link>(), x.<link linkend="id-1_4_1_1_1_14_2-bb">end</link>(), y.<link linkend="id-1_4_1_1_1_14_1-bb">begin</link>())</computeroutput></simpara></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><phrase role="keyword">template</phrase><phrase role="special">&lt;</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">&gt;</phrase>
220  <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">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">&gt;</phrase><phrase role="special">&amp;</phrase> x<phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">&gt;</phrase><phrase role="special">&amp;</phrase> y<phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para><variablelist spacing="compact"><?dbhtml
221          list-presentation="table"
222        ?><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">&lt;</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">&gt;</phrase>
223  <phrase role="keyword">bool</phrase> <anchor id="boost.array.operator_1_4_1_1_1_21_3"/><phrase role="keyword">operator</phrase><phrase role="special">&lt;</phrase><phrase role="special">(</phrase><phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">&gt;</phrase><phrase role="special">&amp;</phrase> x<phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">&gt;</phrase><phrase role="special">&amp;</phrase> y<phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para><variablelist spacing="compact"><?dbhtml
224          list-presentation="table"
225        ?><varlistentry><term>Returns:</term><listitem><simpara><computeroutput>std::lexicographical_compare(x.<link linkend="id-1_4_1_1_1_14_1-bb">begin</link>(), x.<link linkend="id-1_4_1_1_1_14_2-bb">end</link>(), y.<link linkend="id-1_4_1_1_1_14_1-bb">begin</link>(), y.<link linkend="id-1_4_1_1_1_14_2-bb">end</link>())</computeroutput></simpara></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><phrase role="keyword">template</phrase><phrase role="special">&lt;</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">&gt;</phrase>
226  <phrase role="keyword">bool</phrase> <anchor id="boost.array.operator_1_4_1_1_1_21_4"/><phrase role="keyword">operator</phrase><phrase role="special">&gt;</phrase><phrase role="special">(</phrase><phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">&gt;</phrase><phrase role="special">&amp;</phrase> x<phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">&gt;</phrase><phrase role="special">&amp;</phrase> y<phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para><variablelist spacing="compact"><?dbhtml
227          list-presentation="table"
228        ?><varlistentry><term>Returns:</term><listitem><simpara><computeroutput>y &lt; x</computeroutput></simpara></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><phrase role="keyword">template</phrase><phrase role="special">&lt;</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">&gt;</phrase>
229  <phrase role="keyword">bool</phrase> <anchor id="boost.array.operator_=_1_4_1_1_1_21_5"/><phrase role="keyword">operator</phrase><phrase role="special">&lt;=</phrase><phrase role="special">(</phrase><phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">&gt;</phrase><phrase role="special">&amp;</phrase> x<phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">&gt;</phrase><phrase role="special">&amp;</phrase> y<phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para><variablelist spacing="compact"><?dbhtml
230          list-presentation="table"
231        ?><varlistentry><term>Returns:</term><listitem><simpara><computeroutput>!(y &lt; x)</computeroutput></simpara></listitem></varlistentry></variablelist></listitem><listitem><para><literallayout class="monospaced"><phrase role="keyword">template</phrase><phrase role="special">&lt;</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">&gt;</phrase>
232  <phrase role="keyword">bool</phrase> <anchor id="boost.array.operator_=_1_4_1_1_1_21_6"/><phrase role="keyword">operator</phrase><phrase role="special">&gt;=</phrase><phrase role="special">(</phrase><phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">&gt;</phrase><phrase role="special">&amp;</phrase> x<phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <link linkend="boost.array">array</link><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">N</phrase><phrase role="special">&gt;</phrase><phrase role="special">&amp;</phrase> y<phrase role="special">)</phrase><phrase role="special">;</phrase></literallayout></para><variablelist spacing="compact"><?dbhtml
233          list-presentation="table"
234        ?><varlistentry><term>Returns:</term><listitem><simpara><computeroutput>!(x &lt; y)</computeroutput></simpara></listitem></varlistentry></variablelist></listitem></orderedlist></refsect2></refsect1></refentry>
235    </section>
236  </section>
237
238<section id="array.rationale">
239  <title>Design Rationale</title>
240
241  <para>There was an important design tradeoff regarding the
242  constructors: We could implement array as an "aggregate" (see
243  Section 8.5.1, [dcl.init.aggr], of the C++ Standard). This would
244  mean:
245    <itemizedlist>
246      <listitem><simpara>An array can be initialized with a
247      brace-enclosing, comma-separated list of initializers for the
248      elements of the container, written in increasing subscript
249      order:</simpara>
250
251      <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><computeroutput><link linkend="boost.array">boost::array</link></computeroutput>&lt;int,4&gt; a = { { 1, 2, 3 } };</programlisting>
252
253      <simpara>Note that if there are fewer elements in the
254      initializer list, then each remaining element gets
255      default-initialized (thus, it has a defined value).</simpara>
256  </listitem></itemizedlist></para>
257
258  <para>However, this approach has its drawbacks: <emphasis role="bold"> passing no initializer list means that the elements
259  have an indetermined initial value</emphasis>, because the rule says
260  that aggregates may have:
261    <itemizedlist>
262      <listitem><simpara>No user-declared constructors.</simpara></listitem>
263      <listitem><simpara>No private or protected non-static data members.</simpara></listitem>
264      <listitem><simpara>No base classes.</simpara></listitem>
265      <listitem><simpara>No virtual functions.</simpara></listitem>
266    </itemizedlist>
267  </para>
268
269  <para>Nevertheless, The current implementation uses this approach.</para>
270
271  <para>Note that for standard conforming compilers it is possible to
272  use fewer braces (according to 8.5.1 (11) of the Standard). That is,
273  you can initialize an array as follows:</para>
274
275<programlisting xmlns:xi="http://www.w3.org/2001/XInclude">
276<computeroutput><link linkend="boost.array">boost::array</link></computeroutput>&lt;int,4&gt; a = { 1, 2, 3 };
277</programlisting>
278
279  <para>I'd appreciate any constructive feedback. <emphasis role="bold">Please note: I don't have time to read all boost
280  mails. Thus, to make sure that feedback arrives to me, please send
281  me a copy of each mail regarding this class.</emphasis></para>
282
283  <para>The code is provided "as is" without expressed or implied
284  warranty.</para>
285
286</section>
287
288<section id="array.more.info">
289  <title>For more information...</title>
290  <para>To find more details about using ordinary arrays in C++ and
291  the framework of the STL, see e.g.
292
293    <literallayout>The C++ Standard Library - A Tutorial and Reference
294by Nicolai M. Josuttis
295Addison Wesley Longman, 1999
296ISBN 0-201-37926-0</literallayout>
297   </para>
298
299  <para><ulink url="http://www.josuttis.com/">Home Page of Nicolai
300  Josuttis</ulink></para>
301</section>
302
303<section id="array.ack">
304  <title>Acknowledgements</title>
305
306  <para>Doug Gregor ported the documentation to the BoostBook format.</para>
307</section>
308
309
310
311</chapter>