Compare commits

..

1 Commits

Author SHA1 Message Date
54b65a0d7c This commit was manufactured by cvs2svn to create tag
'Version_1_18_0'.

[SVN r7873]
2000-09-29 11:39:43 +00:00
16 changed files with 265 additions and 316 deletions

View File

@ -19,16 +19,16 @@
&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;an&nbsp;STL&nbsp;container&nbsp;(as&nbsp;wrapper)&nbsp;for&nbsp;arrays&nbsp;of&nbsp;constant&nbsp;size.</FONT></I><BR> &nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;an&nbsp;STL&nbsp;container&nbsp;(as&nbsp;wrapper)&nbsp;for&nbsp;arrays&nbsp;of&nbsp;constant&nbsp;size.</FONT></I><BR>
&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*</FONT></I><BR> &nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*</FONT></I><BR>
&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;See</FONT></I><BR> &nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;See</FONT></I><BR>
&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://www.josuttis.com/cppcode">http://www.josuttis.com/cppcode</a></FONT></I><BR> &nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;http://www.josuttis.com/cppcode</FONT></I><BR>
&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;for&nbsp;details&nbsp;and&nbsp;the&nbsp;latest&nbsp;version.</FONT></I><BR> &nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;for&nbsp;details&nbsp;and&nbsp;the&nbsp;latest&nbsp;version.</FONT></I><BR>
&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*</FONT></I><BR> &nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*</FONT></I><BR>
&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;(C)&nbsp;Copyright&nbsp;Nicolai&nbsp;M.&nbsp;Josuttis&nbsp;2001.</FONT></I><BR> &nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;(C)&nbsp;Copyright&nbsp;Nicolai&nbsp;M.&nbsp;Josuttis&nbsp;1999.</FONT></I><BR>
&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;Permission&nbsp;to&nbsp;copy,&nbsp;use,&nbsp;modify,&nbsp;sell&nbsp;and&nbsp;distribute&nbsp;this&nbsp;software</FONT></I><BR> &nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;Permission&nbsp;to&nbsp;copy,&nbsp;use,&nbsp;modify,&nbsp;sell&nbsp;and&nbsp;distribute&nbsp;this&nbsp;software</FONT></I><BR>
&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;is&nbsp;granted&nbsp;provided&nbsp;this&nbsp;copyright&nbsp;notice&nbsp;appears&nbsp;in&nbsp;all&nbsp;copies.</FONT></I><BR> &nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;is&nbsp;granted&nbsp;provided&nbsp;this&nbsp;copyright&nbsp;notice&nbsp;appears&nbsp;in&nbsp;all&nbsp;copies.</FONT></I><BR>
&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;This&nbsp;software&nbsp;is&nbsp;provided&nbsp;"as&nbsp;is"&nbsp;without&nbsp;express&nbsp;or&nbsp;implied</FONT></I><BR> &nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;This&nbsp;software&nbsp;is&nbsp;provided&nbsp;"as&nbsp;is"&nbsp;without&nbsp;express&nbsp;or&nbsp;implied</FONT></I><BR>
&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;warranty,&nbsp;and&nbsp;with&nbsp;no&nbsp;claim&nbsp;as&nbsp;to&nbsp;its&nbsp;suitability&nbsp;for&nbsp;any&nbsp;purpose.</FONT></I><BR> &nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;warranty,&nbsp;and&nbsp;with&nbsp;no&nbsp;claim&nbsp;as&nbsp;to&nbsp;its&nbsp;suitability&nbsp;for&nbsp;any&nbsp;purpose.</FONT></I><BR>
&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*</FONT></I><BR> &nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*</FONT></I><BR>
&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;Aug&nbsp;05,&nbsp;2001</FONT></I><BR> &nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;Jul&nbsp;31,&nbsp;2000</FONT></I><BR>
&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*/</FONT></I><BR> &nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*/</FONT></I><BR>
#ifndef&nbsp;BOOST_ARRAY_HPP<BR> #ifndef&nbsp;BOOST_ARRAY_HPP<BR>
#define&nbsp;BOOST_ARRAY_HPP<BR> #define&nbsp;BOOST_ARRAY_HPP<BR>
@ -38,7 +38,9 @@
#include&nbsp;&lt;iterator&gt;<BR> #include&nbsp;&lt;iterator&gt;<BR>
#include&nbsp;&lt;algorithm&gt;<BR> #include&nbsp;&lt;algorithm&gt;<BR>
<BR> <BR>
<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;FIXES&nbsp;for&nbsp;broken&nbsp;compilers</FONT></I><BR> <I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;BUG-FIX&nbsp;for&nbsp;compilers&nbsp;that&nbsp;don't&nbsp;support</FONT></I><BR>
<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;std::size_t&nbsp;and&nbsp;std::ptrdiff_t&nbsp;yet</FONT></I><BR>
<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;(such&nbsp;as&nbsp;gcc)</FONT></I><BR>
#include&nbsp;&lt;<A href="../../boost/config.hpp">boost/config.hpp</A>&gt;<BR> #include&nbsp;&lt;<A href="../../boost/config.hpp">boost/config.hpp</A>&gt;<BR>
<BR> <BR>
namespace&nbsp;boost&nbsp;{<BR> namespace&nbsp;boost&nbsp;{<BR>
@ -65,15 +67,8 @@ namespace&nbsp;boost&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;const_iterator&nbsp;end()&nbsp;const&nbsp;{&nbsp;return&nbsp;elems+N;&nbsp;}<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;const_iterator&nbsp;end()&nbsp;const&nbsp;{&nbsp;return&nbsp;elems+N;&nbsp;}<BR>
<BR> <BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;reverse&nbsp;iterator&nbsp;support</FONT></I><BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;reverse&nbsp;iterator&nbsp;support</FONT></I><BR>
#if&nbsp;!defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)&nbsp;&&&nbsp;!defined(BOOST_MSVC_STD_ITERATOR)<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;typedef&nbsp;std::reverse_iterator&lt;iterator&gt;&nbsp;reverse_iterator;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;typedef&nbsp;std::reverse_iterator&lt;iterator&gt;&nbsp;reverse_iterator;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;typedef&nbsp;std::reverse_iterator&lt;const_iterator&gt;&nbsp;const_reverse_iterator;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;typedef&nbsp;std::reverse_iterator&lt;const_iterator&gt;&nbsp;const_reverse_iterator;<BR>
#else<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;workaround&nbsp;for&nbsp;broken&nbsp;reverse_iterator&nbsp;implementations</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;typedef&nbsp;std::reverse_iterator&lt;iterator,T&gt;&nbsp;reverse_iterator;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;typedef&nbsp;std::reverse_iterator&lt;const_iterator,T&gt;&nbsp;const_reverse_iterator;<BR>
#endif<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;reverse_iterator&nbsp;rbegin()&nbsp;{&nbsp;return&nbsp;reverse_iterator(end());&nbsp;}<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;reverse_iterator&nbsp;rbegin()&nbsp;{&nbsp;return&nbsp;reverse_iterator(end());&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;const_reverse_iterator&nbsp;rbegin()&nbsp;const&nbsp;{<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;const_reverse_iterator&nbsp;rbegin()&nbsp;const&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;const_reverse_iterator(end());<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;const_reverse_iterator(end());<BR>
@ -103,6 +98,7 @@ namespace&nbsp;boost&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;static&nbsp;size_type&nbsp;max_size()&nbsp;{&nbsp;return&nbsp;N;&nbsp;}<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;static&nbsp;size_type&nbsp;max_size()&nbsp;{&nbsp;return&nbsp;N;&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;enum&nbsp;{&nbsp;static_size&nbsp;=&nbsp;N&nbsp;};<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;enum&nbsp;{&nbsp;static_size&nbsp;=&nbsp;N&nbsp;};<BR>
<BR> <BR>
&nbsp;&nbsp;public:<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;swap&nbsp;(note:&nbsp;linear&nbsp;complexity)</FONT></I><BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;swap&nbsp;(note:&nbsp;linear&nbsp;complexity)</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;void&nbsp;swap&nbsp;(array&lt;T,N&gt;&&nbsp;y)&nbsp;{<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;void&nbsp;swap&nbsp;(array&lt;T,N&gt;&&nbsp;y)&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;std::swap_ranges(begin(),end(),y.begin());<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;std::swap_ranges(begin(),end(),y.begin());<BR>
@ -124,9 +120,7 @@ namespace&nbsp;boost&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;std::fill_n(begin(),size(),value);<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;std::fill_n(begin(),size(),value);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>
<BR> <BR>
#ifndef&nbsp;BOOST_NO_PRIVATE_IN_AGGREGATE<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;private:<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;private:<BR>
#endif<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;check&nbsp;range&nbsp;(may&nbsp;be&nbsp;private&nbsp;because&nbsp;it&nbsp;is&nbsp;static)</FONT></I><BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;check&nbsp;range&nbsp;(may&nbsp;be&nbsp;private&nbsp;because&nbsp;it&nbsp;is&nbsp;static)</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;static&nbsp;void&nbsp;rangecheck&nbsp;(size_type&nbsp;i)&nbsp;{<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;static&nbsp;void&nbsp;rangecheck&nbsp;(size_type&nbsp;i)&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(i&nbsp;&gt;=&nbsp;size())&nbsp;{&nbsp;throw&nbsp;std::range_error("array");&nbsp;}<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(i&nbsp;&gt;=&nbsp;size())&nbsp;{&nbsp;throw&nbsp;std::range_error("array");&nbsp;}<BR>

View File

@ -1,33 +1,34 @@
<!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">&nbsp;</font> <font face="Arial, Helvetica, sans-serif">&nbsp;</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 size="-1" face="Arial, Helvetica, sans-serif">[<a href="#intro">intro</a>] <p><font face="Arial, Helvetica, sans-serif" size="-1">The C++ Standard Template
[<a href="#interface">interface</a>] [<a href="#discussion">discussion</a>] Library STL as part of the C++ Standard Library provides a framework for
[<a href="#code">code</a>]</font> processing algorithms on different kind of containers. However, ordinary arrays
<p><font face="Arial, Helvetica, sans-serif" size="-1"><a name="intro"></a>The don't provide the interface of STL containers (although, they provide the
C++ Standard Template Library STL as part of the C++ Standard Library provides iterator interface of STL containers).</font>
a framework for processing algorithms on different kind of containers. However, <p><font face="Arial, Helvetica, sans-serif" size="-1">As replacement for
ordinary arrays don't provide the interface of STL containers (although, they ordinary arrays, the STL provides class <font face="Courier New, Courier, mono">vector&lt;&gt;</font>.
provide the iterator interface of STL containers).</font>
<p><font face="Arial, Helvetica, sans-serif" size="-1">As replacement for ordinary
arrays, the STL provides class <font face="Courier New, Courier, mono">vector&lt;&gt;</font>.
However, <font face="Courier New, Courier, mono">vector&lt;&gt;</font> provides However, <font face="Courier New, Courier, mono">vector&lt;&gt;</font> provides
the semantics of dynamic arrays. Thus, it manages data to be able to change the semantics of dynamic arrays. Thus, it manages data to be able to change the
the number of elements. This results in some overhead in case only arrays with 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
@ -35,14 +36,14 @@
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 slightly which I (<a href="http://www.josuttis.com">Nicolai Josuttis</a>) present
modified in my book <i>The C++ Standard Library - A Tutorial and Reference</i>, slightly modified in my book <i>The C++ Standard Library - A Tutorial and
called <font face="Courier New, Courier, mono"><b>carray</b></font>. This is Reference</i>, called <font face="Courier New, Courier, mono"><b>carray</b></font>.
the essence of these approaches spiced with many feedback from <a href="http://www.boost.org">boost</a>.</font> This is 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 different <p><font face="Arial, Helvetica, sans-serif" size="-1">After considering
names, we decided to name this class simply <font face="Courier New, Courier, mono"><b>array</b></font>.</font> different 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"><a name="interface"></a>The <p><font face="Arial, Helvetica, sans-serif" size="-1">The class provides the
class provides the following interface:</font> following interface:</font>
<table border="0"> <table border="0">
<tr> <tr>
<td><font face="Arial, Helvetica, sans-serif" size="-1"><b>Types:</b></font></td> <td><font face="Arial, Helvetica, sans-serif" size="-1"><b>Types:</b></font></td>
@ -59,17 +60,18 @@
</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 that <td><font face="Arial, Helvetica, sans-serif" size="-1">type of iterator
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">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 reference</font></td> <td><font face="Arial, Helvetica, sans-serif" size="-1">type of element
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 reference <td><font face="Arial, Helvetica, sans-serif" size="-1">type of element
that considers elements as being constant</font></td> reference 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>
@ -98,8 +100,7 @@
<td><font face="Courier New, Courier, mono" size="-1">array&lt;<i>type</i>,<i>num</i>&gt;(<i>a</i>)</font></td> <td><font face="Courier New, Courier, mono" size="-1">array&lt;<i>type</i>,<i>num</i>&gt;(<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">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">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>
@ -124,13 +125,13 @@
</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 iterator <td><font face="Arial, Helvetica, sans-serif" size="-1">returns reverse
for position of first element of reverse iteration</font></td> iterator 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 iterator <td><font face="Arial, Helvetica, sans-serif" size="-1">returns reverse
for position behind last element of reverse iteration </font></td> iterator 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>
@ -141,13 +142,14 @@
<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 std::range_error index <font face="Courier New, Courier, mono"><i>i</i></font> (throw
if <i><font face="Courier New, Courier, mono">i</font></i> is not valid)</font></td> std::range_error if <i><font face="Courier New, Courier, mono">i</font></i>
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 element <td><font face="Arial, Helvetica, sans-serif" size="-1">returns first
(caller has to ensure that it exists)</font></td> element (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>
@ -166,13 +168,13 @@
</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 array <td><font face="Arial, Helvetica, sans-serif" size="-1">returns whether
is empty</font></td> array 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 possible <td><font face="Arial, Helvetica, sans-serif" size="-1">returns maximum
number of elements (same as size())</font></td> possible 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>
@ -196,16 +198,16 @@
</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 compile <td><font size="-1" face="Arial, Helvetica, sans-serif">yields size at
time</font></td> compile time</font></td>
</tr> </tr>
</table> </table>
<p><font face="Arial, Helvetica, sans-serif" size="-1"><a name="discussion"></a>Class <p><font face="Arial, Helvetica, sans-serif" size="-1">Class array fulfills most
array fulfills most but not all of the requirements of &quot;reversible containers&quot; but not all of the requirements of &quot;reversible containers&quot; (see
(see Section 23.1, [lib.container.requirements] of the C++ Standard). The reasons Section 23.1, [lib.container.requirements] of the C++ Standard). The reasons
array is not an reversible STL container is because:</font><font face="Arial, Helvetica, sans-serif" size="-1"><br> array is 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 undetermined 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>
- size() is always constant, based on the second template argument of the type<br> - size() is always constant, based on the second template argument of the type<br>
- The container provides no allocator support</font> - The container provides no allocator support</font>
@ -214,117 +216,100 @@
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 constructors <p><font face="Arial, Helvetica, sans-serif" size="-1">Regarding the
there was an important design tradeoff: We could implement array as an &quot;<b>aggregate</b>&quot; constructors there was an important design tradeoff: We could implement array as
(see Section 8.5.1, [dcl.init.aggr], of the C++ Standard). This would mean:</font></p> an &quot;<b>aggregate</b>&quot; (see Section 8.5.1, [dcl.init.aggr], of the C++
Standard). This would mean:</font></p>
<ul> <ul>
<li><font face="Arial, Helvetica, sans-serif" size="-1">An array can be initialized <li><font face="Arial, Helvetica, sans-serif" size="-1">An array can be
with a brace-enclosing, comma-separated list of initializers for the elements initialized with a brace-enclosing, comma-separated list of initializers for
of the container, written in increasing subscript order:</font> the elements of the container, written in increasing subscript order:</font>
<blockquote> <blockquote>
<p><font face="Arial, Helvetica, sans-serif" size="-1">boost::array&lt;int,4&gt; <p><font face="Arial, Helvetica, sans-serif" size="-1">boost::array&lt;int,4&gt;
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 are fewer elements in the initializer list, then each remaining element gets
gets default-initialized (thus, it has a defined value).</font></p> default-initialized (thus, it has a defined value).</font></p>
</li> </li>
<li><font face="Arial, Helvetica, sans-serif" size="-1">However, <b>passing <li><font face="Arial, Helvetica, sans-serif" size="-1">However, <b>passing no
no initializer list means that the elements have an indetermined initial value</b>.</font></li> 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 user-declared <li><font face="Arial, Helvetica, sans-serif" size="-1">It has no
constructors.</font></li> user-declared 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 classes.</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 virtual functions.</font></li> classes.</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 implementation <p><font face="Arial, Helvetica, sans-serif" size="-1">The current
uses this approach. However, being able to have indeterminate initial values implementation useus this approach. However, being able to have indetermined
is a big drawback. So, please give me some feedback, how useful you consider initial values is a big drawback. So, please give me some feedback, how useful
this feature to be. This leads to the list of <b>Open issues:</b></font> you consider this feature to be. This leads to the list of <b>Open issues:</b></font>
<ul> <ul>
<li><font face="Arial, Helvetica, sans-serif" size="-1">Do we want initializer <li><font face="Arial, Helvetica, sans-serif">Do we want initializer list
list support or would the following be OK?:</font> support or would the following be OK?:</font>
<blockquote> <blockquote>
<p><font face="Courier New, Courier, mono" size="-1">int data[] = { 1, 2, <p><font face="Courier New, Courier, mono">int data[] = { 1, 2, 3, 4 }</font></p>
3, 4 }</font></p> <p><font face="Courier New, Courier, mono">array&lt;int,5&gt; x(data); <font face="Arial, Helvetica, sans-serif">or
<p><font face="Courier New, Courier, mono" size="-1">array&lt;int,5&gt; </font>&nbsp;&nbsp;array&lt;int,data&gt; x;</font></p>
x(data); <font face="Arial, Helvetica, sans-serif">or </font>&nbsp;&nbsp;array&lt;int,data&gt;
x;</font></p>
</blockquote> </blockquote>
</li> </li>
<li><font face="Arial, Helvetica, sans-serif" size="-1">Could &quot;<font face="Courier New, Courier, mono">{ <li><font face="Arial, Helvetica, sans-serif">Could &quot;<font face="Courier New, Courier, mono">{
</font>...<font face="Courier New, Courier, mono"> }</font>&quot; be used </font>...<font face="Courier New, Courier, mono"> }</font>&quot; be used
portably instead of &quot;<font face="Courier New, Courier, mono">{ { </font>...<font face="Courier New, Courier, mono"> portably instead of &quot;<font face="Courier New, Courier, mono">{ { </font>...<font face="Courier New, Courier, mono">
} }</font>&quot; to initialize values?</font></li> } }</font>&quot; to initialize values?</font></li>
<blockquote> <blockquote>
<p><font face="Arial, Helvetica, sans-serif" size="-1">8.5.1 (11) of the Standard <p><font face="Arial, Helvetica, sans-serif">8.5.1 (11) of the Standard seem
seems to allow it; however, gcc 2.95.2 prints a 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" size="-1">Any way to have determinate <li><font face="Arial, Helvetica, sans-serif">Any way to have determined
initial values and initializer list support?</font></li> initial values and initializer list support?</font></li>
<li><font face="Arial, Helvetica, sans-serif" size="-1">Static_casts for reverse <li><font face="Arial, Helvetica, sans-serif">Static_casts for reverse
iterator stuff?</font></li> iterator stuff</font><font face="Arial, Helvetica, sans-serif">?</font></li>
</ul> </ul>
<p><font face="Arial, Helvetica, sans-serif" size="-1">I'd appreciate any constructive <p><font face="Arial, Helvetica, sans-serif">I'd appreciate any constructive <a href="mailto:solutions@josuttis.com">feedback</a>.
<a href="mailto:solutions@josuttis.com">feedback</a>. <b>Please note: I don't <b>Please note: I don't have time to read all boost mails. Thus, to make sure
have time to read all boost mails. Thus, to make sure that feedback arrives that feedback arrives me, please send me a copy of each mail regarding this
me, please send me a copy of each mail regarding this class.</b></font> class.</b></font>
<p><font face="Arial, Helvetica, sans-serif"><a name="code"></a>The code is provided <p><font face="Arial, Helvetica, sans-serif">The code is provided &quot;as
"as is" without expressed or implied warranty.</font> is&quot; without expressed or implied warranty.</font>
<p><font face="Arial, Helvetica, sans-serif"><b>array.hpp</b>, the implementation <p><font face="Arial, Helvetica, sans-serif"><b>array.hpp</b>, the
of <font face="Courier New, Courier, mono">array&lt;&gt;</font><b>:</b> </font> implementation of <font face="Courier New, Courier, mono">array&lt;&gt;</font><b>:</b>
<li><font face="Arial, Helvetica, sans-serif"> </font><font face="Arial, Helvetica, sans-serif"><a href="array.hpp.html">as
<a href="array.hpp.html">as HTML file</a></font></li> HTML file</a></font> <font face="Arial, Helvetica, sans-serif"><a href="../../boost/array.hpp">as
<li><font face="Arial, Helvetica, sans-serif"> plain file</a></font>
<a href="../../boost/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&lt;&gt;<font face="Arial, Helvetica, sans-serif">:</font></font></font>
<p> <font face="Arial, Helvetica, sans-serif"><b>array1.cpp</b>, a simple example <font face="Arial, Helvetica, sans-serif"><a href="array1.cpp.html">as HTML file</a></font>
for using <font face="Courier New, Courier, mono">array&lt;&gt;<font face="Arial, Helvetica, sans-serif">:</font></font></font> <font face="Arial, Helvetica, sans-serif"><a href="array1.cpp">as plain file</a></font>
<li><font face="Arial, Helvetica, sans-serif"> <p><font face="Arial, Helvetica, sans-serif">Another Example for using <font face="Courier New, Courier, mono">array&lt;&gt;<font face="Arial, Helvetica, sans-serif">:</font></font></font>
<a href="array1.cpp.html">as HTML file</a></font> </li> <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="array1.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&lt;&gt;<font face="Arial, Helvetica, sans-serif">:</font></font></font>
<p> <font face="Arial, Helvetica, sans-serif"><b>array2.cpp</b>, another example <font face="Arial, Helvetica, sans-serif"><a href="array3.cpp.html">as HTML file</a></font>
for using <font face="Courier New, Courier, mono">array&lt;&gt;<font face="Arial, Helvetica, sans-serif">:</font></font></font> <font face="Arial, Helvetica, sans-serif"><a href="array3.cpp">as plain file</a></font>
<li><font face="Arial, Helvetica, sans-serif"> <p><font face="Arial, Helvetica, sans-serif">An Example for using <font face="Courier New, Courier, mono">array</font>s
<a href="array2.cpp.html">as HTML file</a></font></li> 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>
<li><font face="Arial, Helvetica, sans-serif"> <font face="Arial, Helvetica, sans-serif"><a href="array4.cpp.html">as HTML file</a></font>
<a href="array2.cpp">as plain file</a></font></li> <font face="Arial, Helvetica, sans-serif"><a href="array4.cpp">as plain file</a></font>
<p> <font face="Arial, Helvetica, sans-serif"><b>array3.cpp</b>, a third example <p><font face="Arial, Helvetica, sans-serif">An Example for testing other
for using <font face="Courier New, Courier, mono">array&lt;&gt;<font face="Arial, Helvetica, sans-serif">:</font></font></font> operations of <font face="Courier New, Courier, mono">array&lt;&gt;</font><font face="Courier New, Courier, mono"><font face="Arial, Helvetica, sans-serif">:</font></font></font>
<li><font face="Arial, Helvetica, sans-serif"> <font face="Arial, Helvetica, sans-serif"><a href="array5.cpp.html">as HTML file</a></font>
<a href="array3.cpp.html">as HTML file</a></font></li> <font face="Arial, Helvetica, sans-serif"><a href="array5.cpp">as plain file</a></font>
<li><font face="Arial, Helvetica, sans-serif"> <p><font face="Arial, Helvetica, sans-serif">To find more details about using
<a href="array3.cpp">as plain 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>
<p> <font face="Arial, Helvetica, sans-serif"><b>array4.cpp</b>, 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>
<li><font face="Arial, Helvetica, sans-serif"> <a href="array4.cpp.html">as HTML
file</a></font></li>
<li><font face="Arial, Helvetica, sans-serif"> <a href="array4.cpp">as plain file</a></font></li>
<p><font face="Arial, Helvetica, sans-serif"><b>array5.cpp</b>, an example for
testing other operations of <font face="Courier New, Courier, mono">array&lt;&gt;<font face="Arial, Helvetica, sans-serif">:</font></font></font>
<li><font face="Arial, Helvetica, sans-serif"> <a href="array5.cpp.html">as HTML
file</a></font></li>
<li><font face="Arial, Helvetica, sans-serif"> <a href="array5.cpp">as plain file</a></font></li>
<br>
<br>
<font face="Arial, Helvetica, sans-serif">
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>&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://www.josuttis.com/libbook/">The C++ <i>&nbsp;&nbsp;&nbsp;&nbsp; <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>
&nbsp;&nbsp;&nbsp;&nbsp; by <a href="http://www.josuttis.com" target="_top">Nicolai &nbsp;&nbsp;&nbsp;&nbsp; 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>
&nbsp;&nbsp;&nbsp;&nbsp; Addison Wesley Longman, 1999</font><font face="Arial, Helvetica, sans-serif"><br> &nbsp;&nbsp;&nbsp;&nbsp; Addison Wesley Longman, 1999</font><font face="Arial, Helvetica, sans-serif"><br>
&nbsp;&nbsp;&nbsp;&nbsp; ISBN 0-201-37926-0</font><font face="Arial, Helvetica, sans-serif"><br> &nbsp;&nbsp;&nbsp;&nbsp; ISBN 0-201-37926-0</font><font face="Arial, Helvetica, sans-serif"><br>
</font></li>
<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">
</font> </font>
<p><font size="-1" face="Arial, Helvetica, sans-serif">[<a href="#intro">intro</a>] <p><font face="Arial, Helvetica, sans-serif"><a href="http://www.josuttis.com/" target="_top">Home
[<a href="#interface">interface</a>] [<a href="#discussion">discussion</a>] Page of Nicolai Josuttis</a></font><font face="Arial, Helvetica, sans-serif"><br>
[<a href="#code">code</a>]</font> &nbsp;</font>
<p><font face="Arial, Helvetica, sans-serif" size="-1"></font>
<p><font face="Arial, Helvetica, sans-serif">&nbsp; </font>
</body> </body>
</html> </html>

View File

@ -1,8 +1,4 @@
/* simple example for using class array<> /* simple example for using class array<>
*
* Changelog:
* 20 Jan 2001 - Removed boolalpha use since stock GCC doesn't support it
* (David Abrahams)
*/ */
#include <iostream> #include <iostream>
#include <boost/array.hpp> #include <boost/array.hpp>
@ -22,7 +18,7 @@ int main()
// use some common STL container operations // use some common STL container operations
std::cout << "size: " << a.size() << std::endl; std::cout << "size: " << a.size() << std::endl;
std::cout << "empty: " << (a.empty() ? "true" : "false") << std::endl; std::cout << "empty: " << std::boolalpha << a.empty() << std::endl;
std::cout << "max_size: " << a.max_size() << std::endl; std::cout << "max_size: " << a.max_size() << std::endl;
std::cout << "front: " << a.front() << std::endl; std::cout << "front: " << a.front() << std::endl;
std::cout << "back: " << a.back() << std::endl; std::cout << "back: " << a.back() << std::endl;
@ -43,10 +39,8 @@ int main()
<< std::endl; << std::endl;
} }
else { else {
std::cout << "copy construction and copy assignment FAILED" std::cout << "copy construction and copy assignment are OK"
<< std::endl; << std::endl;
} }
return 0; // makes Visual-C++ compiler happy
} }

