forked from boostorg/array
Cosmetic changes from Nico
[SVN r7880]
This commit is contained in:
@ -28,7 +28,7 @@
|
|||||||
<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >* This software is provided "as is" without express or implied</FONT></I><BR>
|
<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >* This software is provided "as is" without express or implied</FONT></I><BR>
|
||||||
<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >* warranty, and with no claim as to its suitability for any purpose.</FONT></I><BR>
|
<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >* warranty, and with no claim as to its suitability for any purpose.</FONT></I><BR>
|
||||||
<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*</FONT></I><BR>
|
<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*</FONT></I><BR>
|
||||||
<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >* Jul 31, 2000</FONT></I><BR>
|
<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >* Sep 29, 2000</FONT></I><BR>
|
||||||
<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*/</FONT></I><BR>
|
<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*/</FONT></I><BR>
|
||||||
#ifndef BOOST_ARRAY_HPP<BR>
|
#ifndef BOOST_ARRAY_HPP<BR>
|
||||||
#define BOOST_ARRAY_HPP<BR>
|
#define BOOST_ARRAY_HPP<BR>
|
||||||
@ -38,10 +38,8 @@
|
|||||||
#include <iterator><BR>
|
#include <iterator><BR>
|
||||||
#include <algorithm><BR>
|
#include <algorithm><BR>
|
||||||
<BR>
|
<BR>
|
||||||
<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >// BUG-FIX for compilers that don't support</FONT></I><BR>
|
<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >// FIXES for broken compilers</FONT></I><BR>
|
||||||
<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >// std::size_t and std::ptrdiff_t yet</FONT></I><BR>
|
#include <<A href="./config.hpp.html"><A href="http://www.boost.org/boost/config.hpp">boost/config.hpp</A></A>><BR>
|
||||||
<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >// (such as gcc)</FONT></I><BR>
|
|
||||||
#include <<A href="../../boost/config.hpp">boost/config.hpp</A>><BR>
|
|
||||||
<BR>
|
<BR>
|
||||||
namespace boost {<BR>
|
namespace boost {<BR>
|
||||||
<BR>
|
<BR>
|
||||||
@ -67,8 +65,15 @@ namespace boost {<BR>
|
|||||||
const_iterator end() const { return elems+N; }<BR>
|
const_iterator end() const { return elems+N; }<BR>
|
||||||
<BR>
|
<BR>
|
||||||
<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >// reverse iterator support</FONT></I><BR>
|
<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >// reverse iterator support</FONT></I><BR>
|
||||||
|
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)<BR>
|
||||||
typedef std::reverse_iterator<iterator> reverse_iterator;<BR>
|
typedef std::reverse_iterator<iterator> reverse_iterator;<BR>
|
||||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;<BR>
|
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;<BR>
|
||||||
|
#else<BR>
|
||||||
|
<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >// workaround for broken reverse_iterator implementations due to no partial specialization</FONT></I><BR>
|
||||||
|
typedef std::reverse_iterator<iterator,T> reverse_iterator;<BR>
|
||||||
|
typedef std::reverse_iterator<const_iterator,T> const_reverse_iterator;<BR>
|
||||||
|
#endif<BR>
|
||||||
|
<BR>
|
||||||
reverse_iterator rbegin() { return reverse_iterator(end()); }<BR>
|
reverse_iterator rbegin() { return reverse_iterator(end()); }<BR>
|
||||||
const_reverse_iterator rbegin() const {<BR>
|
const_reverse_iterator rbegin() const {<BR>
|
||||||
return const_reverse_iterator(end());<BR>
|
return const_reverse_iterator(end());<BR>
|
||||||
@ -98,7 +103,6 @@ namespace boost {<BR>
|
|||||||
static size_type max_size() { return N; }<BR>
|
static size_type max_size() { return N; }<BR>
|
||||||
enum { static_size = N };<BR>
|
enum { static_size = N };<BR>
|
||||||
<BR>
|
<BR>
|
||||||
public:<BR>
|
|
||||||
<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >// swap (note: linear complexity)</FONT></I><BR>
|
<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >// swap (note: linear complexity)</FONT></I><BR>
|
||||||
void swap (array<T,N>& y) {<BR>
|
void swap (array<T,N>& y) {<BR>
|
||||||
std::swap_ranges(begin(),end(),y.begin());<BR>
|
std::swap_ranges(begin(),end(),y.begin());<BR>
|
||||||
@ -120,7 +124,9 @@ namespace boost {<BR>
|
|||||||
std::fill_n(begin(),size(),value);<BR>
|
std::fill_n(begin(),size(),value);<BR>
|
||||||
}<BR>
|
}<BR>
|
||||||
<BR>
|
<BR>
|
||||||
|
#ifndef BOOST_NO_PRIVATE_IN_AGGREGATE<BR>
|
||||||
private:<BR>
|
private:<BR>
|
||||||
|
#endif<BR>
|
||||||
<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >// check range (may be private because it is static)</FONT></I><BR>
|
<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >// check range (may be private because it is static)</FONT></I><BR>
|
||||||
static void rangecheck (size_type i) {<BR>
|
static void rangecheck (size_type i) {<BR>
|
||||||
if (i >= size()) { throw std::range_error("array"); }<BR>
|
if (i >= size()) { throw std::range_error("array"); }<BR>
|
||||||
|
199
array.html
199
array.html
@ -1,34 +1,30 @@
|
|||||||
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||||
<meta name="Keywords" content="array, block, carray, c_array, array wrapper, adapter, adaptor, STL, C++ Standard Library, array.hpp">
|
<meta name="Keywords" content="array, block, carray, c_array, array wrapper, adapter, adaptor, STL, C++ Standard Library, array.hpp">
|
||||||
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
|
|
||||||
<meta name="ProgId" content="FrontPage.Editor.Document">
|
|
||||||
<title>array.hpp, an STL Array Wrapper</title>
|
<title>array.hpp, an STL Array Wrapper</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body text="#000000" bgcolor="#FFFFFF" link="#186ABF">
|
<body text="#000000" bgcolor="#FFFFFF" link="#186ABF">
|
||||||
|
|
||||||
<font face="Arial, Helvetica, sans-serif"> </font>
|
<font face="Arial, Helvetica, sans-serif"> </font>
|
||||||
<table width="100%" height="40">
|
<table width="100%" height="40">
|
||||||
<tr>
|
<tr>
|
||||||
<td bgcolor="#DDDDDD"><b><font face="Arial,helvetica" color="#000000" size="+1">Class
|
<td BGCOLOR="#DDDDDD"><b><font face="Arial,helvetica" color="#000000" size="+1">Class
|
||||||
<font face="Courier New, Courier, mono">array</font>, an STL Container (as
|
<font face="Courier New, Courier, mono">array</font>, an STL Container (as
|
||||||
Wrapper) for Arrays of Constant Size</font></b></td>
|
Wrapper) for Arrays of Constant Size</font></b></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<p><font face="Arial, Helvetica, sans-serif" size="-1">The C++ Standard Template
|
<p><font face="Arial, Helvetica, sans-serif" size="-1">The C++ Standard Template
|
||||||
Library STL as part of the C++ Standard Library provides a framework for
|
Library STL as part of the C++ Standard Library provides a framework for processing
|
||||||
processing algorithms on different kind of containers. However, ordinary arrays
|
algorithms on different kind of containers. However, ordinary arrays don't provide
|
||||||
don't provide the interface of STL containers (although, they provide the
|
the interface of STL containers (although, they provide the iterator interface
|
||||||
iterator interface of STL containers).</font>
|
of STL containers).</font>
|
||||||
<p><font face="Arial, Helvetica, sans-serif" size="-1">As replacement for
|
<p><font face="Arial, Helvetica, sans-serif" size="-1">As replacement for ordinary
|
||||||
ordinary arrays, the STL provides class <font face="Courier New, Courier, mono">vector<></font>.
|
arrays, the STL provides class <font face="Courier New, Courier, mono">vector<></font>.
|
||||||
However, <font face="Courier New, Courier, mono">vector<></font> provides
|
However, <font face="Courier New, Courier, mono">vector<></font> provides
|
||||||
the semantics of dynamic arrays. Thus, it manages data to be able to change the
|
the semantics of dynamic arrays. Thus, it manages data to be able to change
|
||||||
number of elements. This results in some overhead in case only arrays with
|
the number of elements. This results in some overhead in case only arrays with
|
||||||
static size are needed.</font>
|
static size are needed.</font>
|
||||||
<p><font face="Arial, Helvetica, sans-serif" size="-1">In his book, <i>Generic
|
<p><font face="Arial, Helvetica, sans-serif" size="-1">In his book, <i>Generic
|
||||||
Programming and the STL</i>, Matthew H. Austern introduces a useful wrapper
|
Programming and the STL</i>, Matthew H. Austern introduces a useful wrapper
|
||||||
@ -36,12 +32,12 @@ class for ordinary arrays with static size, called <font face="Courier New, Cour
|
|||||||
It is safer and has no worse performance than ordinary arrays. In <i>The C++
|
It is safer and has no worse performance than ordinary arrays. In <i>The C++
|
||||||
Programming Language</i>, 3rd edition, Bjarne Stroustrup introduces a similar
|
Programming Language</i>, 3rd edition, Bjarne Stroustrup introduces a similar
|
||||||
class, called <font face="Courier New, Courier, mono"><b>c_array</b></font>,
|
class, called <font face="Courier New, Courier, mono"><b>c_array</b></font>,
|
||||||
which I (<a href="http://www.josuttis.com">Nicolai Josuttis</a>) present
|
which I (<a href="http://www.josuttis.com">Nicolai Josuttis</a>) present slightly
|
||||||
slightly modified in my book <i>The C++ Standard Library - A Tutorial and
|
modified in my book <i>The C++ Standard Library - A Tutorial and Reference</i>,
|
||||||
Reference</i>, called <font face="Courier New, Courier, mono"><b>carray</b></font>.
|
called <font face="Courier New, Courier, mono"><b>carray</b></font>. This is
|
||||||
This is the essence of these approaches spiced with many feedback from <a href="http://www.boost.org">boost</a>.</font>
|
the essence of these approaches spiced with many feedback from <a href="http://www.boost.org">boost</a>.</font>
|
||||||
<p><font face="Arial, Helvetica, sans-serif" size="-1">After considering
|
<p><font face="Arial, Helvetica, sans-serif" size="-1">After considering different
|
||||||
different names, we decided to name this class simply <font face="Courier New, Courier, mono"><b>array</b></font>.</font>
|
names, we decided to name this class simply <font face="Courier New, Courier, mono"><b>array</b></font>.</font>
|
||||||
<p><font face="Arial, Helvetica, sans-serif" size="-1">The class provides the
|
<p><font face="Arial, Helvetica, sans-serif" size="-1">The class provides the
|
||||||
following interface:</font>
|
following interface:</font>
|
||||||
<table border="0">
|
<table border="0">
|
||||||
@ -60,18 +56,17 @@ following interface:</font>
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><font face="Courier New, Courier, mono" size="-1">const_iterator</font></td>
|
<td><font face="Courier New, Courier, mono" size="-1">const_iterator</font></td>
|
||||||
<td><font face="Arial, Helvetica, sans-serif" size="-1">type of iterator
|
<td><font face="Arial, Helvetica, sans-serif" size="-1">type of iterator that
|
||||||
that considers elements as being constant</font></td>
|
considers elements as being constant</font></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><font face="Courier New, Courier, mono" size="-1">reference</font></td>
|
<td><font face="Courier New, Courier, mono" size="-1">reference</font></td>
|
||||||
<td><font face="Arial, Helvetica, sans-serif" size="-1">type of element
|
<td><font face="Arial, Helvetica, sans-serif" size="-1">type of element reference</font></td>
|
||||||
reference</font></td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><font face="Courier New, Courier, mono" size="-1">const_reference</font></td>
|
<td><font face="Courier New, Courier, mono" size="-1">const_reference</font></td>
|
||||||
<td><font face="Arial, Helvetica, sans-serif" size="-1">type of element
|
<td><font face="Arial, Helvetica, sans-serif" size="-1">type of element reference
|
||||||
reference that considers elements as being constant</font></td>
|
that considers elements as being constant</font></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><font face="Courier New, Courier, mono" size="-1">size_type</font></td>
|
<td><font face="Courier New, Courier, mono" size="-1">size_type</font></td>
|
||||||
@ -100,7 +95,8 @@ following interface:</font>
|
|||||||
<td><font face="Courier New, Courier, mono" size="-1">array<<i>type</i>,<i>num</i>>(<i>a</i>)</font></td>
|
<td><font face="Courier New, Courier, mono" size="-1">array<<i>type</i>,<i>num</i>>(<i>a</i>)</font></td>
|
||||||
<td><font face="Arial, Helvetica, sans-serif" size="-1">copy constructor,
|
<td><font face="Arial, Helvetica, sans-serif" size="-1">copy constructor,
|
||||||
copies all elements of <i><font face="Courier New, Courier, mono">a</font></i>
|
copies all elements of <i><font face="Courier New, Courier, mono">a</font></i>
|
||||||
(<i><font face="Courier New, Courier, mono">a</font></i> must have same <i><font face="Courier New, Courier, mono">type</font></i><font face="Courier New, Courier, mono"><font face="Arial, Helvetica, sans-serif">
|
(<i><font face="Courier New, Courier, mono">a</font></i> must have same
|
||||||
|
<i> <font face="Courier New, Courier, mono">type</font></i><font face="Courier New, Courier, mono"><font face="Arial, Helvetica, sans-serif">
|
||||||
and </font></font><i><font face="Courier New, Courier, mono">num</font></i>)</font></td>
|
and </font></font><i><font face="Courier New, Courier, mono">num</font></i>)</font></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@ -125,13 +121,13 @@ following interface:</font>
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><font face="Courier New, Courier, mono" size="-1">rbegin()</font></td>
|
<td><font face="Courier New, Courier, mono" size="-1">rbegin()</font></td>
|
||||||
<td><font face="Arial, Helvetica, sans-serif" size="-1">returns reverse
|
<td><font face="Arial, Helvetica, sans-serif" size="-1">returns reverse iterator
|
||||||
iterator for position of first element of reverse iteration</font></td>
|
for position of first element of reverse iteration</font></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><font face="Courier New, Courier, mono" size="-1">rend()</font></td>
|
<td><font face="Courier New, Courier, mono" size="-1">rend()</font></td>
|
||||||
<td><font face="Arial, Helvetica, sans-serif" size="-1">returns reverse
|
<td><font face="Arial, Helvetica, sans-serif" size="-1">returns reverse iterator
|
||||||
iterator for posistion behind last element of reverese iteration</font></td>
|
for posistion behind last element of reverese iteration </font></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><font face="Courier New, Courier, mono" size="-1">operator[<i>i</i>]</font></td>
|
<td><font face="Courier New, Courier, mono" size="-1">operator[<i>i</i>]</font></td>
|
||||||
@ -142,14 +138,13 @@ following interface:</font>
|
|||||||
<tr>
|
<tr>
|
||||||
<td><font face="Courier New, Courier, mono" size="-1">at(<i>i</i>)</font></td>
|
<td><font face="Courier New, Courier, mono" size="-1">at(<i>i</i>)</font></td>
|
||||||
<td><font face="Arial, Helvetica, sans-serif" size="-1">returns element with
|
<td><font face="Arial, Helvetica, sans-serif" size="-1">returns element with
|
||||||
index <font face="Courier New, Courier, mono"><i>i</i></font> (throw
|
index <font face="Courier New, Courier, mono"><i>i</i></font> (throw std::range_error
|
||||||
std::range_error if <i><font face="Courier New, Courier, mono">i</font></i>
|
if <i><font face="Courier New, Courier, mono">i</font></i> is not valid)</font></td>
|
||||||
is not valid)</font></td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><font face="Courier New, Courier, mono" size="-1">front()</font></td>
|
<td><font face="Courier New, Courier, mono" size="-1">front()</font></td>
|
||||||
<td><font face="Arial, Helvetica, sans-serif" size="-1">returns first
|
<td><font face="Arial, Helvetica, sans-serif" size="-1">returns first element
|
||||||
element (caller has to ensure that it exists)</font></td>
|
(caller has to ensure that it exists)</font></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><font face="Courier New, Courier, mono" size="-1">back()</font></td>
|
<td><font face="Courier New, Courier, mono" size="-1">back()</font></td>
|
||||||
@ -168,13 +163,13 @@ following interface:</font>
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><font face="Courier New, Courier, mono" size="-1">empty()</font></td>
|
<td><font face="Courier New, Courier, mono" size="-1">empty()</font></td>
|
||||||
<td><font face="Arial, Helvetica, sans-serif" size="-1">returns whether
|
<td><font face="Arial, Helvetica, sans-serif" size="-1">returns whether array
|
||||||
array is empty</font></td>
|
is empty</font></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><font face="Courier New, Courier, mono" size="-1">max_size()</font></td>
|
<td><font face="Courier New, Courier, mono" size="-1">max_size()</font></td>
|
||||||
<td><font face="Arial, Helvetica, sans-serif" size="-1">returns maximum
|
<td><font face="Arial, Helvetica, sans-serif" size="-1">returns maximum possible
|
||||||
possible number of elements (same as size())</font></td>
|
number of elements (same as size())</font></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><font face="Courier New, Courier, mono" size="-1">swap(a)</font></td>
|
<td><font face="Courier New, Courier, mono" size="-1">swap(a)</font></td>
|
||||||
@ -198,14 +193,14 @@ following interface:</font>
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><font face="Courier New, Courier, mono" size="-1">static_size</font></td>
|
<td><font face="Courier New, Courier, mono" size="-1">static_size</font></td>
|
||||||
<td><font size="-1" face="Arial, Helvetica, sans-serif">yields size at
|
<td><font size="-1" face="Arial, Helvetica, sans-serif">yields size at compile
|
||||||
compile time</font></td>
|
time</font></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<p><font face="Arial, Helvetica, sans-serif" size="-1">Class array fulfills most
|
<p><font face="Arial, Helvetica, sans-serif" size="-1">Class array fulfills most
|
||||||
but not all of the requirements of "reversible containers" (see
|
but not all of the requirements of "reversible containers" (see Section
|
||||||
Section 23.1, [lib.container.requirements] of the C++ Standard). The reasons
|
23.1, [lib.container.requirements] of the C++ Standard). The reasons array is
|
||||||
array is not an reversible STL container is because:</font><font face="Arial, Helvetica, sans-serif" size="-1"><br>
|
not an reversible STL container is because: </font> <font face="Arial, Helvetica, sans-serif" size="-1"><br>
|
||||||
- No constructors are provided<br>
|
- No constructors are provided<br>
|
||||||
- Elements may have an indetermined initial value (see below)<br>
|
- Elements may have an indetermined initial value (see below)<br>
|
||||||
- swap() has no constant complexity<br>
|
- swap() has no constant complexity<br>
|
||||||
@ -216,40 +211,37 @@ requirements of a "sequence" (see Section 23.1.1, [lib.sequence.reqmts
|
|||||||
of the C++ Standard), except that</font> <font face="Arial, Helvetica, sans-serif" size="-1"><br>
|
of the C++ Standard), except that</font> <font face="Arial, Helvetica, sans-serif" size="-1"><br>
|
||||||
- front() and back() are provided<br>
|
- front() and back() are provided<br>
|
||||||
- operator[] and at() are provided</font>
|
- operator[] and at() are provided</font>
|
||||||
<p><font face="Arial, Helvetica, sans-serif" size="-1">Regarding the
|
<p><font face="Arial, Helvetica, sans-serif" size="-1">Regarding the constructors
|
||||||
constructors there was an important design tradeoff: We could implement array as
|
there was an important design tradeoff: We could implement array as an "<b>aggregate</b>"
|
||||||
an "<b>aggregate</b>" (see Section 8.5.1, [dcl.init.aggr], of the C++
|
(see Section 8.5.1, [dcl.init.aggr], of the C++ Standard). This would mean:</font></p>
|
||||||
Standard). This would mean:</font></p>
|
|
||||||
<ul>
|
<ul>
|
||||||
<li><font face="Arial, Helvetica, sans-serif" size="-1">An array can be
|
<li><font face="Arial, Helvetica, sans-serif" size="-1">An array can be initialized
|
||||||
initialized with a brace-enclosing, comma-separated list of initializers for
|
with a brace-enclosing, comma-separated list of initializers for the elements
|
||||||
the elements of the container, written in increasing subscript order:</font>
|
of the container, written in increasing subscript order:</font>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p><font face="Arial, Helvetica, sans-serif" size="-1">boost::array<int,4>
|
<p><font face="Arial, Helvetica, sans-serif" size="-1">boost::array<int,4>
|
||||||
a = { { 1, 2, 3 } };</font></p>
|
a = { { 1, 2, 3 } };</font></p>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
<p><font face="Arial, Helvetica, sans-serif" size="-1">Note that if there
|
<p><font face="Arial, Helvetica, sans-serif" size="-1">Note that if there
|
||||||
are fewer elements in the initializer list, then each remaining element gets
|
are fewer elements in the initializer list, then each remaining element
|
||||||
default-initialized (thus, it has a defined value).</font></p>
|
gets default-initialized (thus, it has a defined value).</font></p>
|
||||||
</li>
|
</li>
|
||||||
<li><font face="Arial, Helvetica, sans-serif" size="-1">However, <b>passing no
|
<li><font face="Arial, Helvetica, sans-serif" size="-1">However, <b>passing
|
||||||
initializer list means that the elements have an indetermined initial value</b>.</font></li>
|
no initializer list means that the elements have an indetermined initial value</b>.</font></li>
|
||||||
<li><font face="Arial, Helvetica, sans-serif" size="-1">It has no
|
<li><font face="Arial, Helvetica, sans-serif" size="-1">It has no user-declared
|
||||||
user-declared constructors.</font></li>
|
constructors.</font></li>
|
||||||
<li><font face="Arial, Helvetica, sans-serif" size="-1">It has no private or
|
<li><font face="Arial, Helvetica, sans-serif" size="-1">It has no private or
|
||||||
protected non-static data members.</font></li>
|
protected non-static data members.</font></li>
|
||||||
<li><font face="Arial, Helvetica, sans-serif" size="-1">It has no base
|
<li><font face="Arial, Helvetica, sans-serif" size="-1">It has no base classes.</font></li>
|
||||||
classes.</font></li>
|
<li><font face="Arial, Helvetica, sans-serif" size="-1">It has no virtual functions.</font></li>
|
||||||
<li><font face="Arial, Helvetica, sans-serif" size="-1">It has no virtual
|
|
||||||
functions.</font></li>
|
|
||||||
</ul>
|
</ul>
|
||||||
<p><font face="Arial, Helvetica, sans-serif" size="-1">The current
|
<p><font face="Arial, Helvetica, sans-serif" size="-1">The current implementation
|
||||||
implementation useus this approach. However, being able to have indetermined
|
useus this approach. However, being able to have indetermined initial values
|
||||||
initial values is a big drawback. So, please give me some feedback, how useful
|
is a big drawback. So, please give me some feedback, how useful you consider
|
||||||
you consider this feature to be. This leads to the list of <b>Open issues:</b></font>
|
this feature to be. This leads to the list of <b>Open issues:</b></font>
|
||||||
<ul>
|
<ul>
|
||||||
<li><font face="Arial, Helvetica, sans-serif">Do we want initializer list
|
<li><font face="Arial, Helvetica, sans-serif">Do we want initializer list support
|
||||||
support or would the following be OK?:</font>
|
or would the following be OK?:</font>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p><font face="Courier New, Courier, mono">int data[] = { 1, 2, 3, 4 }</font></p>
|
<p><font face="Courier New, Courier, mono">int data[] = { 1, 2, 3, 4 }</font></p>
|
||||||
<p><font face="Courier New, Courier, mono">array<int,5> x(data); <font face="Arial, Helvetica, sans-serif">or
|
<p><font face="Courier New, Courier, mono">array<int,5> x(data); <font face="Arial, Helvetica, sans-serif">or
|
||||||
@ -264,52 +256,65 @@ you consider this feature to be. This leads to the list of <b>Open issues:</b></
|
|||||||
<p><font face="Arial, Helvetica, sans-serif">8.5.1 (11) of the Standard seem
|
<p><font face="Arial, Helvetica, sans-serif">8.5.1 (11) of the Standard seem
|
||||||
to allow it; however, gcc 2.95.2 printa warning message.</font></p>
|
to allow it; however, gcc 2.95.2 printa warning message.</font></p>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
<li><font face="Arial, Helvetica, sans-serif">Any way to have determined
|
<li><font face="Arial, Helvetica, sans-serif">Any way to have determined initial
|
||||||
initial values and initializer list support?</font></li>
|
values and initializer list support?</font></li>
|
||||||
<li><font face="Arial, Helvetica, sans-serif">Static_casts for reverse
|
<li><font face="Arial, Helvetica, sans-serif">Static_casts for reverse iterator
|
||||||
iterator stuff</font><font face="Arial, Helvetica, sans-serif">?</font></li>
|
stuff</font><font face="Arial, Helvetica, sans-serif">?</font></li>
|
||||||
</ul>
|
</ul>
|
||||||
<p><font face="Arial, Helvetica, sans-serif">I'd appreciate any constructive <a href="mailto:solutions@josuttis.com">feedback</a>.
|
<p><font face="Arial, Helvetica, sans-serif">I'd appreciate any constructive <a href="mailto:solutions@josuttis.com">feedback</a>.
|
||||||
<b>Please note: I don't have time to read all boost mails. Thus, to make sure
|
<b>Please note: I don't have time to read all boost mails. Thus, to make sure
|
||||||
that feedback arrives me, please send me a copy of each mail regarding this
|
that feedback arrives me, please send me a copy of each mail regarding this
|
||||||
class.</b></font>
|
class.</b></font>
|
||||||
<p><font face="Arial, Helvetica, sans-serif">The code is provided "as
|
<p><font face="Arial, Helvetica, sans-serif">The code is provided "as is" without
|
||||||
is" without expressed or implied warranty.</font>
|
expressed or implied warranty.</font>
|
||||||
<p><font face="Arial, Helvetica, sans-serif"><b>array.hpp</b>, the
|
<p><font face="Arial, Helvetica, sans-serif"><b>array.hpp</b>, the implementation
|
||||||
implementation of <font face="Courier New, Courier, mono">array<></font><b>:</b>
|
of <font face="Courier New, Courier, mono">array<></font><b>:</b> </font>
|
||||||
</font><font face="Arial, Helvetica, sans-serif"><a href="array.hpp.html">as
|
<li><font face="Arial, Helvetica, sans-serif">
|
||||||
HTML file</a></font> <font face="Arial, Helvetica, sans-serif"><a href="../../boost/array.hpp">as
|
<a href="array.hpp.html">as HTML file</a></font></li>
|
||||||
plain file</a></font>
|
<li><font face="Arial, Helvetica, sans-serif">
|
||||||
|
<a href="array.hpp">as plain file</a></font></li>
|
||||||
<p> <font face="Arial, Helvetica, sans-serif">Simple Example for using <font face="Courier New, Courier, mono">array<><font face="Arial, Helvetica, sans-serif">:</font></font></font>
|
<p> <font face="Arial, Helvetica, sans-serif">Simple Example for using <font face="Courier New, Courier, mono">array<><font face="Arial, Helvetica, sans-serif">:</font></font></font>
|
||||||
<font face="Arial, Helvetica, sans-serif"><a href="array1.cpp.html">as HTML file</a></font>
|
<li><font face="Arial, Helvetica, sans-serif">
|
||||||
<font face="Arial, Helvetica, sans-serif"><a href="array1.cpp">as plain file</a></font>
|
<a href="array1.cpp.html">as HTML file</a></font> </li>
|
||||||
|
<li><font face="Arial, Helvetica, sans-serif">
|
||||||
|
<a href="array1.cpp">as plain file</a></font></li>
|
||||||
<p> <font face="Arial, Helvetica, sans-serif">Another Example for using <font face="Courier New, Courier, mono">array<><font face="Arial, Helvetica, sans-serif">:</font></font></font>
|
<p> <font face="Arial, Helvetica, sans-serif">Another Example for using <font face="Courier New, Courier, mono">array<><font face="Arial, Helvetica, sans-serif">:</font></font></font>
|
||||||
<font face="Arial, Helvetica, sans-serif"><a href="array2.cpp.html">as HTML file</a></font>
|
<li><font face="Arial, Helvetica, sans-serif">
|
||||||
<font face="Arial, Helvetica, sans-serif"><a href="array2.cpp">as plain file</a></font>
|
<a href="array2.cpp.html">as HTML file</a></font></li>
|
||||||
|
<li><font face="Arial, Helvetica, sans-serif">
|
||||||
|
<a href="array2.cpp">as plain file</a></font></li>
|
||||||
<p> <font face="Arial, Helvetica, sans-serif">A third Example for using <font face="Courier New, Courier, mono">array<><font face="Arial, Helvetica, sans-serif">:</font></font></font>
|
<p> <font face="Arial, Helvetica, sans-serif">A third Example for using <font face="Courier New, Courier, mono">array<><font face="Arial, Helvetica, sans-serif">:</font></font></font>
|
||||||
<font face="Arial, Helvetica, sans-serif"><a href="array3.cpp.html">as HTML file</a></font>
|
<li><font face="Arial, Helvetica, sans-serif">
|
||||||
<font face="Arial, Helvetica, sans-serif"><a href="array3.cpp">as plain file</a></font>
|
<a href="array3.cpp.html">as HTML file</a></font></li>
|
||||||
|
<li><font face="Arial, Helvetica, sans-serif">
|
||||||
|
<a href="array3.cpp">as plain file</a></font></li>
|
||||||
<p> <font face="Arial, Helvetica, sans-serif">An Example for using <font face="Courier New, Courier, mono">array</font>s
|
<p> <font face="Arial, Helvetica, sans-serif">An Example for using <font face="Courier New, Courier, mono">array</font>s
|
||||||
of <font face="Courier New, Courier, mono">array</font>s<font face="Courier New, Courier, mono"><font face="Arial, Helvetica, sans-serif">:</font></font></font>
|
of <font face="Courier New, Courier, mono">array</font>s<font face="Courier New, Courier, mono"><font face="Arial, Helvetica, sans-serif">:</font></font></font>
|
||||||
<font face="Arial, Helvetica, sans-serif"><a href="array4.cpp.html">as HTML file</a></font>
|
<li><font face="Arial, Helvetica, sans-serif"> <a href="array4.cpp.html">as HTML
|
||||||
<font face="Arial, Helvetica, sans-serif"><a href="array4.cpp">as plain file</a></font>
|
file</a></font></li>
|
||||||
<p><font face="Arial, Helvetica, sans-serif">An Example for testing other
|
<li><font face="Arial, Helvetica, sans-serif"> <a href="array4.cpp">as plain file</a></font></li>
|
||||||
operations of <font face="Courier New, Courier, mono">array<></font><font face="Courier New, Courier, mono"><font face="Arial, Helvetica, sans-serif">:</font></font></font>
|
<p><font face="Arial, Helvetica, sans-serif">An Example for testing other operations
|
||||||
<font face="Arial, Helvetica, sans-serif"><a href="array5.cpp.html">as HTML file</a></font>
|
of <font face="Courier New, Courier, mono">array<></font><font face="Courier New, Courier, mono"><font face="Arial, Helvetica, sans-serif">:</font></font></font>
|
||||||
<font face="Arial, Helvetica, sans-serif"><a href="array5.cpp">as plain file</a></font>
|
<li><font face="Arial, Helvetica, sans-serif"> <a href="array5.cpp.html">as HTML
|
||||||
<p><font face="Arial, Helvetica, sans-serif">To find more details about using
|
file</a></font></li>
|
||||||
ordinary arrays in C++ and the framework of the STL, see e.g.</font><font face="Arial, Helvetica, sans-serif"><br>
|
<li><font face="Arial, Helvetica, sans-serif"> <a href="array5.cpp">as plain file</a></font></li>
|
||||||
|
<p><b><font face="Arial, Helvetica, sans-serif">All files</font></b>
|
||||||
|
<li><font face="Arial, Helvetica, sans-serif"> <a href="array.zip">as ZIP file
|
||||||
|
(24KB)</a></font></li>
|
||||||
|
<li><font face="Arial, Helvetica, sans-serif"> <a href="array.tgz">as TGZ file
|
||||||
|
(13KB)</a><br>
|
||||||
|
<br>
|
||||||
|
To find more details about using ordinary arrays in C++ and the framework of
|
||||||
|
the STL, see e.g.</font> <font face="Arial, Helvetica, sans-serif"><br>
|
||||||
<i> <a href="http://www.josuttis.com/libbook/">The C++
|
<i> <a href="http://www.josuttis.com/libbook/">The C++
|
||||||
Standard Library - A Tutorial and Reference</a></i> <br>
|
Standard Library - A Tutorial and Reference</a></i> <br>
|
||||||
by <a href="http://www.josuttis.com" target="_top">Nicolai
|
by <a href="http://www.josuttis.com" target="_top">Nicolai
|
||||||
M. Josuttis</a></font> <font face="Arial, Helvetica, sans-serif"><br>
|
M. Josuttis</a></font> <font face="Arial, Helvetica, sans-serif"><br>
|
||||||
Addison Wesley Longman, 1999</font> <font face="Arial, Helvetica, sans-serif"><br>
|
Addison Wesley Longman, 1999</font> <font face="Arial, Helvetica, sans-serif"><br>
|
||||||
ISBN 0-201-37926-0</font> <font face="Arial, Helvetica, sans-serif"><br>
|
ISBN 0-201-37926-0</font> <font face="Arial, Helvetica, sans-serif"><br>
|
||||||
</font>
|
</font></li>
|
||||||
<p><font face="Arial, Helvetica, sans-serif"><a href="http://www.josuttis.com/" target="_top">Home
|
<p><font face="Arial, Helvetica, sans-serif"><a href="http://www.josuttis.com/" TARGET="_top">Home
|
||||||
Page of Nicolai Josuttis</a></font> <font face="Arial, Helvetica, sans-serif"><br>
|
Page of Nicolai Josuttis</a></font> <font face="Arial, Helvetica, sans-serif"><br>
|
||||||
</font>
|
</font>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
@ -39,7 +39,7 @@ int main()
|
|||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
std::cout << "copy construction and copy assignment are OK"
|
std::cout << "copy construction and copy assignment FAILED"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ int main()<BR>
|
|||||||
<< std::endl;<BR>
|
<< std::endl;<BR>
|
||||||
}<BR>
|
}<BR>
|
||||||
else {<BR>
|
else {<BR>
|
||||||
std::cout << "copy construction and copy assignment are OK"<BR>
|
std::cout << "copy construction and copy assignment FAILED"<BR>
|
||||||
<< std::endl;<BR>
|
<< std::endl;<BR>
|
||||||
}<BR>
|
}<BR>
|
||||||
}<BR>
|
}<BR>
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
* This software is provided "as is" without express or implied
|
* This software is provided "as is" without express or implied
|
||||||
* warranty, and with no claim as to its suitability for any purpose.
|
* warranty, and with no claim as to its suitability for any purpose.
|
||||||
*
|
*
|
||||||
* Jul 31, 2000
|
* Sep 29, 2000
|
||||||
*/
|
*/
|
||||||
#ifndef BOOST_ARRAY_HPP
|
#ifndef BOOST_ARRAY_HPP
|
||||||
#define BOOST_ARRAY_HPP
|
#define BOOST_ARRAY_HPP
|
||||||
@ -21,9 +21,7 @@
|
|||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
// BUG-FIX for compilers that don't support
|
// FIXES for broken compilers
|
||||||
// std::size_t and std::ptrdiff_t yet
|
|
||||||
// (such as gcc)
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
@ -88,7 +86,6 @@ namespace boost {
|
|||||||
static size_type max_size() { return N; }
|
static size_type max_size() { return N; }
|
||||||
enum { static_size = N };
|
enum { static_size = N };
|
||||||
|
|
||||||
public:
|
|
||||||
// swap (note: linear complexity)
|
// swap (note: linear complexity)
|
||||||
void swap (array<T,N>& y) {
|
void swap (array<T,N>& y) {
|
||||||
std::swap_ranges(begin(),end(),y.begin());
|
std::swap_ranges(begin(),end(),y.begin());
|
||||||
@ -113,7 +110,7 @@ namespace boost {
|
|||||||
#ifndef BOOST_NO_PRIVATE_IN_AGGREGATE
|
#ifndef BOOST_NO_PRIVATE_IN_AGGREGATE
|
||||||
private:
|
private:
|
||||||
#endif
|
#endif
|
||||||
// private member functions are allowed in aggregates [ISO 8.5.1]
|
// check range (may be private because it is static)
|
||||||
static void rangecheck (size_type i) {
|
static void rangecheck (size_type i) {
|
||||||
if (i >= size()) { throw std::range_error("array"); }
|
if (i >= size()) { throw std::range_error("array"); }
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user