Squashed 'third_party/boostorg/array/' content from commit 8f3aea2
Change-Id: If00bd8d3b291b4e3c61e8fec0ff84ac07078db5e
git-subtree-dir: third_party/boostorg/array
git-subtree-split: 8f3aea2200fa45ed4c1829b3d3148432867dda87
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..3e84d7c
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,96 @@
+* text=auto !eol svneol=native#text/plain
+*.gitattributes text svneol=native#text/plain
+
+# Scriptish formats
+*.bat text svneol=native#text/plain
+*.bsh text svneol=native#text/x-beanshell
+*.cgi text svneol=native#text/plain
+*.cmd text svneol=native#text/plain
+*.js text svneol=native#text/javascript
+*.php text svneol=native#text/x-php
+*.pl text svneol=native#text/x-perl
+*.pm text svneol=native#text/x-perl
+*.py text svneol=native#text/x-python
+*.sh eol=lf svneol=LF#text/x-sh
+configure eol=lf svneol=LF#text/x-sh
+
+# Image formats
+*.bmp binary svneol=unset#image/bmp
+*.gif binary svneol=unset#image/gif
+*.ico binary svneol=unset#image/ico
+*.jpeg binary svneol=unset#image/jpeg
+*.jpg binary svneol=unset#image/jpeg
+*.png binary svneol=unset#image/png
+*.tif binary svneol=unset#image/tiff
+*.tiff binary svneol=unset#image/tiff
+*.svg text svneol=native#image/svg%2Bxml
+
+# Data formats
+*.pdf binary svneol=unset#application/pdf
+*.avi binary svneol=unset#video/avi
+*.doc binary svneol=unset#application/msword
+*.dsp text svneol=crlf#text/plain
+*.dsw text svneol=crlf#text/plain
+*.eps binary svneol=unset#application/postscript
+*.gz binary svneol=unset#application/gzip
+*.mov binary svneol=unset#video/quicktime
+*.mp3 binary svneol=unset#audio/mpeg
+*.ppt binary svneol=unset#application/vnd.ms-powerpoint
+*.ps binary svneol=unset#application/postscript
+*.psd binary svneol=unset#application/photoshop
+*.rdf binary svneol=unset#text/rdf
+*.rss text svneol=unset#text/xml
+*.rtf binary svneol=unset#text/rtf
+*.sln text svneol=native#text/plain
+*.swf binary svneol=unset#application/x-shockwave-flash
+*.tgz binary svneol=unset#application/gzip
+*.vcproj text svneol=native#text/xml
+*.vcxproj text svneol=native#text/xml
+*.vsprops text svneol=native#text/xml
+*.wav binary svneol=unset#audio/wav
+*.xls binary svneol=unset#application/vnd.ms-excel
+*.zip binary svneol=unset#application/zip
+
+# Text formats
+.htaccess text svneol=native#text/plain
+*.bbk text svneol=native#text/xml
+*.cmake text svneol=native#text/plain
+*.css text svneol=native#text/css
+*.dtd text svneol=native#text/xml
+*.htm text svneol=native#text/html
+*.html text svneol=native#text/html
+*.ini text svneol=native#text/plain
+*.log text svneol=native#text/plain
+*.mak text svneol=native#text/plain
+*.qbk text svneol=native#text/plain
+*.rst text svneol=native#text/plain
+*.sql text svneol=native#text/x-sql
+*.txt text svneol=native#text/plain
+*.xhtml text svneol=native#text/xhtml%2Bxml
+*.xml text svneol=native#text/xml
+*.xsd text svneol=native#text/xml
+*.xsl text svneol=native#text/xml
+*.xslt text svneol=native#text/xml
+*.xul text svneol=native#text/xul
+*.yml text svneol=native#text/plain
+boost-no-inspect text svneol=native#text/plain
+CHANGES text svneol=native#text/plain
+COPYING text svneol=native#text/plain
+INSTALL text svneol=native#text/plain
+Jamfile text svneol=native#text/plain
+Jamroot text svneol=native#text/plain
+Jamfile.v2 text svneol=native#text/plain
+Jamrules text svneol=native#text/plain
+Makefile* text svneol=native#text/plain
+README text svneol=native#text/plain
+TODO text svneol=native#text/plain
+
+# Code formats
+*.c text svneol=native#text/plain
+*.cpp text svneol=native#text/plain
+*.h text svneol=native#text/plain
+*.hpp text svneol=native#text/plain
+*.ipp text svneol=native#text/plain
+*.tpp text svneol=native#text/plain
+*.jam text svneol=native#text/plain
+*.java text svneol=native#text/plain
diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2
new file mode 100644
index 0000000..b7f51b7
--- /dev/null
+++ b/doc/Jamfile.v2
@@ -0,0 +1,19 @@
+#~ Copyright Marshall Clow 2013
+#~ Distributed under the Boost Software License, Version 1.0.
+#~ (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+using boostbook ;
+
+boostbook standalone
+ : array.xml
+ : <xsl:param>boost.root=../../../.. ;
+
+###############################################################################
+alias boostdoc
+ : array.xml
+ :
+ :
+ : ;
+explicit boostdoc ;
+alias boostrelease ;
+explicit boostrelease ;
diff --git a/doc/array.xml b/doc/array.xml
new file mode 100644
index 0000000..68ee5a3
--- /dev/null
+++ b/doc/array.xml
@@ -0,0 +1,639 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+ "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
+<library name="Array" dirname="array" id="array" last-revision="$Date$">
+ <libraryinfo>
+ <author>
+ <firstname>Nicolai</firstname>
+ <surname>Josuttis</surname>
+ </author>
+ <maintainer>
+ <firstname>Marshall</firstname>
+ <surname>Clow</surname>
+ </maintainer>
+
+ <copyright>
+ <year>2001</year>
+ <year>2002</year>
+ <year>2003</year>
+ <year>2004</year>
+ <holder>Nicolai M. Josuttis</holder>
+ </copyright>
+
+ <copyright>
+ <year>2012</year>
+ <holder>Marshall Clow</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>
+
+ <librarypurpose>STL compliant container wrapper for arrays of constant size</librarypurpose>
+ <librarycategory name="category:containers"/>
+ </libraryinfo>
+
+ <title>Boost.Array</title>
+
+ <section id="array.intro">
+ <title>Introduction</title>
+
+ <using-namespace name="boost"/>
+ <using-class name="array"/>
+
+ <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
+ <code><classname>std::vector</classname></code>. However,
+ <code><classname>std::vector<></classname></code> provides
+ the semantics of dynamic arrays. Thus, it manages data to be able
+ to change the number of elements. This results in some overhead in
+ case only arrays with static size are needed.</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
+ <code>block</code>. 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 <code>c_array</code>, 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
+ <code>carray</code>. 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 <code><classname>array</classname></code>.</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://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1548.htm">http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1548.htm</ulink>).</para>
+
+ <para>Update: <code>std::array</code> is (as of C++11) part of the C++ standard.
+ The differences between <code>boost::array</code> and <code>std::array</code> are minimal.
+ If you are using C++11, you should consider using <code>std::array</code> instead of <code>boost::array</code>.
+ </para>
+
+ <para>Class <code><classname>array</classname></code> fulfills most
+ but not all of the requirements of "reversible containers" (see
+ Section 23.1, [lib.container.requirements] of the C++
+ Standard). The reasons array is not an reversible STL container is
+ because:
+ <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><functionname>swap</functionname>() has no constant complexity.</simpara></listitem>
+ <listitem><simpara><methodname>size</methodname>() 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><methodname>front</methodname>() and <methodname>back</methodname>() are provided.</simpara></listitem>
+ <listitem><simpara><methodname>operator[]</methodname> and <methodname>at</methodname>() are provided.</simpara></listitem>
+ </itemizedlist>
+ </para>
+ </section>
+
+ <library-reference>
+ <header name="boost/array.hpp">
+ <namespace name="boost">
+ <class name="array">
+ <template>
+ <template-type-parameter name="T"/>
+ <template-nontype-parameter name="N">
+ <type>std::size_t</type>
+ </template-nontype-parameter>
+ </template>
+
+ <purpose><para>STL compliant container wrapper for arrays of constant size</para></purpose>
+ <typedef name="value_type">
+ <type>T</type>
+ </typedef>
+ <typedef name="iterator">
+ <type>T*</type>
+ </typedef>
+ <typedef name="const_iterator">
+ <type>const T*</type>
+ </typedef>
+ <typedef name="reverse_iterator">
+ <type><classname>std::reverse_iterator</classname><iterator></type>
+ </typedef>
+ <typedef name="const_reverse_iterator">
+ <type><classname>std::reverse_iterator</classname><const_iterator></type>
+ </typedef>
+ <typedef name="reference">
+ <type>T&</type>
+ </typedef>
+ <typedef name="const_reference">
+ <type>const T&</type>
+ </typedef>
+ <typedef name="size_type">
+ <type>std::size_t</type>
+ </typedef>
+ <typedef name="difference_type">
+ <type>std::ptrdiff_t</type>
+ </typedef>
+
+ <static-constant name="static_size">
+ <type>size_type</type>
+ <default>N</default>
+ </static-constant>
+
+ <copy-assignment>
+ <template>
+ <template-type-parameter name="U"/>
+ </template>
+ <parameter name="other">
+ <paramtype>const <classname>array</classname><U, N>&</paramtype>
+ </parameter>
+ <effects><simpara><code>std::copy(rhs.<methodname>begin</methodname>(),rhs.<methodname>end</methodname>(), <methodname>begin</methodname>())</code></simpara></effects>
+ </copy-assignment>
+
+ <method-group name="iterator support">
+ <overloaded-method name="begin">
+ <signature>
+ <type>iterator</type>
+ </signature>
+ <signature cv="const">
+ <type>const_iterator</type>
+ </signature>
+
+ <returns><simpara>iterator for the first element</simpara></returns>
+ <throws><simpara>will not throw</simpara></throws>
+ </overloaded-method>
+
+ <overloaded-method name="end">
+ <signature>
+ <type>iterator</type>
+ </signature>
+ <signature cv="const">
+ <type>const_iterator</type>
+ </signature>
+
+ <returns><simpara>iterator for position after the last element</simpara></returns>
+ <throws><simpara>will not throw</simpara></throws>
+ </overloaded-method>
+
+ <overloaded-method name="cbegin" cv="const">
+ <signature>
+ <type>const_iterator</type>
+ </signature>
+
+ <returns><simpara>constant iterator for the first element</simpara></returns>
+ <throws><simpara>will not throw</simpara></throws>
+ </overloaded-method>
+
+ <overloaded-method name="cend" cv="const">
+ <signature>
+ <type>const_iterator</type>
+ </signature>
+
+ <returns><simpara>constant iterator for position after the last element</simpara></returns>
+ <throws><simpara>will not throw</simpara></throws>
+ </overloaded-method>
+ </method-group>
+
+ <method-group name="reverse iterator support">
+ <overloaded-method name="rbegin">
+ <signature>
+ <type>reverse_iterator</type>
+ </signature>
+ <signature cv="const">
+ <type>const_reverse_iterator</type>
+ </signature>
+
+ <returns><simpara>reverse iterator for the first element of reverse iteration</simpara></returns>
+ </overloaded-method>
+
+ <overloaded-method name="rend">
+ <signature>
+ <type>reverse_iterator</type>
+ </signature>
+ <signature cv="const">
+ <type>const_reverse_iterator</type>
+ </signature>
+
+ <returns><simpara>reverse iterator for position after the last element in reverse iteration</simpara></returns>
+ </overloaded-method>
+
+ <overloaded-method name="crbegin" cv="const">
+ <signature>
+ <type>const_reverse_iterator</type>
+ </signature>
+
+ <returns><simpara>constant reverse iterator for the first element of reverse iteration</simpara></returns>
+ <throws><simpara>will not throw</simpara></throws>
+ </overloaded-method>
+
+ <overloaded-method name="crend" cv="const">
+ <signature>
+ <type>const_reverse_iterator</type>
+ </signature>
+
+ <returns><simpara>constant reverse iterator for position after the last element in reverse iteration</simpara></returns>
+ <throws><simpara>will not throw</simpara></throws>
+ </overloaded-method>
+ </method-group>
+
+ <method-group name="capacity">
+ <method name="size">
+ <type>size_type</type>
+ <returns><simpara><code>N</code></simpara></returns>
+ </method>
+ <method name="empty">
+ <type>bool</type>
+ <returns><simpara><code>N==0</code></simpara></returns>
+ <throws><simpara>will not throw</simpara></throws>
+ </method>
+ <method name="max_size">
+ <type>size_type</type>
+ <returns><simpara><code>N</code></simpara></returns>
+ <throws><simpara>will not throw</simpara></throws>
+ </method>
+ </method-group>
+
+ <method-group name="element access">
+ <overloaded-method name="operator[]">
+ <signature>
+ <type>reference</type>
+ <parameter name="i">
+ <paramtype>size_type</paramtype>
+ </parameter>
+ </signature>
+
+ <signature cv="const">
+ <type>const_reference</type>
+ <parameter name="i">
+ <paramtype>size_type</paramtype>
+ </parameter>
+ </signature>
+
+ <requires><simpara><code>i < N</code></simpara></requires>
+ <returns><simpara>element with index <code>i</code></simpara></returns>
+ <throws><simpara>will not throw.</simpara></throws>
+ </overloaded-method>
+
+ <overloaded-method name="at">
+ <signature>
+ <type>reference</type>
+ <parameter name="i">
+ <paramtype>size_type</paramtype>
+ </parameter>
+ </signature>
+
+ <signature cv="const">
+ <type>const_reference</type>
+ <parameter name="i">
+ <paramtype>size_type</paramtype>
+ </parameter>
+ </signature>
+
+ <returns><simpara>element with index <code>i</code></simpara></returns>
+ <throws><simpara><code><classname>std::range_error</classname></code> if <code>i >= N</code></simpara></throws>
+ </overloaded-method>
+
+ <overloaded-method name="front">
+ <signature>
+ <type>reference</type>
+ </signature>
+ <signature cv="const">
+ <type>const_reference</type>
+ </signature>
+ <requires><simpara><code>N > 0</code></simpara></requires>
+ <returns><simpara>the first element</simpara></returns>
+ <throws><simpara>will not throw</simpara></throws>
+ </overloaded-method>
+
+ <overloaded-method name="back">
+ <signature>
+ <type>reference</type>
+ </signature>
+ <signature cv="const">
+ <type>const_reference</type>
+ </signature>
+ <requires><simpara><code>N > 0</code></simpara></requires>
+ <returns><simpara>the last element</simpara></returns>
+ <throws><simpara>will not throw</simpara></throws>
+ </overloaded-method>
+
+ <method name="data" cv="const">
+ <type>const T*</type>
+ <returns><simpara><code>elems</code></simpara></returns>
+ <throws><simpara>will not throw</simpara></throws>
+ </method>
+
+ <method name="c_array">
+ <type>T*</type>
+ <returns><simpara><code>elems</code></simpara></returns>
+ <throws><simpara>will not throw</simpara></throws>
+ </method>
+ </method-group>
+
+ <method-group name="modifiers">
+ <method name="swap">
+ <type>void</type>
+ <parameter name="other">
+ <paramtype><classname>array</classname><T, N>&</paramtype>
+ </parameter>
+ <effects><simpara><code>std::swap_ranges(<methodname>begin</methodname>(), <methodname>end</methodname>(), other.<methodname>begin</methodname>())</code></simpara></effects>
+ <complexity><simpara>linear in <code>N</code></simpara></complexity>
+ </method>
+ <method name="assign">
+ <type>void</type>
+ <parameter name="value">
+ <paramtype>const T&</paramtype>
+ </parameter>
+ <effects><simpara><code>std::fill_n(<methodname>begin</methodname>(), N, value)</code></simpara></effects>
+ </method>
+ </method-group>
+
+ <data-member name="elems[N]"> <!-- HACK -->
+ <type>T</type>
+ </data-member>
+
+ <free-function-group name="specialized algorithms">
+ <function name="swap">
+ <template>
+ <template-type-parameter name="T"/>
+ <template-nontype-parameter name="N">
+ <type>std::size_t</type>
+ </template-nontype-parameter>
+ </template>
+
+ <type>void</type>
+
+ <parameter name="x">
+ <paramtype><classname>array</classname><T, N>&</paramtype>
+ </parameter>
+ <parameter name="y">
+ <paramtype><classname>array</classname><T, N>&</paramtype>
+ </parameter>
+
+ <effects><simpara><code>x.<methodname>swap</methodname>(y)</code></simpara></effects>
+ <throws><simpara>will not throw.</simpara></throws>
+ </function>
+ </free-function-group>
+
+ <free-function-group name="comparisons">
+ <function name="operator==">
+ <template>
+ <template-type-parameter name="T"/>
+ <template-nontype-parameter name="N">
+ <type>std::size_t</type>
+ </template-nontype-parameter>
+ </template>
+
+ <type>bool</type>
+
+ <parameter name="x">
+ <paramtype>const <classname>array</classname><T, N>&</paramtype>
+ </parameter>
+ <parameter name="y">
+ <paramtype>const <classname>array</classname><T, N>&</paramtype>
+ </parameter>
+
+ <returns><simpara><code>std::equal(x.<methodname>begin</methodname>(), x.<methodname>end</methodname>(), y.<methodname>begin</methodname>())</code></simpara>
+ </returns>
+ </function>
+
+ <function name="operator!=">
+ <template>
+ <template-type-parameter name="T"/>
+ <template-nontype-parameter name="N">
+ <type>std::size_t</type>
+ </template-nontype-parameter>
+ </template>
+
+ <type>bool</type>
+
+ <parameter name="x">
+ <paramtype>const <classname>array</classname><T, N>&</paramtype>
+ </parameter>
+ <parameter name="y">
+ <paramtype>const <classname>array</classname><T, N>&</paramtype>
+ </parameter>
+
+ <returns><simpara><code>!(x == y)</code></simpara>
+ </returns>
+ </function>
+
+ <function name="operator<">
+ <template>
+ <template-type-parameter name="T"/>
+ <template-nontype-parameter name="N">
+ <type>std::size_t</type>
+ </template-nontype-parameter>
+ </template>
+
+ <type>bool</type>
+
+ <parameter name="x">
+ <paramtype>const <classname>array</classname><T, N>&</paramtype>
+ </parameter>
+ <parameter name="y">
+ <paramtype>const <classname>array</classname><T, N>&</paramtype>
+ </parameter>
+
+ <returns><simpara><code>std::lexicographical_compare(x.<methodname>begin</methodname>(), x.<methodname>end</methodname>(), y.<methodname>begin</methodname>(), y.<methodname>end</methodname>())</code></simpara>
+ </returns>
+ </function>
+
+ <function name="operator>">
+ <template>
+ <template-type-parameter name="T"/>
+ <template-nontype-parameter name="N">
+ <type>std::size_t</type>
+ </template-nontype-parameter>
+ </template>
+
+ <type>bool</type>
+
+ <parameter name="x">
+ <paramtype>const <classname>array</classname><T, N>&</paramtype>
+ </parameter>
+ <parameter name="y">
+ <paramtype>const <classname>array</classname><T, N>&</paramtype>
+ </parameter>
+
+ <returns><simpara><code>y < x</code></simpara></returns>
+ </function>
+
+ <function name="operator<=">
+ <template>
+ <template-type-parameter name="T"/>
+ <template-nontype-parameter name="N">
+ <type>std::size_t</type>
+ </template-nontype-parameter>
+ </template>
+
+ <type>bool</type>
+
+ <parameter name="x">
+ <paramtype>const <classname>array</classname><T, N>&</paramtype>
+ </parameter>
+ <parameter name="y">
+ <paramtype>const <classname>array</classname><T, N>&</paramtype>
+ </parameter>
+
+ <returns><simpara><code>!(y < x)</code></simpara></returns>
+ </function>
+
+ <function name="operator>=">
+ <template>
+ <template-type-parameter name="T"/>
+ <template-nontype-parameter name="N">
+ <type>std::size_t</type>
+ </template-nontype-parameter>
+ </template>
+
+ <type>bool</type>
+
+ <parameter name="x">
+ <paramtype>const <classname>array</classname><T, N>&</paramtype>
+ </parameter>
+ <parameter name="y">
+ <paramtype>const <classname>array</classname><T, N>&</paramtype>
+ </parameter>
+
+ <returns><simpara><code>!(x < y)</code></simpara></returns>
+ </function>
+ </free-function-group>
+
+ <free-function-group name="specializations">
+ <function name="boost::get">
+ <template>
+ <template-type-parameter name="T"/>
+ <template-nontype-parameter name="N">
+ <type>std::size_t</type>
+ </template-nontype-parameter>
+ <template-nontype-parameter name="Idx">
+ <type>std::size_t</type>
+ </template-nontype-parameter>
+ </template>
+
+ <type>T</type>
+
+ <parameter name="arr">
+ <paramtype><classname>array</classname><T, N>&</paramtype>
+ </parameter>
+ <returns><simpara>element of array with index <code>Idx</code></simpara></returns>
+ <effects><simpara>Will <code>static_assert</code> if <code>Idx >= N</code></simpara></effects>
+ </function>
+
+ <function name="boost::get">
+ <template>
+ <template-type-parameter name="T"/>
+ <template-nontype-parameter name="N">
+ <type>std::size_t</type>
+ </template-nontype-parameter>
+ <template-nontype-parameter name="Idx">
+ <type>std::size_t</type>
+ </template-nontype-parameter>
+ </template>
+
+ <type>T</type>
+
+ <parameter name="arr">
+ <paramtype>const <classname>array</classname><T, N>&</paramtype>
+ </parameter>
+ <returns><simpara>const element of array with index <code>Idx</code></simpara></returns>
+ <effects><simpara>Will <code>static_assert</code> if <code>Idx >= N</code></simpara></effects>
+ </function>
+ </free-function-group>
+
+ </class>
+ </namespace>
+ </header>
+ </library-reference>
+
+<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><classname>boost::array</classname><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>
+<classname>boost::array</classname><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>
+
+<!-- Notes:
+ empty() should return N != 0
+ size(), empty(), max_size() should be const
+ -->
+
+</library>
diff --git a/include/boost/array.hpp b/include/boost/array.hpp
new file mode 100644
index 0000000..210c072
--- /dev/null
+++ b/include/boost/array.hpp
@@ -0,0 +1,457 @@
+/* The following code declares class array,
+ * an STL container (as wrapper) for arrays of constant size.
+ *
+ * See
+ * http://www.boost.org/libs/array/
+ * for documentation.
+ *
+ * The original author site is at: http://www.josuttis.com/
+ *
+ * (C) Copyright Nicolai M. Josuttis 2001.
+ *
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * 9 Jan 2013 - (mtc) Added constexpr
+ * 14 Apr 2012 - (mtc) Added support for boost::hash
+ * 28 Dec 2010 - (mtc) Added cbegin and cend (and crbegin and crend) for C++Ox compatibility.
+ * 10 Mar 2010 - (mtc) fill method added, matching resolution of the standard library working group.
+ * See <http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#776> or Trac issue #3168
+ * Eventually, we should remove "assign" which is now a synonym for "fill" (Marshall Clow)
+ * 10 Mar 2010 - added workaround for SUNCC and !STLPort [trac #3893] (Marshall Clow)
+ * 29 Jan 2004 - c_array() added, BOOST_NO_PRIVATE_IN_AGGREGATE removed (Nico Josuttis)
+ * 23 Aug 2002 - fix for Non-MSVC compilers combined with MSVC libraries.
+ * 05 Aug 2001 - minor update (Nico Josuttis)
+ * 20 Jan 2001 - STLport fix (Beman Dawes)
+ * 29 Sep 2000 - Initial Revision (Nico Josuttis)
+ *
+ * Jan 29, 2004
+ */
+#ifndef BOOST_ARRAY_HPP
+#define BOOST_ARRAY_HPP
+
+#include <boost/detail/workaround.hpp>
+
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
+# pragma warning(push)
+# pragma warning(disable:4996) // 'std::equal': Function call with parameters that may be unsafe
+# pragma warning(disable:4510) // boost::array<T,N>' : default constructor could not be generated
+# pragma warning(disable:4610) // warning C4610: class 'boost::array<T,N>' can never be instantiated - user defined constructor required
+#endif
+
+#include <cstddef>
+#include <stdexcept>
+#include <boost/assert.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/swap.hpp>
+
+// Handles broken standard libraries better than <iterator>
+#include <boost/detail/iterator.hpp>
+#include <boost/throw_exception.hpp>
+#include <algorithm>
+
+// FIXES for broken compilers
+#include <boost/config.hpp>
+
+
+namespace boost {
+
+ template<class T, std::size_t N>
+ class array {
+ public:
+ T elems[N]; // fixed-size array of elements of type T
+
+ public:
+ // type definitions
+ typedef T value_type;
+ typedef T* iterator;
+ typedef const T* const_iterator;
+ typedef T& reference;
+ typedef const T& const_reference;
+ typedef std::size_t size_type;
+ typedef std::ptrdiff_t difference_type;
+
+ // iterator support
+ iterator begin() { return elems; }
+ const_iterator begin() const { return elems; }
+ const_iterator cbegin() const { return elems; }
+
+ iterator end() { return elems+N; }
+ const_iterator end() const { return elems+N; }
+ const_iterator cend() const { return elems+N; }
+
+ // reverse iterator support
+#if !defined(BOOST_MSVC_STD_ITERATOR) && !defined(BOOST_NO_STD_ITERATOR_TRAITS)
+ typedef std::reverse_iterator<iterator> reverse_iterator;
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+#elif defined(_RWSTD_NO_CLASS_PARTIAL_SPEC)
+ typedef std::reverse_iterator<iterator, std::random_access_iterator_tag,
+ value_type, reference, iterator, difference_type> reverse_iterator;
+ typedef std::reverse_iterator<const_iterator, std::random_access_iterator_tag,
+ value_type, const_reference, const_iterator, difference_type> const_reverse_iterator;
+#else
+ // workaround for broken reverse_iterator implementations
+ typedef std::reverse_iterator<iterator,T> reverse_iterator;
+ typedef std::reverse_iterator<const_iterator,T> const_reverse_iterator;
+#endif
+
+ reverse_iterator rbegin() { return reverse_iterator(end()); }
+ const_reverse_iterator rbegin() const {
+ return const_reverse_iterator(end());
+ }
+ const_reverse_iterator crbegin() const {
+ return const_reverse_iterator(end());
+ }
+
+ reverse_iterator rend() { return reverse_iterator(begin()); }
+ const_reverse_iterator rend() const {
+ return const_reverse_iterator(begin());
+ }
+ const_reverse_iterator crend() const {
+ return const_reverse_iterator(begin());
+ }
+
+ // operator[]
+ reference operator[](size_type i)
+ {
+ return BOOST_ASSERT_MSG( i < N, "out of range" ), elems[i];
+ }
+
+ /*BOOST_CONSTEXPR*/ const_reference operator[](size_type i) const
+ {
+ return BOOST_ASSERT_MSG( i < N, "out of range" ), elems[i];
+ }
+
+ // at() with range check
+ reference at(size_type i) { return rangecheck(i), elems[i]; }
+ /*BOOST_CONSTEXPR*/ const_reference at(size_type i) const { return rangecheck(i), elems[i]; }
+
+ // front() and back()
+ reference front()
+ {
+ return elems[0];
+ }
+
+ BOOST_CONSTEXPR const_reference front() const
+ {
+ return elems[0];
+ }
+
+ reference back()
+ {
+ return elems[N-1];
+ }
+
+ BOOST_CONSTEXPR const_reference back() const
+ {
+ return elems[N-1];
+ }
+
+ // size is constant
+ static BOOST_CONSTEXPR size_type size() { return N; }
+ static BOOST_CONSTEXPR bool empty() { return false; }
+ static BOOST_CONSTEXPR size_type max_size() { return N; }
+ enum { static_size = N };
+
+ // swap (note: linear complexity)
+ void swap (array<T,N>& y) {
+ for (size_type i = 0; i < N; ++i)
+ boost::swap(elems[i],y.elems[i]);
+ }
+
+ // direct access to data (read-only)
+ const T* data() const { return elems; }
+ T* data() { return elems; }
+
+ // use array as C array (direct read/write access to data)
+ T* c_array() { return elems; }
+
+ // assignment with type conversion
+ template <typename T2>
+ array<T,N>& operator= (const array<T2,N>& rhs) {
+ std::copy(rhs.begin(),rhs.end(), begin());
+ return *this;
+ }
+
+ // assign one value to all elements
+ void assign (const T& value) { fill ( value ); } // A synonym for fill
+ void fill (const T& value)
+ {
+ std::fill_n(begin(),size(),value);
+ }
+
+ // check range (may be private because it is static)
+ static BOOST_CONSTEXPR bool rangecheck (size_type i) {
+ return i > size() ? boost::throw_exception(std::out_of_range ("array<>: index out of range")), true : true;
+ }
+
+ };
+
+ template< class T >
+ class array< T, 0 > {
+
+ public:
+ // type definitions
+ typedef T value_type;
+ typedef T* iterator;
+ typedef const T* const_iterator;
+ typedef T& reference;
+ typedef const T& const_reference;
+ typedef std::size_t size_type;
+ typedef std::ptrdiff_t difference_type;
+
+ // iterator support
+ iterator begin() { return iterator( reinterpret_cast< T * >( this ) ); }
+ const_iterator begin() const { return const_iterator( reinterpret_cast< const T * >( this ) ); }
+ const_iterator cbegin() const { return const_iterator( reinterpret_cast< const T * >( this ) ); }
+
+ iterator end() { return begin(); }
+ const_iterator end() const { return begin(); }
+ const_iterator cend() const { return cbegin(); }
+
+ // reverse iterator support
+#if !defined(BOOST_MSVC_STD_ITERATOR) && !defined(BOOST_NO_STD_ITERATOR_TRAITS)
+ typedef std::reverse_iterator<iterator> reverse_iterator;
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+#elif defined(_RWSTD_NO_CLASS_PARTIAL_SPEC)
+ typedef std::reverse_iterator<iterator, std::random_access_iterator_tag,
+ value_type, reference, iterator, difference_type> reverse_iterator;
+ typedef std::reverse_iterator<const_iterator, std::random_access_iterator_tag,
+ value_type, const_reference, const_iterator, difference_type> const_reverse_iterator;
+#else
+ // workaround for broken reverse_iterator implementations
+ typedef std::reverse_iterator<iterator,T> reverse_iterator;
+ typedef std::reverse_iterator<const_iterator,T> const_reverse_iterator;
+#endif
+
+ reverse_iterator rbegin() { return reverse_iterator(end()); }
+ const_reverse_iterator rbegin() const {
+ return const_reverse_iterator(end());
+ }
+ const_reverse_iterator crbegin() const {
+ return const_reverse_iterator(end());
+ }
+
+ reverse_iterator rend() { return reverse_iterator(begin()); }
+ const_reverse_iterator rend() const {
+ return const_reverse_iterator(begin());
+ }
+ const_reverse_iterator crend() const {
+ return const_reverse_iterator(begin());
+ }
+
+ // operator[]
+ reference operator[](size_type /*i*/)
+ {
+ return failed_rangecheck();
+ }
+
+ /*BOOST_CONSTEXPR*/ const_reference operator[](size_type /*i*/) const
+ {
+ return failed_rangecheck();
+ }
+
+ // at() with range check
+ reference at(size_type /*i*/) { return failed_rangecheck(); }
+ /*BOOST_CONSTEXPR*/ const_reference at(size_type /*i*/) const { return failed_rangecheck(); }
+
+ // front() and back()
+ reference front()
+ {
+ return failed_rangecheck();
+ }
+
+ BOOST_CONSTEXPR const_reference front() const
+ {
+ return failed_rangecheck();
+ }
+
+ reference back()
+ {
+ return failed_rangecheck();
+ }
+
+ BOOST_CONSTEXPR const_reference back() const
+ {
+ return failed_rangecheck();
+ }
+
+ // size is constant
+ static BOOST_CONSTEXPR size_type size() { return 0; }
+ static BOOST_CONSTEXPR bool empty() { return true; }
+ static BOOST_CONSTEXPR size_type max_size() { return 0; }
+ enum { static_size = 0 };
+
+ void swap (array<T,0>& /*y*/) {
+ }
+
+ // direct access to data (read-only)
+ const T* data() const { return 0; }
+ T* data() { return 0; }
+
+ // use array as C array (direct read/write access to data)
+ T* c_array() { return 0; }
+
+ // assignment with type conversion
+ template <typename T2>
+ array<T,0>& operator= (const array<T2,0>& ) {
+ return *this;
+ }
+
+ // assign one value to all elements
+ void assign (const T& value) { fill ( value ); }
+ void fill (const T& ) {}
+
+ // check range (may be private because it is static)
+ static reference failed_rangecheck () {
+ std::out_of_range e("attempt to access element of an empty array");
+ boost::throw_exception(e);
+#if defined(BOOST_NO_EXCEPTIONS) || (!defined(BOOST_MSVC) && !defined(__PATHSCALE__))
+ //
+ // We need to return something here to keep
+ // some compilers happy: however we will never
+ // actually get here....
+ //
+ static T placeholder;
+ return placeholder;
+#endif
+ }
+ };
+
+ // comparisons
+ template<class T, std::size_t N>
+ bool operator== (const array<T,N>& x, const array<T,N>& y) {
+ return std::equal(x.begin(), x.end(), y.begin());
+ }
+ template<class T, std::size_t N>
+ bool operator< (const array<T,N>& x, const array<T,N>& y) {
+ return std::lexicographical_compare(x.begin(),x.end(),y.begin(),y.end());
+ }
+ template<class T, std::size_t N>
+ bool operator!= (const array<T,N>& x, const array<T,N>& y) {
+ return !(x==y);
+ }
+ template<class T, std::size_t N>
+ bool operator> (const array<T,N>& x, const array<T,N>& y) {
+ return y<x;
+ }
+ template<class T, std::size_t N>
+ bool operator<= (const array<T,N>& x, const array<T,N>& y) {
+ return !(y<x);
+ }
+ template<class T, std::size_t N>
+ bool operator>= (const array<T,N>& x, const array<T,N>& y) {
+ return !(x<y);
+ }
+
+ // global swap()
+ template<class T, std::size_t N>
+ inline void swap (array<T,N>& x, array<T,N>& y) {
+ x.swap(y);
+ }
+
+#if defined(__SUNPRO_CC)
+// Trac ticket #4757; the Sun Solaris compiler can't handle
+// syntax like 'T(&get_c_array(boost::array<T,N>& arg))[N]'
+//
+// We can't just use this for all compilers, because the
+// borland compilers can't handle this form.
+ namespace detail {
+ template <typename T, std::size_t N> struct c_array
+ {
+ typedef T type[N];
+ };
+ }
+
+ // Specific for boost::array: simply returns its elems data member.
+ template <typename T, std::size_t N>
+ typename detail::c_array<T,N>::type& get_c_array(boost::array<T,N>& arg)
+ {
+ return arg.elems;
+ }
+
+ // Specific for boost::array: simply returns its elems data member.
+ template <typename T, std::size_t N>
+ typename detail::c_array<T,N>::type const& get_c_array(const boost::array<T,N>& arg)
+ {
+ return arg.elems;
+ }
+#else
+// Specific for boost::array: simply returns its elems data member.
+ template <typename T, std::size_t N>
+ T(&get_c_array(boost::array<T,N>& arg))[N]
+ {
+ return arg.elems;
+ }
+
+ // Const version.
+ template <typename T, std::size_t N>
+ const T(&get_c_array(const boost::array<T,N>& arg))[N]
+ {
+ return arg.elems;
+ }
+#endif
+
+#if 0
+ // Overload for std::array, assuming that std::array will have
+ // explicit conversion functions as discussed at the WG21 meeting
+ // in Summit, March 2009.
+ template <typename T, std::size_t N>
+ T(&get_c_array(std::array<T,N>& arg))[N]
+ {
+ return static_cast<T(&)[N]>(arg);
+ }
+
+ // Const version.
+ template <typename T, std::size_t N>
+ const T(&get_c_array(const std::array<T,N>& arg))[N]
+ {
+ return static_cast<T(&)[N]>(arg);
+ }
+#endif
+
+ template <class It> std::size_t hash_range(It, It);
+
+ template<class T, std::size_t N>
+ std::size_t hash_value(const array<T,N>& arr)
+ {
+ return boost::hash_range(arr.begin(), arr.end());
+ }
+
+ template <size_t Idx, typename T, size_t N>
+ T &get(boost::array<T,N> &arr) BOOST_NOEXCEPT {
+ BOOST_STATIC_ASSERT_MSG ( Idx < N, "boost::get<>(boost::array &) index out of range" );
+ return arr[Idx];
+ }
+
+ template <size_t Idx, typename T, size_t N>
+ const T &get(const boost::array<T,N> &arr) BOOST_NOEXCEPT {
+ BOOST_STATIC_ASSERT_MSG ( Idx < N, "boost::get<>(const boost::array &) index out of range" );
+ return arr[Idx];
+ }
+
+} /* namespace boost */
+
+#ifndef BOOST_NO_CXX11_HDR_ARRAY
+// If we don't have std::array, I'm assuming that we don't have std::get
+namespace std {
+ template <size_t Idx, typename T, size_t N>
+ T &get(boost::array<T,N> &arr) BOOST_NOEXCEPT {
+ BOOST_STATIC_ASSERT_MSG ( Idx < N, "std::get<>(boost::array &) index out of range" );
+ return arr[Idx];
+ }
+
+ template <size_t Idx, typename T, size_t N>
+ const T &get(const boost::array<T,N> &arr) BOOST_NOEXCEPT {
+ BOOST_STATIC_ASSERT_MSG ( Idx < N, "std::get<>(const boost::array &) index out of range" );
+ return arr[Idx];
+ }
+}
+#endif
+
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
+# pragma warning(pop)
+#endif
+
+#endif /*BOOST_ARRAY_HPP*/
diff --git a/index.html b/index.html
new file mode 100644
index 0000000..a9e3c34
--- /dev/null
+++ b/index.html
@@ -0,0 +1,13 @@
+<html>
+<head>
+<meta http-equiv="refresh" content="0; URL=../../doc/html/array.html">
+</head>
+<body>
+Automatic redirection failed, please go to
+<a href="../../doc/html/array.html">../../doc/html/array.html</a> <hr>
+<p>© Copyright Beman Dawes, 2001</p>
+<p>Distributed under the Boost Software License, Version 1.0. (See accompanying
+file <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy
+at <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</p>
+</body>
+</html>
\ No newline at end of file
diff --git a/meta/libraries.json b/meta/libraries.json
new file mode 100644
index 0000000..7710ee2
--- /dev/null
+++ b/meta/libraries.json
@@ -0,0 +1,17 @@
+{
+ "key": "array",
+ "name": "Array",
+ "authors": [
+ "Nicolai Josuttis"
+ ],
+ "description": "STL compliant container wrapper for arrays of constant size.",
+ "std": [
+ "tr1"
+ ],
+ "category": [
+ "Containers"
+ ],
+ "maintainers": [
+ "Marshall Clow <marshall -at- idio.com>"
+ ]
+}
diff --git a/test/Jamfile.v2 b/test/Jamfile.v2
new file mode 100644
index 0000000..1a04d91
--- /dev/null
+++ b/test/Jamfile.v2
@@ -0,0 +1,25 @@
+#~ Copyright Rene Rivera 2008
+#~ Distributed under the Boost Software License, Version 1.0.
+#~ (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+import testing ;
+
+alias unit_test_framework
+ : # sources
+ /boost//unit_test_framework
+ ;
+
+test-suite array :
+ [ run array0.cpp unit_test_framework : : : : array0 ]
+ [ run array1.cpp ]
+ [ run array2.cpp ]
+ [ run array3.cpp ]
+ [ run array4.cpp ]
+ [ run array5.cpp ]
+ [ run array6.cpp unit_test_framework : : : : array6 ]
+ [ run array7.cpp unit_test_framework : : : : array7 ]
+# [ run array_constexpr.cpp unit_test_framework : : : : array_constexpr ]
+ [ compile-fail array_getfail1.cpp ]
+ [ compile-fail array_getfail2.cpp ]
+ [ run array_hash.cpp unit_test_framework : : : : array_hash ]
+ ;
diff --git a/test/array0.cpp b/test/array0.cpp
new file mode 100644
index 0000000..c1c047e
--- /dev/null
+++ b/test/array0.cpp
@@ -0,0 +1,89 @@
+/* tests for using class array<> specialization for size 0
+ * (C) Copyright Alisdair Meredith 2006.
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#include <string>
+#include <iostream>
+#include <boost/array.hpp>
+
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
+
+namespace {
+
+template< class T >
+void BadValue( const T & )
+{
+ BOOST_CHECK ( false );
+}
+
+template< class T >
+void RunTests()
+{
+ typedef boost::array< T, 0 > test_type;
+
+ // Test value and aggegrate initialization
+ test_type test_case = {};
+ const boost::array< T, 0 > const_test_case = test_type();
+
+ test_case.fill ( T() );
+
+ // front/back and operator[] must compile, but calling them is undefined
+ // Likewise, all tests below should evaluate to false, avoiding undefined behaviour
+ BOOST_CHECK ( test_case.empty());
+ BOOST_CHECK ( const_test_case.empty());
+
+ BOOST_CHECK ( test_case.size() == 0 );
+ BOOST_CHECK ( const_test_case.size() == 0 );
+
+ // Assert requirements of TR1 6.2.2.4
+ BOOST_CHECK ( test_case.begin() == test_case.end());
+ BOOST_CHECK ( test_case.cbegin() == test_case.cend());
+ BOOST_CHECK ( const_test_case.begin() == const_test_case.end());
+ BOOST_CHECK ( const_test_case.cbegin() == const_test_case.cend());
+
+ BOOST_CHECK ( test_case.begin() != const_test_case.begin() );
+ if( test_case.data() == const_test_case.data() ) {
+ // Value of data is unspecified in TR1, so no requirement this test pass or fail
+ // However, it must compile!
+ }
+
+ // Check can safely use all iterator types with std algorithms
+ std::for_each( test_case.begin(), test_case.end(), BadValue< T > );
+ std::for_each( test_case.rbegin(), test_case.rend(), BadValue< T > );
+ std::for_each( test_case.cbegin(), test_case.cend(), BadValue< T > );
+ std::for_each( const_test_case.begin(), const_test_case.end(), BadValue< T > );
+ std::for_each( const_test_case.rbegin(), const_test_case.rend(), BadValue< T > );
+ std::for_each( const_test_case.cbegin(), const_test_case.cend(), BadValue< T > );
+
+ // Check swap is well formed
+ std::swap( test_case, test_case );
+
+ // Check assignment operator and overloads are well formed
+ test_case = const_test_case;
+
+ // Confirm at() throws the std lib defined exception
+ try {
+ BadValue( test_case.at( 0 ));
+ } catch ( const std::out_of_range & ) {
+ }
+
+ try {
+ BadValue( const_test_case.at( 0 ) );
+ } catch ( const std::out_of_range & ) {
+ }
+}
+
+}
+
+BOOST_AUTO_TEST_CASE( test_main )
+{
+ RunTests< bool >();
+ RunTests< void * >();
+ RunTests< long double >();
+ RunTests< std::string >();
+}
+
diff --git a/test/array1.cpp b/test/array1.cpp
new file mode 100644
index 0000000..740968f
--- /dev/null
+++ b/test/array1.cpp
@@ -0,0 +1,58 @@
+/* simple example for using class array<>
+ *
+ * (C) Copyright Nicolai M. Josuttis 2001.
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * Changelog:
+ * 20 Jan 2001 - Removed boolalpha use since stock GCC doesn't support it
+ * (David Abrahams)
+ */
+
+#include <iostream>
+#include <boost/array.hpp>
+
+int main()
+{
+ // define special type name
+ typedef boost::array<float,6> Array;
+
+ // create and initialize an array
+ Array a = { { 42 } };
+
+ // access elements
+ for (unsigned i=1; i<a.size(); ++i) {
+ a[i] = a[i-1]+1;
+ }
+
+ // use some common STL container operations
+ std::cout << "size: " << a.size() << std::endl;
+ std::cout << "empty: " << (a.empty() ? "true" : "false") << std::endl;
+ std::cout << "max_size: " << a.max_size() << std::endl;
+ std::cout << "front: " << a.front() << std::endl;
+ std::cout << "back: " << a.back() << std::endl;
+ std::cout << "elems: ";
+
+ // iterate through all elements
+ for (Array::const_iterator pos=a.begin(); pos<a.end(); ++pos) {
+ std::cout << *pos << ' ';
+ }
+ std::cout << std::endl;
+
+ // check copy constructor and assignment operator
+ Array b(a);
+ Array c;
+ c = a;
+ if (a==b && a==c) {
+ std::cout << "copy construction and copy assignment are OK"
+ << std::endl;
+ }
+ else {
+ std::cout << "copy construction and copy assignment FAILED"
+ << std::endl;
+ }
+
+ return 0; // makes Visual-C++ compiler happy
+}
+
diff --git a/test/array2.cpp b/test/array2.cpp
new file mode 100644
index 0000000..b33e0b5
--- /dev/null
+++ b/test/array2.cpp
@@ -0,0 +1,44 @@
+/* example for using class array<>
+ * (C) Copyright Nicolai M. Josuttis 2001.
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#ifndef _SCL_SECURE_NO_WARNINGS
+// Suppress warnings from the std lib:
+# define _SCL_SECURE_NO_WARNINGS
+#endif
+
+#include <algorithm>
+#include <functional>
+#include <boost/array.hpp>
+#include "print.hpp"
+using namespace std;
+
+int main()
+{
+ // create and initialize array
+ boost::array<int,10> a = { { 1, 2, 3, 4, 5 } };
+
+ print_elements(a);
+
+ // modify elements directly
+ for (unsigned i=0; i<a.size(); ++i) {
+ ++a[i];
+ }
+ print_elements(a);
+
+ // change order using an STL algorithm
+ reverse(a.begin(),a.end());
+ print_elements(a);
+
+ // negate elements using STL framework
+ transform(a.begin(),a.end(), // source
+ a.begin(), // destination
+ negate<int>()); // operation
+ print_elements(a);
+
+ return 0; // makes Visual-C++ compiler happy
+}
+
diff --git a/test/array3.cpp b/test/array3.cpp
new file mode 100644
index 0000000..29aacb1
--- /dev/null
+++ b/test/array3.cpp
@@ -0,0 +1,62 @@
+/* example for using class array<>
+ * (C) Copyright Nicolai M. Josuttis 2001.
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#include <string>
+#include <iostream>
+#include <boost/array.hpp>
+
+template <class T>
+void print_elements (const T& x);
+
+int main()
+{
+ // create array of four seasons
+ boost::array<std::string,4> seasons = {
+ { "spring", "summer", "autumn", "winter" }
+ };
+
+ // copy and change order
+ boost::array<std::string,4> seasons_orig = seasons;
+ for (std::size_t i=seasons.size()-1; i>0; --i) {
+ std::swap(seasons.at(i),seasons.at((i+1)%seasons.size()));
+ }
+
+ std::cout << "one way: ";
+ print_elements(seasons);
+
+ // try swap()
+ std::cout << "other way: ";
+ std::swap(seasons,seasons_orig);
+ print_elements(seasons);
+
+ // try reverse iterators
+ std::cout << "reverse: ";
+ for (boost::array<std::string,4>::reverse_iterator pos
+ =seasons.rbegin(); pos<seasons.rend(); ++pos) {
+ std::cout << " " << *pos;
+ }
+
+ // try constant reverse iterators
+ std::cout << "reverse: ";
+ for (boost::array<std::string,4>::const_reverse_iterator pos
+ =seasons.crbegin(); pos<seasons.crend(); ++pos) {
+ std::cout << " " << *pos;
+ }
+ std::cout << std::endl;
+
+ return 0; // makes Visual-C++ compiler happy
+}
+
+template <class T>
+void print_elements (const T& x)
+{
+ for (unsigned i=0; i<x.size(); ++i) {
+ std::cout << " " << x[i];
+ }
+ std::cout << std::endl;
+}
+
diff --git a/test/array4.cpp b/test/array4.cpp
new file mode 100644
index 0000000..33b9819
--- /dev/null
+++ b/test/array4.cpp
@@ -0,0 +1,43 @@
+/* example for using class array<>
+ * (C) Copyright Nicolai M. Josuttis 2001.
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#include <algorithm>
+#include <functional>
+#include <string>
+#include <iostream>
+#include <boost/array.hpp>
+
+int main()
+{
+ // array of arrays of seasons
+ boost::array<boost::array<std::string,4>,2> seasons_i18n = {
+ { { { "spring", "summer", "autumn", "winter", } },
+ { { "Fruehling", "Sommer", "Herbst", "Winter" } }
+ }
+ };
+
+ // for any array of seasons print seasons
+ for (unsigned i=0; i<seasons_i18n.size(); ++i) {
+ boost::array<std::string,4> seasons = seasons_i18n[i];
+ for (unsigned j=0; j<seasons.size(); ++j) {
+ std::cout << seasons[j] << " ";
+ }
+ std::cout << std::endl;
+ }
+
+ // print first element of first array
+ std::cout << "first element of first array: "
+ << seasons_i18n[0][0] << std::endl;
+
+ // print last element of last array
+ std::cout << "last element of last array: "
+ << seasons_i18n[seasons_i18n.size()-1][seasons_i18n[0].size()-1]
+ << std::endl;
+
+ return 0; // makes Visual-C++ compiler happy
+}
+
diff --git a/test/array5.cpp b/test/array5.cpp
new file mode 100644
index 0000000..23156b9
--- /dev/null
+++ b/test/array5.cpp
@@ -0,0 +1,72 @@
+/* simple example for using class array<>
+ * (C) Copyright Nicolai M. Josuttis 2001.
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#include <iostream>
+#include <boost/array.hpp>
+
+template <typename T>
+void test_static_size (const T& cont)
+{
+ int tmp[T::static_size];
+ for (unsigned i=0; i<T::static_size; ++i) {
+ tmp[i] = int(cont[i]);
+ }
+ for (unsigned j=0; j<T::static_size; ++j) {
+ std::cout << tmp[j] << ' ';
+ }
+ std::cout << std::endl;
+}
+
+int main()
+{
+ // define special type name
+ typedef boost::array<float,6> Array;
+
+ // create and initialize an array
+ const Array a = { { 42.42f } };
+
+ // use some common STL container operations
+ std::cout << "static_size: " << a.size() << std::endl;
+ std::cout << "size: " << a.size() << std::endl;
+ // Can't use std::boolalpha because it isn't portable
+ std::cout << "empty: " << (a.empty()? "true" : "false") << std::endl;
+ std::cout << "max_size: " << a.max_size() << std::endl;
+ std::cout << "front: " << a.front() << std::endl;
+ std::cout << "back: " << a.back() << std::endl;
+ std::cout << "[0]: " << a[0] << std::endl;
+ std::cout << "elems: ";
+
+ // iterate through all elements
+ for (Array::const_iterator pos=a.begin(); pos<a.end(); ++pos) {
+ std::cout << *pos << ' ';
+ }
+ std::cout << std::endl;
+ test_static_size(a);
+
+ // check copy constructor and assignment operator
+ Array b(a);
+ Array c;
+ c = a;
+ if (a==b && a==c) {
+ std::cout << "copy construction and copy assignment are OK"
+ << std::endl;
+ }
+ else {
+ std::cout << "copy construction and copy assignment are BROKEN"
+ << std::endl;
+ }
+
+ typedef boost::array<double,6> DArray;
+ typedef boost::array<int,6> IArray;
+ IArray ia = { { 1, 2, 3, 4, 5, 6 } } ; // extra braces silence GCC warning
+ DArray da;
+ da = ia;
+ da.assign(42);
+
+ return 0; // makes Visual-C++ compiler happy
+}
+
diff --git a/test/array6.cpp b/test/array6.cpp
new file mode 100644
index 0000000..3d737fd
--- /dev/null
+++ b/test/array6.cpp
@@ -0,0 +1,40 @@
+/* tests for using class array<> specialization for size 0
+ * (C) Copyright Alisdair Meredith 2006.
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#include <string>
+#include <iostream>
+#include <boost/array.hpp>
+#include <algorithm>
+
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
+
+namespace {
+ template< class T >
+ void RunTests()
+ {
+ typedef boost::array< T, 5 > test_type;
+ typedef T arr[5];
+ test_type test_case; // = { 1, 1, 2, 3, 5 };
+
+ arr &aRef = get_c_array ( test_case );
+ BOOST_CHECK ( &*test_case.begin () == &aRef[0] );
+
+ const arr &caRef = get_c_array ( test_case );
+ typename test_type::const_iterator iter = test_case.begin ();
+ BOOST_CHECK ( &*iter == &caRef[0] );
+ }
+}
+
+BOOST_AUTO_TEST_CASE( test_main )
+{
+ RunTests< bool >();
+ RunTests< void * >();
+ RunTests< long double >();
+ RunTests< std::string >();
+}
+
diff --git a/test/array7.cpp b/test/array7.cpp
new file mode 100644
index 0000000..de2ebe0
--- /dev/null
+++ b/test/array7.cpp
@@ -0,0 +1,67 @@
+/* tests using std::get on boost:array
+ * (C) Copyright Marshall Clow 2012
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#include <string>
+#include <iostream>
+#include <boost/array.hpp>
+#include <algorithm>
+#ifndef BOOST_NO_CXX11_HDR_ARRAY
+#include <array>
+#endif
+
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
+
+namespace {
+
+ #ifndef BOOST_NO_CXX11_HDR_ARRAY
+ template< class T >
+ void RunStdTests()
+ {
+ typedef boost::array< T, 5 > test_type;
+ typedef T arr[5];
+ test_type test_case; // = { 1, 1, 2, 3, 5 };
+
+ T &aRef = std::get<0> ( test_case );
+ BOOST_CHECK ( &*test_case.begin () == &aRef );
+
+ const T &caRef = std::get<0> ( test_case );
+ BOOST_CHECK ( &*test_case.cbegin () == &caRef );
+ }
+ #endif
+
+ template< class T >
+ void RunBoostTests()
+ {
+ typedef boost::array< T, 5 > test_type;
+ typedef T arr[5];
+ test_type test_case; // = { 1, 1, 2, 3, 5 };
+
+ T &aRef = boost::get<0> ( test_case );
+ BOOST_CHECK ( &*test_case.begin () == &aRef );
+
+ const T &caRef = boost::get<0> ( test_case );
+ BOOST_CHECK ( &*test_case.cbegin () == &caRef );
+ }
+
+}
+
+BOOST_AUTO_TEST_CASE( test_main )
+{
+ RunBoostTests< bool >();
+ RunBoostTests< void * >();
+ RunBoostTests< long double >();
+ RunBoostTests< std::string >();
+
+#ifndef BOOST_NO_CXX11_HDR_ARRAY
+ RunStdTests< bool >();
+ RunStdTests< void * >();
+ RunStdTests< long double >();
+ RunStdTests< std::string >();
+#endif
+}
+
diff --git a/test/array_constexpr.cpp b/test/array_constexpr.cpp
new file mode 100644
index 0000000..927bdec
--- /dev/null
+++ b/test/array_constexpr.cpp
@@ -0,0 +1,42 @@
+/* tests using constexpr on boost:array
+ * (C) Copyright Marshall Clow 2012
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#include <string>
+#include <iostream>
+#include <boost/array.hpp>
+#include <algorithm>
+#ifndef BOOST_NO_CXX11_HDR_ARRAY
+#include <array>
+#endif
+
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
+
+#ifndef BOOST_NO_CXX11_CONSTEXPR
+constexpr boost::array<int, 10> arr {{ 0,1,2,3,4,5,6,7,8,9 }};
+constexpr std::array<int, 10> arr_std {{ 0,1,2,3,4,5,6,7,8,9 }};
+
+template <typename T>
+void sink ( T t ) {}
+
+template <typename T, size_t N>
+void sink ( boost::array<T,N> &arr ) {}
+
+BOOST_AUTO_TEST_CASE( test_main )
+{
+// constexpr int two = arr_std.at (2);
+ constexpr int three = arr.at (3);
+ int whatever [ arr.at(4) ];
+ (void)three;
+ (void) whatever;
+}
+
+#else // no constexpr means no constexpr tests!
+BOOST_AUTO_TEST_CASE( test_main )
+{
+}
+#endif
diff --git a/test/array_getfail1.cpp b/test/array_getfail1.cpp
new file mode 100644
index 0000000..21ae62f
--- /dev/null
+++ b/test/array_getfail1.cpp
@@ -0,0 +1,49 @@
+/* tests using std::get on boost:array
+ * (C) Copyright Marshall Clow 2012
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#include <boost/array.hpp>
+#include <boost/static_assert.hpp>
+
+
+#include <string>
+#include <iostream>
+#include <algorithm>
+#ifndef BOOST_NO_CXX11_HDR_ARRAY
+#include <array>
+#endif
+
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
+
+namespace {
+
+ #ifndef BOOST_NO_CXX11_HDR_ARRAY
+ template< class T >
+ void RunStdTests()
+ {
+ typedef boost::array< T, 5 > test_type;
+ typedef T arr[5];
+ test_type test_case; // = { 1, 1, 2, 3, 5 };
+
+ T &aRef = std::get<5> ( test_case ); // should fail to compile
+ BOOST_CHECK ( &*test_case.begin () == &aRef );
+ }
+ #endif
+
+}
+
+BOOST_AUTO_TEST_CASE( test_main )
+{
+#ifndef BOOST_NO_CXX11_HDR_ARRAY
+ RunStdTests< bool >();
+ RunStdTests< void * >();
+ RunStdTests< long double >();
+ RunStdTests< std::string >();
+#else
+ BOOST_STATIC_ASSERT ( false ); // fail on C++03 systems.
+#endif
+}
diff --git a/test/array_getfail2.cpp b/test/array_getfail2.cpp
new file mode 100644
index 0000000..e2277b0
--- /dev/null
+++ b/test/array_getfail2.cpp
@@ -0,0 +1,64 @@
+/* tests using std::get on boost:array
+ * (C) Copyright Marshall Clow 2012
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#include <string>
+#include <iostream>
+#include <boost/array.hpp>
+#include <algorithm>
+#ifndef BOOST_NO_CXX11_HDR_ARRAY
+#include <array>
+#endif
+
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
+
+namespace {
+
+ #ifndef BOOST_NO_CXX11_HDR_ARRAY
+ template< class T >
+ void RunStdTests()
+ {
+ typedef boost::array< T, 5 > test_type;
+ typedef T arr[5];
+ test_type test_case; // = { 1, 1, 2, 3, 5 };
+
+ T &aRef = std::get<0> ( test_case );
+ BOOST_CHECK ( &*test_case.begin () == &aRef );
+
+ const T &caRef = std::get<0> ( test_case );
+ BOOST_CHECK ( &*test_case.cbegin () == &caRef );
+ }
+ #endif
+
+ template< class T >
+ void RunBoostTests()
+ {
+ typedef boost::array< T, 5 > test_type;
+ typedef T arr[5];
+ test_type test_case; // = { 1, 1, 2, 3, 5 };
+
+ T &aRef = boost::get<5> ( test_case );
+ BOOST_CHECK ( &*test_case.begin () == &aRef );
+ }
+
+}
+
+BOOST_AUTO_TEST_CASE( test_main )
+{
+ RunBoostTests< bool >();
+ RunBoostTests< void * >();
+ RunBoostTests< long double >();
+ RunBoostTests< std::string >();
+
+#ifndef BOOST_NO_CXX11_HDR_ARRAY
+ RunStdTests< bool >();
+ RunStdTests< void * >();
+ RunStdTests< long double >();
+ RunStdTests< std::string >();
+#endif
+}
+
diff --git a/test/array_hash.cpp b/test/array_hash.cpp
new file mode 100644
index 0000000..a83eead
--- /dev/null
+++ b/test/array_hash.cpp
@@ -0,0 +1,43 @@
+/* tests for using boost::hash with boost::array
+ * (C) Copyright Marshall Clow 2012
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#include <string>
+#include <iostream>
+#include <boost/array.hpp>
+#include <algorithm>
+#include <boost/functional/hash.hpp>
+
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
+
+namespace {
+
+ template< class T >
+ void RunTests()
+ {
+ // std::size_t hash0 = boost::hash<boost::array<T,0> > () ( boost::array<T, 0> ());
+ // std::size_t hash1 = boost::hash<boost::array<T,1> > () ( boost::array<T, 1> ());
+
+ typedef boost::array< T, 5 > barr;
+ typedef T arr[5];
+ barr test_barr = {{ 1, 1, 2, 3, 5 }};
+ arr test_arr = { 1, 1, 2, 3, 5 };
+
+ std::size_t bhash = boost::hash<barr> () ( test_barr );
+ std::size_t ahash = boost::hash<arr> () ( test_arr );
+ BOOST_CHECK ( ahash == bhash );
+ }
+
+}
+
+BOOST_AUTO_TEST_CASE( test_main )
+{
+ RunTests< int >();
+ RunTests< long >();
+ RunTests< long double >();
+}
+
diff --git a/test/print.hpp b/test/print.hpp
new file mode 100644
index 0000000..6d68e8e
--- /dev/null
+++ b/test/print.hpp
@@ -0,0 +1,27 @@
+/* The following code example is taken from the book
+ * "The C++ Standard Library - A Tutorial and Reference"
+ * by Nicolai M. Josuttis, Addison-Wesley, 1999
+ *
+ * (C) Copyright Nicolai M. Josuttis 1999.
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ */
+#include <iostream>
+
+/* print_elements()
+ * - prints optional C-string optcstr followed by
+ * - all elements of the collection coll
+ * - separated by spaces
+ */
+template <class T>
+inline void print_elements (const T& coll, const char* optcstr="")
+{
+ typename T::const_iterator pos;
+
+ std::cout << optcstr;
+ for (pos=coll.begin(); pos!=coll.end(); ++pos) {
+ std::cout << *pos << ' ';
+ }
+ std::cout << std::endl;
+}