View File

@ -53,14 +53,12 @@ int&nbsp;main()<BR>
&nbsp;&nbsp;&nbsp;&nbsp;c&nbsp;=&nbsp;a;<BR> &nbsp;&nbsp;&nbsp;&nbsp;c&nbsp;=&nbsp;a;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(a==b&nbsp;&&&nbsp;a==c)&nbsp;{<BR> &nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(a==b&nbsp;&&&nbsp;a==c)&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;"copy&nbsp;construction&nbsp;and&nbsp;copy&nbsp;assignment&nbsp;are&nbsp;OK"<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;"copy&nbsp;construction&nbsp;and&nbsp;copy&nbsp;assignment&nbsp;are&nbsp;OK"<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;&lt;&nbsp;std::endl;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;&lt;&nbsp;std::endl;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;}<BR> &nbsp;&nbsp;&nbsp;&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;{<BR> &nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;"copy&nbsp;construction&nbsp;and&nbsp;copy&nbsp;assignment&nbsp;FAILED"<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;"copy&nbsp;construction&nbsp;and&nbsp;copy&nbsp;assignment&nbsp;are&nbsp;OK"<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;&lt;&nbsp;std::endl;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;&lt;&nbsp;std::endl;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;}<BR> &nbsp;&nbsp;&nbsp;&nbsp;}<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;0;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;makes&nbsp;Visual-C++&nbsp;compiler&nbsp;happy</FONT></I><BR>
}<BR> }<BR>
<BR> <BR>
</SPAN> </SPAN>

View File

@ -12,24 +12,22 @@ int main()
// create and initialize array // create and initialize array
array<int,10> a = { { 1, 2, 3, 4, 5 } }; array<int,10> a = { { 1, 2, 3, 4, 5 } };
print_elements(a); PRINT_ELEMENTS(a);
// modify elements directly // modify elements directly
for (unsigned i=0; i<a.size(); ++i) { for (unsigned i=0; i<a.size(); ++i) {
++a[i]; ++a[i];
} }
print_elements(a); PRINT_ELEMENTS(a);
// change order using an STL algorithm // change order using an STL algorithm
reverse(a.begin(),a.end()); reverse(a.begin(),a.end());
print_elements(a); PRINT_ELEMENTS(a);
// negate elements using STL framework // negate elements using STL framework
transform(a.begin(),a.end(), // source transform(a.begin(),a.end(), // source
a.begin(), // destination a.begin(), // destination
negate<int>()); // operation negate<int>()); // operation
print_elements(a); PRINT_ELEMENTS(a);
return 0; // makes Visual-C++ compiler happy
} }

View File

@ -29,25 +29,23 @@ int&nbsp;main()<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;create&nbsp;and&nbsp;initialize&nbsp;array</FONT></I><BR> &nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;create&nbsp;and&nbsp;initialize&nbsp;array</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;array&lt;int,10&gt;&nbsp;a&nbsp;=&nbsp;{&nbsp;{&nbsp;1,&nbsp;2,&nbsp;3,&nbsp;4,&nbsp;5&nbsp;}&nbsp;};<BR> &nbsp;&nbsp;&nbsp;&nbsp;array&lt;int,10&gt;&nbsp;a&nbsp;=&nbsp;{&nbsp;{&nbsp;1,&nbsp;2,&nbsp;3,&nbsp;4,&nbsp;5&nbsp;}&nbsp;};<BR>
<BR> <BR>
&nbsp;&nbsp;&nbsp;&nbsp;print_elements(a);<BR> &nbsp;&nbsp;&nbsp;&nbsp;PRINT_ELEMENTS(a);<BR>
<BR> <BR>
&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;modify&nbsp;elements&nbsp;directly</FONT></I><BR> &nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;modify&nbsp;elements&nbsp;directly</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;(unsigned&nbsp;i=0;&nbsp;i&lt;a.size();&nbsp;++i)&nbsp;{<BR> &nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;(unsigned&nbsp;i=0;&nbsp;i&lt;a.size();&nbsp;++i)&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;++a[i];<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;++a[i];<BR>
&nbsp;&nbsp;&nbsp;&nbsp;}<BR> &nbsp;&nbsp;&nbsp;&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;print_elements(a);<BR> &nbsp;&nbsp;&nbsp;&nbsp;PRINT_ELEMENTS(a);<BR>
<BR> <BR>
&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;change&nbsp;order&nbsp;using&nbsp;an&nbsp;STL&nbsp;algorithm</FONT></I><BR> &nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;change&nbsp;order&nbsp;using&nbsp;an&nbsp;STL&nbsp;algorithm</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;reverse(a.begin(),a.end());<BR> &nbsp;&nbsp;&nbsp;&nbsp;reverse(a.begin(),a.end());<BR>
&nbsp;&nbsp;&nbsp;&nbsp;print_elements(a);<BR> &nbsp;&nbsp;&nbsp;&nbsp;PRINT_ELEMENTS(a);<BR>
<BR> <BR>
&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;negate&nbsp;elements&nbsp;using&nbsp;STL&nbsp;framework</FONT></I><BR> &nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;negate&nbsp;elements&nbsp;using&nbsp;STL&nbsp;framework</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;transform(a.begin(),a.end(),&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;source</FONT></I><BR> &nbsp;&nbsp;&nbsp;&nbsp;transform(a.begin(),a.end(),&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;source</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a.begin(),&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;destination</FONT></I><BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a.begin(),&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;destination</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;negate&lt;int&gt;());&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;operation</FONT></I><BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;negate&lt;int&gt;());&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;operation</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;print_elements(a);<BR> &nbsp;&nbsp;&nbsp;&nbsp;PRINT_ELEMENTS(a);<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;0;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;makes&nbsp;Visual-C++&nbsp;compiler&nbsp;happy</FONT></I><BR>
}<BR> }<BR>
<BR> <BR>
</SPAN> </SPAN>

View File

@ -17,7 +17,7 @@ int main()
// copy and change order // copy and change order
boost::array<std::string,4> seasons_orig = seasons; boost::array<std::string,4> seasons_orig = seasons;
for (unsigned i=seasons.size()-1; i>0; --i) { for (unsigned i=seasons.size()-1; i>0; --i) {
std::swap(seasons.at(i),seasons.at((i+1)%seasons.size())); swap(seasons.at(i),seasons.at((i+1)%seasons.size()));
} }
std::cout << "one way: "; std::cout << "one way: ";
@ -25,7 +25,7 @@ int main()
// try swap() // try swap()
std::cout << "other way: "; std::cout << "other way: ";
std::swap(seasons,seasons_orig); swap(seasons,seasons_orig);
print_elements(seasons); print_elements(seasons);
// try reverse iterators // try reverse iterators
@ -35,8 +35,6 @@ int main()
std::cout << " " << *pos; std::cout << " " << *pos;
} }
std::cout << std::endl; std::cout << std::endl;
return 0; // makes Visual-C++ compiler happy
} }
template <class T> template <class T>

View File

@ -52,8 +52,6 @@ int&nbsp;main()<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;"&nbsp;"&nbsp;&lt;&lt;&nbsp;*pos;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;"&nbsp;"&nbsp;&lt;&lt;&nbsp;*pos;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;}<BR> &nbsp;&nbsp;&nbsp;&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;std::endl;<BR> &nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;std::endl;<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;0;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;makes&nbsp;Visual-C++&nbsp;compiler&nbsp;happy</FONT></I><BR>
}<BR> }<BR>
<BR> <BR>
template&nbsp;&lt;class&nbsp;T&gt;<BR> template&nbsp;&lt;class&nbsp;T&gt;<BR>

View File

@ -32,7 +32,5 @@ int main()
std::cout << "last element of last array: " std::cout << "last element of last array: "
<< seasons_i18n[seasons_i18n.size()-1][seasons_i18n[0].size()-1] << seasons_i18n[seasons_i18n.size()-1][seasons_i18n[0].size()-1]
<< std::endl; << std::endl;
return 0; // makes Visual-C++ compiler happy
} }

View File

@ -48,9 +48,7 @@ int&nbsp;main()<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;print&nbsp;last&nbsp;element&nbsp;of&nbsp;last&nbsp;array</FONT></I><BR> &nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;print&nbsp;last&nbsp;element&nbsp;of&nbsp;last&nbsp;array</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;"last&nbsp;element&nbsp;of&nbsp;last&nbsp;array:&nbsp;"<BR> &nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;"last&nbsp;element&nbsp;of&nbsp;last&nbsp;array:&nbsp;"<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;&lt;&nbsp;seasons_i18n[seasons_i18n.size()-1][seasons_i18n[0].size()-1]<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;&lt;&nbsp;seasons_i18n[seasons_i18n.size()-1][seasons_i18n[0].size()-1]<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;&lt;&nbsp;std::endl;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;&lt;&nbsp;std::endl;<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;0;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;makes&nbsp;Visual-C++&nbsp;compiler&nbsp;happy</FONT></I><BR>
}<BR> }<BR>
<BR> <BR>
</SPAN> </SPAN>

View File

@ -27,8 +27,7 @@ int main()
// use some common STL container operations // use some common STL container operations
std::cout << "static_size: " << a.size() << std::endl; std::cout << "static_size: " << a.size() << std::endl;
std::cout << "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: " << std::boolalpha << a.empty() << std::endl;
std::cout << "empty: " << (a.empty()? "true" : "false") << std::endl;
std::cout << "max_size: " << a.max_size() << std::endl; std::cout << "max_size: " << a.max_size() << std::endl;
std::cout << "front: " << a.front() << std::endl; std::cout << "front: " << a.front() << std::endl;
std::cout << "back: " << a.back() << std::endl; std::cout << "back: " << a.back() << std::endl;
@ -51,17 +50,15 @@ int main()
<< std::endl; << std::endl;
} }
else { else {
std::cout << "copy construction and copy assignment are BROKEN" std::cout << "copy construction and copy assignment are OK"
<< std::endl; << std::endl;
} }
typedef boost::array<double,6> DArray; typedef boost::array<double,6> DArray;
typedef boost::array<int,6> IArray; typedef boost::array<int,6> IArray;
IArray ia = { { 1, 2, 3, 4, 5, 6 } } ; // extra braces silence GCC warning IArray ia = { 1, 2, 3, 4, 5, 6 };
DArray da; DArray da;
da = ia; da = ia;
da.assign(42); da.assign(42);
return 0; // makes Visual-C++ compiler happy
} }

View File

@ -64,11 +64,11 @@ int&nbsp;main()<BR>
&nbsp;&nbsp;&nbsp;&nbsp;c&nbsp;=&nbsp;a;<BR> &nbsp;&nbsp;&nbsp;&nbsp;c&nbsp;=&nbsp;a;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(a==b&nbsp;&&&nbsp;a==c)&nbsp;{<BR> &nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(a==b&nbsp;&&&nbsp;a==c)&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;"copy&nbsp;construction&nbsp;and&nbsp;copy&nbsp;assignment&nbsp;are&nbsp;OK"<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;"copy&nbsp;construction&nbsp;and&nbsp;copy&nbsp;assignment&nbsp;are&nbsp;OK"<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;&lt;&nbsp;std::endl;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;&lt;&nbsp;std::endl;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;}<BR> &nbsp;&nbsp;&nbsp;&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;{<BR> &nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;"copy&nbsp;construction&nbsp;and&nbsp;copy&nbsp;assignment&nbsp;are&nbsp;BROKEN"<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;"copy&nbsp;construction&nbsp;and&nbsp;copy&nbsp;assignment&nbsp;are&nbsp;OK"<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;&lt;&nbsp;std::endl;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;&lt;&nbsp;std::endl;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;}<BR> &nbsp;&nbsp;&nbsp;&nbsp;}<BR>
<BR> <BR>
&nbsp;&nbsp;&nbsp;&nbsp;typedef&nbsp;boost::array&lt;double,6&gt;&nbsp;DArray;<BR> &nbsp;&nbsp;&nbsp;&nbsp;typedef&nbsp;boost::array&lt;double,6&gt;&nbsp;DArray;<BR>
@ -77,8 +77,6 @@ int&nbsp;main()<BR>
&nbsp;&nbsp;&nbsp;&nbsp;DArray&nbsp;da;<BR> &nbsp;&nbsp;&nbsp;&nbsp;DArray&nbsp;da;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;da&nbsp;=&nbsp;ia;<BR> &nbsp;&nbsp;&nbsp;&nbsp;da&nbsp;=&nbsp;ia;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;da.assign(42);<BR> &nbsp;&nbsp;&nbsp;&nbsp;da.assign(42);<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;0;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;makes&nbsp;Visual-C++&nbsp;compiler&nbsp;happy</FONT></I><BR>
}<BR> }<BR>
<BR> <BR>
</SPAN> </SPAN>

View File

@ -5,15 +5,13 @@
* http://www.josuttis.com/cppcode * http://www.josuttis.com/cppcode
* for details and the latest version. * for details and the latest version.
* *
* (C) Copyright Nicolai M. Josuttis 2001. * (C) Copyright Nicolai M. Josuttis 1999.
* Permission to copy, use, modify, sell and distribute this software * Permission to copy, use, modify, sell and distribute this software
* is granted provided this copyright notice appears in all copies. * is granted provided this copyright notice appears in all copies.
* 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.
* *
* 05 Aug 2001 - minor update (Nico Josuttis) * Jul 31, 2000
* 20 Jan 2001 - STLport fix (Beman Dawes)
* 29 Sep 2000 - Initial Revision (Nico Josuttis)
*/ */
#ifndef BOOST_ARRAY_HPP #ifndef BOOST_ARRAY_HPP
#define BOOST_ARRAY_HPP #define BOOST_ARRAY_HPP
@ -23,7 +21,9 @@
#include <iterator> #include <iterator>
#include <algorithm> #include <algorithm>
// FIXES for broken compilers // BUG-FIX for compilers that don't support
// std::size_t and std::ptrdiff_t yet
// (such as gcc)
#include <boost/config.hpp> #include <boost/config.hpp>
namespace boost { namespace boost {
@ -50,17 +50,11 @@ namespace boost {
const_iterator end() const { return elems+N; } const_iterator end() const { return elems+N; }
// reverse iterator support // reverse iterator support
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_MSVC_STD_ITERATOR) # if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
typedef std::reverse_iterator<iterator> reverse_iterator; typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator; typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
#elif defined(BOOST_MSVC) && (BOOST_MSVC == 1300)
// workaround for broken reverse_iterator in VC7
typedef std::reverse_iterator<std::_Ptrit<value_type, difference_type, iterator,
reference, iterator, reference> > reverse_iterator;
typedef std::reverse_iterator<std::_Ptrit<value_type, difference_type, const_iterator,
const_reference, iterator, reference> > const_reverse_iterator;
# else # else
// workaround for broken reverse_iterator implementations // workaround for broken reverse_iterator implementations due to no partial specialization
typedef std::reverse_iterator<iterator,T> reverse_iterator; typedef std::reverse_iterator<iterator,T> reverse_iterator;
typedef std::reverse_iterator<const_iterator,T> const_reverse_iterator; typedef std::reverse_iterator<const_iterator,T> const_reverse_iterator;
# endif # endif
@ -94,6 +88,7 @@ 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());
@ -118,7 +113,7 @@ namespace boost {
# ifndef BOOST_NO_PRIVATE_IN_AGGREGATE # ifndef BOOST_NO_PRIVATE_IN_AGGREGATE
private: private:
# endif # endif
// check range (may be private because it is static) // private member functions are allowed in aggregates [ISO 8.5.1]
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"); }
} }
@ -160,4 +155,3 @@ namespace boost {
} /* namespace boost */ } /* namespace boost */
#endif /*BOOST_ARRAY_HPP*/ #endif /*BOOST_ARRAY_HPP*/

View File

@ -13,8 +13,8 @@
<tr> <tr>
<td bgcolor="#FFFFFF"><img src="../../c++boost.gif" alt="c++boost.gif (8819 bytes)" width="277" height="86"></td> <td bgcolor="#FFFFFF"><img src="../../c++boost.gif" alt="c++boost.gif (8819 bytes)" width="277" height="86"></td>
<td><a href="../../index.htm"><font face="Arial" color="#FFFFFF"><big>Home</big></font></a></td> <td><a href="../../index.htm"><font face="Arial" color="#FFFFFF"><big>Home</big></font></a></td>
<td><a href="../libraries.htm"><font face="Arial" color="#FFFFFF"><big>Libraries</big></font></a></td> <td><a href="../../libraries.htm"><font face="Arial" color="#FFFFFF"><big>Libraries</big></font></a></td>
<td><a href="../../people/people.htm"><font face="Arial" color="#FFFFFF"><big>People</big></font></a></td> <td><a href="../../people.htm"><font face="Arial" color="#FFFFFF"><big>People</big></font></a></td>
<td><a href="../../more/faq.htm"><font face="Arial" color="#FFFFFF"><big>FAQ</big></font></a></td> <td><a href="../../more/faq.htm"><font face="Arial" color="#FFFFFF"><big>FAQ</big></font></a></td>
<td><a href="../../more/index.htm"><font face="Arial" color="#FFFFFF"><big>More</big></font></a></td> <td><a href="../../more/index.htm"><font face="Arial" color="#FFFFFF"><big>More</big></font></a></td>
</tr> </tr>
@ -26,9 +26,10 @@ of constant size.
<li><a href="array.html">Documentation</a> (HTML).</li> <li><a href="array.html">Documentation</a> (HTML).</li>
<li>Header <a href="../../boost/array.hpp">array.hpp</a></li> <li>Header <a href="../../boost/array.hpp">array.hpp</a></li>
<li>See docs for links to example programs.</li> <li>See docs for links to example programs.</li>
<li>Download <a href="../../boost_all.zip">all of Boost</a> (ZIP format).</li>
<li>Submitted by <a href="http://www.josuttis.com">Nicolai M. Josuttis</a>.</li> <li>Submitted by <a href="http://www.josuttis.com">Nicolai M. Josuttis</a>.</li>
</ul> </ul>
<p>Revised <!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %b %Y" startspan -->14 Mar 2001<!--webbot bot="Timestamp" endspan i-checksum="14885" --></p> <p>Revised <!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %b %Y" startspan -->27 Sep 2000<!--webbot bot="Timestamp" endspan i-checksum="14936" --></p>
</body> </body>

View File

@ -10,13 +10,13 @@
*/ */
#include <iostream> #include <iostream>
/* print_elements() /* PRINT_ELEMENTS()
* - prints optional C-string optcstr followed by * - prints optional C-string optcstr followed by
* - all elements of the collection coll * - all elements of the collection coll
* - separated by spaces * - separated by spaces
*/ */
template <class T> template <class T>
inline void print_elements (const T& coll, const char* optcstr="") inline void PRINT_ELEMENTS (const T& coll, const char* optcstr="")
{ {
typename T::const_iterator pos; typename T::const_iterator pos;

View File

@ -26,13 +26,13 @@
<SPAN class="Source"> <SPAN class="Source">
#include&nbsp;&lt;iostream&gt;<BR> #include&nbsp;&lt;iostream&gt;<BR>
<BR> <BR>
<Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;print_elements()</FONT></I><BR> <Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;PRINT_ELEMENTS()</FONT></I><BR>
&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;-&nbsp;prints&nbsp;optional&nbsp;C-string&nbsp;optcstr&nbsp;followed&nbsp;by</FONT></I><BR> &nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;-&nbsp;prints&nbsp;optional&nbsp;C-string&nbsp;optcstr&nbsp;followed&nbsp;by</FONT></I><BR>
&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;-&nbsp;all&nbsp;elements&nbsp;of&nbsp;the&nbsp;collection&nbsp;coll</FONT></I><BR> &nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;-&nbsp;all&nbsp;elements&nbsp;of&nbsp;the&nbsp;collection&nbsp;coll</FONT></I><BR>
&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;-&nbsp;separated&nbsp;by&nbsp;spaces</FONT></I><BR> &nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;-&nbsp;separated&nbsp;by&nbsp;spaces</FONT></I><BR>
&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*/</FONT></I><BR> &nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*/</FONT></I><BR>
template&nbsp;&lt;class&nbsp;T&gt;<BR> template&nbsp;&lt;class&nbsp;T&gt;<BR>
inline&nbsp;void&nbsp;print_elements&nbsp;(const&nbsp;T&&nbsp;coll,&nbsp;const&nbsp;char*&nbsp;optcstr="")<BR> inline&nbsp;void&nbsp;PRINT_ELEMENTS&nbsp;(const&nbsp;T&&nbsp;coll,&nbsp;const&nbsp;char*&nbsp;optcstr="")<BR>
{<BR> {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;typename&nbsp;T::const_iterator&nbsp;pos;<BR> &nbsp;&nbsp;&nbsp;&nbsp;typename&nbsp;T::const_iterator&nbsp;pos;<BR>
<BR> <BR>