Compare commits

...

46 Commits

Author SHA1 Message Date
nobody
24d1980304 This commit was manufactured by cvs2svn to create tag
'Version_1_31_0'.

[SVN r22162]
2004-02-04 15:24:32 +00:00
nobody
f34bc373f2 This commit was manufactured by cvs2svn to create branch 'RC_1_31_0'.
[SVN r21427]
2003-12-30 12:10:04 +00:00
Beman Dawes
afb151d824 fix links broken by index.htm to index.html renaming
[SVN r21233]
2003-12-12 00:00:13 +00:00
Ronald Garcia
4da202d5ae silly error.
[SVN r21153]
2003-12-05 18:51:24 +00:00
Ronald Garcia
25899202c2 Some minor updates:
Reworded synopsis and introduction. Moved "Related work" to the
end. Added a TOC entry for credits.


[SVN r21092]
2003-12-02 22:15:37 +00:00
Ronald Garcia
5ae8b95af8 Updated license and copyright information.
[SVN r21050]
2003-12-01 19:25:45 +00:00
Ronald Garcia
26b81a8471 Removed reference to array_traits, which have disappeared from the earth.
[SVN r21049]
2003-12-01 19:15:58 +00:00
Ronald Garcia
0588a31e72 Updated/Added/Corrected license information for source files.
[SVN r21048]
2003-12-01 19:07:11 +00:00
Dave Abrahams
5e3d128254 vc6 workarounds
[SVN r21005]
2003-11-29 17:49:36 +00:00
Beman Dawes
707f699a62 Fix broken links
[SVN r21001]
2003-11-29 13:19:18 +00:00
Dave Abrahams
f39fdf871b Workarounds for vc7
[SVN r20920]
2003-11-23 15:49:55 +00:00
Dave Abrahams
9542f4546b Removed access category tags from iterator library, made corresponding
changes elsewhere.

boost/iterator and libs/iterator/test were updated from
branch "simplify"


[SVN r20905]
2003-11-22 01:18:37 +00:00
Dave Abrahams
3289929679 Correctly fail on Intel, which otherwise just warns.
[SVN r20873]
2003-11-19 22:38:55 +00:00
Dave Abrahams
7291ae7703 Factored out of status/Jamfile
[SVN r20871]
2003-11-19 22:22:29 +00:00
Ronald Garcia
327918c0de Fixed a bug in length calculation for array views. Caught by Ben Nasatyr.
[SVN r20732]
2003-11-08 00:05:40 +00:00
Douglas Gregor
34a7fdda5d Added some missing "template" keywords via BOOST_NESTED_TEMPLATE
[SVN r20605]
2003-11-02 19:14:16 +00:00
Ronald Garcia
a39dec2f39 Added a storage_order query and storage_order_type to the various multi_array
versions.


[SVN r19775]
2003-08-25 22:32:45 +00:00
Ronald Garcia
0de9a4b475 Using mpl in a more sophisticated manner to pick value_accessor class.
This change has made the code both more concise and more suggestive of its
purpose.


[SVN r19698]
2003-08-19 19:31:05 +00:00
Ronald Garcia
b27fbb3a78 Removed iterator generators from iterator.hpp
Now using mpl::if_c to pick a value_accessor class.


[SVN r19697]
2003-08-19 19:11:06 +00:00
Ronald Garcia
ea278bfd88 More changes related to iterators:
- Fixed the access categories to be proper
- Removed iterator generator classes.
- Custom iterator adaptors is now gone!


[SVN r19696]
2003-08-19 18:25:38 +00:00
Ronald Garcia
49b928a2ab Updated multi_array to use the new boost iterators library.
[SVN r19695]
2003-08-19 15:50:25 +00:00
Ronald Garcia
a7e14cb547 Made a change to prevent ICE in gcc 2.95.3 and 2.96.
[SVN r19557]
2003-08-12 16:28:13 +00:00
Dave Abrahams
6f25eb3232 Apply patch from Matthias Troyer <troyer-at-itp.phys.ethz.ch>
[SVN r19109]
2003-07-14 13:01:01 +00:00
Jens Maurer
7bbb0b93c0 avoid "comparison between signed and unsigned integer" warning
[SVN r19011]
2003-07-09 23:25:25 +00:00
Ronald Garcia
a3120b00ca Changed the test for dimensionality to a static assert.
[SVN r18869]
2003-06-25 20:16:57 +00:00
Ronald Garcia
e9427e12f0 Added "dimensionality" nested constant value and a test case.
[SVN r18868]
2003-06-25 16:55:39 +00:00
Ronald Garcia
1223a932a3 Astoundingly embarrassing bug.
[SVN r18589]
2003-05-28 19:37:05 +00:00
Ronald Garcia
434d47eee0 Patch from Matthias Troyer.
[SVN r18221]
2003-04-09 13:58:41 +00:00
Ronald Garcia
73698a7bc2 Forgot to commit this file along with the other revisions allowing default
constructed multi_arrays


[SVN r18220]
2003-04-09 13:53:16 +00:00
Ronald Garcia
e35e6102b7 Added documentation for "resize" and default constructor to the multi_array
section.


[SVN r18115]
2003-03-27 21:03:23 +00:00
Ronald Garcia
c05ce3ff59 More boost-ified, now uses test tools.
[SVN r18113]
2003-03-27 20:28:29 +00:00
Ronald Garcia
fad36ccacd Now using test tools.
[SVN r18112]
2003-03-27 20:19:11 +00:00
Ronald Garcia
0de8b74284 Added support for default constructed multi_arrays:
- default public constructor for multi_array
- default protected constructors for multi_array_ref and const_multi_*
- fixed a bug in index_range regarding degenerate dimiensions.
- Added tests to resize.cpp and constructors.cpp.


[SVN r18111]
2003-03-27 20:12:32 +00:00
Ronald Garcia
f2d6737f50 Fixed a broken patch job....grr!
[SVN r17853]
2003-03-12 15:39:25 +00:00
Markus Schöpflin
e37de3592b FIX: Changed 2nd parameter of check_shape() from unsigned int * to size_t *.
[SVN r17831]
2003-03-12 10:45:59 +00:00
Ronald Garcia
84d65a8402 Must have forgot to check in this change.
[SVN r17540]
2003-02-19 23:42:32 +00:00
Ronald Garcia
da922535c2 Repaired some dependent base class issues (found by icc -ansi).
[SVN r17243]
2003-02-05 20:39:13 +00:00
Ronald Garcia
b8bf7a5fcd Fixed a bug in advance.
[SVN r17093]
2003-01-30 16:55:31 +00:00
Ronald Garcia
ef89b81e7c Made some changes as per bug reports regarding calls to dependent base classes.
[SVN r16932]
2003-01-18 19:47:29 +00:00
Ronald Garcia
080c2a7c9b Bug fixes related to calling functions in dependent base classes.
[SVN r16924]
2003-01-17 20:09:54 +00:00
Ronald Garcia
9c3949fb67 Imported from jsiek's submission to the library group, or something like that.
I modified the labels to not use colons because some browser's can't handle
labels with colons in them.


[SVN r16829]
2003-01-09 14:23:05 +00:00
Ronald Garcia
0e55920979 Added a note about upcoming user documentation update.
[SVN r16809]
2003-01-08 23:36:12 +00:00
Beman Dawes
7683594b36 add or update See www.boost.org comments
[SVN r16708]
2002-12-27 16:51:53 +00:00
Ronald Garcia
7ed9d30cc9 Added resizing capability to multi_array (not multi_array_ref!).
[SVN r16505]
2002-12-04 02:03:26 +00:00
Beman Dawes
e5909ce409 Add super_type:: so 2-phase lookup works right
[SVN r16378]
2002-11-23 18:17:43 +00:00
Ronald Garcia
8387e84d8f Patch received from Toon Knapen applied.
[SVN r16034]
2002-10-31 21:26:25 +00:00
78 changed files with 2416 additions and 1640 deletions

View File

@@ -1,14 +1,16 @@
<html>
<!--
== Copyright (c) Ronald Garcia, Jeremy Siek 2001
==
== Permission to use, copy, modify, distribute and sell this software
== and its documentation for any purpose is hereby granted without fee,
== provided that the above copyright notice appears in all copies and
== that both that copyright notice and this permission notice appear
== in supporting documentation. Jeremy Siek makes no
== representations about the suitability of this software for any
== purpose. It is provided "as is" without express or implied warranty.
== Copyright 2002 The Trustees of Indiana University.
== Use, modification and distribution is subject to the Boost Software
== License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
== http://www.boost.org/LICENSE_1_0.txt)
== Boost.MultiArray Library
== Authors: Ronald Garcia
== Jeremy Siek
== Andrew Lumsdaine
== See http://www.boost.org/libs/multi_array for documentation.
-->
<head>
<title>MultiDimensional Array Libary</title></head>

View File

@@ -0,0 +1,797 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><!-- saved from url=(0022)http://internet.e-mail --><title>Improved Iterator Categories and Requirements</title>
<meta content="text/html; charset=windows-1252" http-equiv="Content-Type">
<meta content="Microsoft FrontPage 5.0" name="GENERATOR"></head>
<body bgcolor="#ffffff">
<p align="right">
<table border="0">
<tbody>
<tr>
<td width="125">
<p align="right">Document number: </p></td>
<td width="190">
<p>J16/01-0011 = WG21 N1297 </p></td></tr>
<tr>
<td width="125">
<p align="right">Date: </p></td>
<td width="190">
<p>March 21, 2001 </p></td></tr>
<tr>
<td width="125">
<p align="right">Author: </p></td>
<td width="190">
<p>Jeremy Siek, <br>University of Notre Dame </p></td></tr>
<tr>
<td width="125">
<p></p></td>
<td width="190">
<p><a href="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</a>
</p></td></tr></tbody></table></p>
<h1>
<center>Improved Iterator Categories and Requirements</center></h1>
<h2>Introduction</h2>The standard iterator categories and requirements are
flawed because they use a single hierarchy of requirements to address two
orthogonal issues: <b><i>iterator traversal</i></b> and <b><i>dereference return
type</i></b>. The current iterator requirement hierarchy is mainly geared
towards iterator traversal (hence the category names), while requirements that
address dereference return type sneak in at various places. The following table
gives a summary of the current dereference return type requirements in the
iterator categories.
<p>
</p><center>
<a name="table:2">
<b>Table 1.</b> Summary of current dereference return type
requirements.</a><table border="1">
<tbody>
<tr>
<td>Output Iterator</td>
<td><tt>*i = a</tt> </td></tr>
<tr>
<td>Input Iterator</td>
<td><tt>*i</tt> is convertible to <tt>T</tt></td></tr>
<tr>
<td>Forward Iterator</td>
<td><tt>*i</tt> is <tt>T&amp;</tt> (or <tt>const T&amp;</tt> once <a href="http://anubis.dkuug.dk/JTC1/SC22/WG21/docs/lwg-active.html#200">issue
200</a> is resolved)</td></tr>
<tr>
<td>Random Access Iterator</td>
<td><tt>i[n]</tt> is convertible to <tt>T</tt> (which is odd because the
operational semantics say <tt>i[n]</tt> is equivalent to <tt>*(i + n)</tt>
which would have a return type of <tt>T&amp;</tt>) </td></tr></tbody></table></center>
<h2>Examples of useful iterators that do not ``fit''</h2>
<p>Because of the mixing of iterator traversal and dereference return type, many
useful iterators can not be appropriately categorized. For example,
<tt>vector&lt;bool&gt;::iterator</tt> is almost a random access iterator, but
the return type is not <tt>bool&amp;</tt> (see <a href="http://anubis.dkuug.dk/JTC1/SC22/WG21/docs/lwg-active.html#96">issue
96</a> and Herb Sutter's paper J16/99-0008 = WG21 N1185). Therefore, the
iterators only meet the requirements of input iterator and output iterator. This
is so nonintuitive that at least one implementation erroneously assigns
<tt>random_access_iterator_tag</tt> as its <tt>iterator_category</tt>. Also,
<tt>vector&lt;bool&gt;</tt> is not the only example of useful iterators that do
not return true references: there is the often cited example of disk-based
collections.
</p><p>Another example is a counting iterator, an iterator the returns a sequence of
integers when incremented and dereferenced (see <a href="http://www.boost.org/libs/utility/counting_iterator.htm"><tt>boost::counting_iterator</tt></a>).
There are two ways to implement this iterator, 1) make the <tt>reference</tt>
type be a true reference (a reference to an integer data member of the counting
iterator) or 2) make the <tt>reference</tt> type be the same as the
<tt>value_type</tt>. Option 1) runs into the problems discussed in <a href="http://anubis.dkuug.dk/JTC1/SC22/WG21/docs/lwg-active.html#198">Issue
198</a>, the reference will not be valid after the iterator is destroyed. Option
2) is therefore a better choice, but then we have a counting iterator that
cannot be a random access iterator.
</p><p>Yet another example is a transform iterator, an iterator adaptor that applies
a unary function object to the dereference value of the wrapped iterator (see <a href="http://www.boost.org/libs/utility/transform_iterator.htm"><tt>boost::transform_iterator</tt></a>).
For unary functions such as <tt>std::times</tt> the return type of
<tt>operator*</tt> clearly needs to be the <tt>result_type</tt> of the function
object, which is typically not a reference. However, with the current iterator
requirements, if you wrap <tt>int*</tt> with a transform iterator, you do not
get a random access iterator as expected, but an input iterator.
</p><p>A fourth example is found in the vertex and edge iterators of the <a href="http://www.boost.org/libs/graph/doc/table_of_contents.html">Boost Graph
Library</a>. These iterators return vertex and edge descriptors, which are
lightweight handles created on-the-fly. They must be returned by-value. As a
result, their current standard iterator category is
<tt>std::input_iterator_tag</tt>, which means that, strictly speaking, you could
not use these iterators with algorithms like <tt>std::min_element()</tt>. As a
temporary solution, we introduced the concept <a href="http://www.boost.org/libs/utility/MultiPassInputIterator.html">Multi-Pass
Input Iterator</a> to describe the vertex and edge descriptors, but as the
design notes for concept suggest, a better solution is needed.
</p><p>In short, there are many useful iterators that do not fit into the current
standard iterator categories. As a result, the following bad things happen:
</p><ul>
<li>Iterators are often miss-categorized.
</li><li>Algorithm requirements are more strict than necessary, because they can
not separate out the need for random-access from the need for a true reference
return type. </li></ul>
<h2>Proposal for new iterator categories and requirements</h2>The iterator
requirements should be separated into two hierarchies. One set of concepts
handles the return type semantics:
<ul>
<li><a href="#concept_ReadableIterator">Readable
Iterator</a>
</li><li><a href="#concept_WritableIterator">Writable
Iterator</a>
</li><li><a href="#concept_SwappableIterator">Swappable
Iterator</a>
</li><li><a href="#concept_ConstantLvalueIterator">Constant
Lvalue Iterator</a>
</li><li><a href="#concept_MutableLvalueIterator">Mutable
Lvalue Iterator</a> </li></ul>The other set of concepts handles iterator
traversal:
<ul>
<li><a href="#concept_ForwardTraversalIterator">Forward
Traversal Iterator</a>
</li><li><a href="#concept_BidirectionalTraversalIterator">Bidirectional
Traversal Iterator</a>
</li><li><a href="#concept_RandomAccessTraversalIterator">Random
Access Traversal Iterator</a> </li></ul>The current Input Iterator and Output
Iterator requirements will continue to be used as is. Note that Input Iterator
implies Readable Iterator and Output Iterator implies Writable Iterator.
<p>Note: we considered defining a Single-Pass Iterator, which could be combined
with Readable or Writable Iterator to replace the Input and Output Iterator
requirements. We rejected this idea because there are several differences
between Input and Output Iterators that make it hard to merge them: Input
Iterator requires Equality Comparable while Output Iterator does not and Input
Iterator requires Assignable while Output Iterator does not.
</p><h3>New categories and traits classes</h3>Each of the new iterator requirements
will need a category tag. <pre>namespace std {
// Return Type Categories
struct readable_iterator_tag { };
struct writable_iterator_tag { };
struct swappable_iterator_tag { };
struct mutable_lvalue_iterator_tag : virtual public writable_iterator_tag,
virtual public readable_iterator_tag { };
struct constant_lvalue_iterator_tag : public readable_iterator_tag { };
// Traversal Categories
struct forward_traversal_tag { };
struct bidirectional_traversal_tag : public forward_traversal_tag { };
struct random_access_traversal_tag : public bidirectional_traversal_tag { };
}
</pre>And there will need to be a way to access these category tags using a
traits mechanism. Adding new typedefs to <tt>std::iterator_traits</tt> is not an
acceptable solution because that would break every existing iterator. Instead,
we propose two new traits classes. It is important that these traits classes are
<b>backward compatible</b>, that is, they should work with any iterator for
which there is a valid definition of <tt>std::iterator_traits</tt>. This can be
accomplished by making the default behavior of the traits classes map the
<tt>iterator_category</tt> of the iterator to the appropriate return or
traversal category. For new iterators, either specializations of these traits
classes can be defined, or the iterator can provide nested typedefs, and inherit
from <tt>new_iterator_base</tt> (which is just a signal to the traits class that
it is a new iterator). As with <tt>std::iterator_traits</tt>, specializations
for <tt>T*</tt> are provided. <pre>namespace std {
struct new_iterator_base { };
template &lt;typename Iterator&gt;
struct return_category
{
<b><i>// Pseudo-code</i></b>
if (Iterator inherits from new_iterator_base) {
typedef typename Iterator::return_category type;
} else {
typedef std::iterator_traits&lt;Iterator&gt; OldTraits;
typedef typename OldTraits::iterator_category Cat;
if (Cat inherits from std::forward_iterator_tag)
if (is-const(T))
typedef boost::constant_lvalue_iterator_tag type;
else
typedef boost::mutable_lvalue_iterator_tag type;
else if (Cat inherits from std::input_iterator_tag)
typedef boost::readable_iterator_tag type;
else if (Cat inherits from std::output_iterator_tag)
typedef boost::writable_iterator_tag type;
}
};
template &lt;typename T&gt;
struct return_category&lt;T*&gt;
{
<b><i>// Pseudo-code</i></b>
if (is-const(T))
typedef boost::constant_lvalue_iterator_tag type;
else
typedef boost::mutable_lvalue_iterator_tag type;
};
template &lt;typename Iterator&gt;
struct traversal_category
{
<b><i>// Pseudo-code</i></b>
if (Iterator inherits from new_iterator_base) {
typedef typename Iterator::traversal_category type;
} else {
typedef std::iterator_traits&lt;Iterator&gt; OldTraits;
typedef typename OldTraits::iterator_category Cat;
if (Cat inherits from std::random_access_iterator_tag)
typedef boost::random_access_traversal_tag type;
else if (Cat inherits from std::bidirectional_iterator_tag)
typedef boost::bidirectional_traversal_tag type;
else if (Cat inherits from std::forward_iterator_tag)
typedef boost::forward_traversal_tag type;
}
};
template &lt;typename T&gt;
struct traversal_category&lt;T*&gt;
{
typedef boost::random_access_traversal_tag type;
};
}
</pre>
<h2>Impact on the Standard Algorithms</h2>Many of the standard algorithms place
more requirements than necessary on their iterator parameters due to the
coarseness of the current iterator categories. By using the new iterator
categories a better fit can be achieved, thereby increasing the reusability of
the algorithms. These changes will not affect user-code, though they will
require changes by standard implementers: dispatching should be based on the new
categories, and in places return values may need to be handled more carefully.
In particular, uses of <tt>std::swap()</tt> will need to be replaced with
<tt>std::iter_swap()</tt>, and <tt>std::iter_swap()</tt> will need to call
<tt>std::swap()</tt>.
<p>
</p><center>
<a name="table:2">
<b>Table 2.</b> Requirement changes for standard
algorithms.</a><table border="1">
<tbody>
<tr>
<th>Algorithm</th>
<th>Requirement Change</th></tr>
<tr>
<td>find_end</td>
<td rowspan="12">Forward Iterator<br>-&gt; Forward Traversal Iterator and
Readable Iterator </td></tr>
<tr>
<td>find_first_of</td></tr>
<tr>
<td>adjacent_find</td></tr>
<tr>
<td>search</td></tr>
<tr>
<td>search_n</td></tr>
<tr>
<td>rotate_copy</td></tr>
<tr>
<td>lower_bound</td></tr>
<tr>
<td>upper_bound</td></tr>
<tr>
<td>equal_range</td></tr>
<tr>
<td>binary_search</td></tr>
<tr>
<td>min_element</td></tr>
<tr>
<td>max_element</td></tr>
<tr>
<td>iter_swap</td>
<td>Forward Iterator<br>-&gt; Swappable Iterator </td></tr>
<tr>
<td>fill</td>
<td rowspan="2">Forward Iterator<br>-&gt; Forward Traversal Iterator and
Writable Iterator </td></tr>
<tr>
<td>generate</td></tr>
<tr>
<td>swap_ranges</td>
<td rowspan="2">Forward Iterator<br>-&gt; Forward Traversal Iterator and
Swappable Iterator </td></tr>
<tr>
<td>rotate</td></tr>
<tr>
<td>replace</td>
<td rowspan="5">Forward Iterator<br>-&gt; Forward Traversal Iterator
and<br>Readable Iterator and Writable Iterator </td>
</tr><tr>
<td>replace_if</td></tr>
<tr>
<td>remove</td></tr>
<tr>
<td>remove_if</td></tr>
<tr>
<td>unique</td></tr>
<tr>
<td>reverse</td>
<td rowspan="2">Bidirectional Iterator<br>-&gt; Bidirectional Traversal
Iterator and Swappable Iterator </td></tr>
<tr>
<td>partition</td></tr>
<tr>
<td>copy_backwards</td>
<td>Bidirectional Iterator<br>-&gt; Bidirectional Traversal Iterator and
Readable Iterator<br>Bidirectional Iterator<br>-&gt; Bidirectional
Traversal Iterator and Writable Iterator </td></tr>
<tr>
<td>next_permutation</td>
<td rowspan="2">Bidirectional Iterator<br>-&gt; Bidirectional Traversal
Iterator and <br>Swappable Iterator and Readable Iterator </td>
</tr><tr>
<td>prev_permutation</td></tr>
<tr>
<td>stable_partition</td>
<td rowspan="2">Bidirectional Iterator<br>-&gt; Bidirectional Traversal
Iterator and <br>Readable Iterator and Writable Iterator </td>
</tr><tr>
<td>inplace_merge</td></tr>
<tr>
<td>reverse_copy</td>
<td>Bidirectional Iterator<br>-&gt; Bidirectional Traversal Iterator and
Readable Iterator </td></tr>
<tr>
<td>random_shuffle</td>
<td rowspan="9">Random Access Iterator<br>-&gt; Random Access Traversal
Iterator and Swappable Iterator </td></tr>
<tr>
<td>sort</td></tr>
<tr>
<td>stable_sort</td></tr>
<tr>
<td>partial_sort</td></tr>
<tr>
<td>nth_element</td></tr>
<tr>
<td>push_heap</td></tr>
<tr>
<td>pop_heap</td></tr>
<tr>
<td>make_heap</td></tr>
<tr>
<td>sort_heap</td></tr></tbody></table></center>
<h2>The New Iterator Requirements</h2>
<h3>Notation</h3>
<table>
<tbody>
<tr>
<td><tt>X</tt></td>
<td>The iterator type.</td></tr>
<tr>
<td><tt>T</tt></td>
<td>The value type of <tt>X</tt>, i.e.,
<tt>std::iterator_traits&lt;X&gt;::value_type</tt>.</td></tr>
<tr>
<td><tt>x</tt>, <tt>y</tt></td>
<td>An object of type <tt>X</tt>.</td></tr>
<tr>
<td><tt>t</tt></td>
<td>An object of type <tt>T</tt>.</td></tr></tbody></table>
<p>
</p><hr>
<!--------------------------------------------------------------------------->
<h3><a name="concept_ReadableIterator"></a>Readable Iterator </h3>A Readable
Iterator is an iterator that dereferences to produce an rvalue that is
convertible to the <tt>value_type</tt> of the iterator.
<h3>Associated Types</h3>
<table border="1">
<tbody>
<tr>
<td>Value type</td>
<td><tt>std::iterator_traits&lt;X&gt;::value_type</tt></td>
<td>The type of the objects pointed to by the iterator.</td></tr>
<tr>
<td>Reference type</td>
<td><tt>std::iterator_traits&lt;X&gt;::reference</tt></td>
<td>The return type of dereferencing the iterator. This type must be
convertible to <tt>T</tt>. </td></tr>
<tr>
<td>Return Category</td>
<td><tt>std::return_category&lt;X&gt;::type</tt></td>
<td>A type convertible to <tt>std::readable_iterator_tag</tt>
</td></tr></tbody></table>
<h3>Refinement of</h3><a href="http://www.boost.org/libs/utility/CopyConstructible.html">Copy
Constructible</a>
<h3>Valid expressions</h3>
<table border="1">
<tbody>
<tr>
<th>Name</th>
<th>Expression</th>
<th>Type requirements</th>
<th>Return type</th></tr>
<tr>
<td>Dereference</td>
<td><tt>*x</tt></td>
<td> </td>
<td><tt>std::iterator_traits&lt;X&gt;::reference</tt></td></tr>
<tr>
<td>Member access</td>
<td><tt>x-&gt;m</tt></td>
<td><tt>T</tt> is a type with a member named <tt>m</tt>.</td>
<td>If <tt>m</tt> is a data member, the type of <tt>m</tt>. If <tt>m</tt>
is a member function, the return type of <tt>m</tt>. </td></tr></tbody></table>
<p>
</p><hr>
<!--------------------------------------------------------------------------->
<h3><a name="concept_WritableIterator"></a>Writable Iterator </h3>A Writable
Iterator is an iterator that can be used to store a value using the
dereference-assignment expression.
<h3>Definitions</h3>If <tt>x</tt> is an Writable Iterator of type <tt>X</tt>,
then the expression <tt>*x = a;</tt> stores the value <tt>a</tt> into
<tt>x</tt>. Note that <tt>operator=</tt>, like other C++ functions, may be
overloaded; it may, in fact, even be a template function. In general, then,
<tt>a</tt> may be any of several different types. A type <tt>A</tt> belongs to
the <i>set of value types</i> of <tt>X</tt> if, for an object <tt>a</tt> of type
<tt>A</tt>, <tt>*x = a;</tt> is well-defined and does not require performing any
non-trivial conversions on <tt>a</tt>.
<h3>Associated Types</h3>
<table border="1">
<tbody>
<tr>
<td>Return Category</td>
<td><tt>std::return_category&lt;X&gt;::type</tt></td>
<td>A type convertible to <tt>std::writable_iterator_tag</tt>
</td></tr></tbody></table>
<h3>Refinement of</h3><a href="http://www.boost.org/libs/utility/CopyConstructible.html">Copy
Constructible</a>
<h3>Valid expressions</h3>
<table border="1">
<tbody>
<tr>
<th>Name</th>
<th>Expression</th>
<th>Return type</th></tr>
<tr>
<td>Dereference assignment</td>
<td><tt>*x = a</tt></td>
<td>unspecified</td></tr></tbody></table>
<p>
</p><hr>
<!--------------------------------------------------------------------------->
<h3><a name="concept_SwappableIterator"></a>Swappable Iterator </h3>A Swappable
Iterator is an iterator whose dereferenced values can be swapped.
<p>Note: the requirements for Swappable Iterator are dependent on the issues
surrounding <tt>std::swap()</tt> being resolved. Here we assume that the issue
will be resolved by allowing the overload of <tt>std::swap()</tt> for
user-defined types.
</p><p>Note: Readable Iterator and Writable Iterator combined implies Swappable
Iterator because of the fully templated <tt>std::swap()</tt>. However, Swappable
Iterator does not imply Readable Iterator nor Writable Iterator.
</p><h3>Associated Types</h3>
<table border="1">
<tbody>
<tr>
<td>Return Category</td>
<td><tt>std::return_category&lt;X&gt;::type</tt></td>
<td>A type convertible to <tt>std::swappable_iterator_tag</tt>
</td></tr></tbody></table>
<h3>Valid expressions</h3>Of the two valid expressions listed below, only one
<b>OR</b> the other is required. If <tt>std::iter_swap()</tt> is overloaded for
<tt>X</tt> then <tt>std::swap()</tt> is not required. If
<tt>std::iter_swap()</tt> is not overloaded for <tt>X</tt> then the default
(fully templated) version is used, which will call <tt>std::swap()</tt> (this
means changing the current requirements for <tt>std::iter_swap()</tt>).
<p>
<table border="1">
<tbody>
<tr>
<th>Name</th>
<th>Expression</th>
<th>Return type</th></tr>
<tr>
<td>Iterator Swap</td>
<td><tt>std::iter_swap(x, y)</tt></td>
<td>void</td></tr>
<tr>
<td>Dereference and Swap</td>
<td><tt>std::swap(*x, *y)</tt></td>
<td>void</td></tr></tbody></table>
</p><p>
</p><hr>
<!--------------------------------------------------------------------------->
<h3><a name="concept_ConstantLvalueIterator"></a>Constant Lvalue Iterator </h3>A
Constant Lvalue Iterator is an iterator that dereferences to produce a const
reference to the pointed-to object, i.e., the associated <tt>reference</tt> type
is <tt>const T&amp;</tt>. Changing the value of or destroying an iterator that
models Constant Lvalue Iterator does not invalidate pointers and references
previously obtained from that iterator.
<h3>Refinement of</h3><a href="#concept_ReadableIterator">Readable
Iterator</a>
<h3>Associated Types</h3>
<table border="1">
<tbody>
<tr>
<td>Reference type</td>
<td><tt>std::iterator_traits&lt;X&gt;::reference</tt></td>
<td>The return type of dereferencing the iterator, which must be <tt>const
T&amp;</tt>. </td></tr><!-- I don't think this is needed
<tr>
<td>Pointer type</td>
<td><tt>std::iterator_traits&lt;X&gt;::pointer</tt></td>
<td>
The pointer to the value type, which must be <tt>const T*</tt>.
</td>
</tr>
-->
<tr>
<td>Return Category</td>
<td><tt>std::return_category&lt;X&gt;::type</tt></td>
<td>A type convertible to <tt>std::constant_lvalue_iterator_tag</tt>
</td></tr></tbody></table><!-- these are not necessary now that we use reference as operator* return type
<h3>Valid expressions</h3>
<Table border>
<tr><TH>Name</TH><TH>Expression</TH><TH>Type requirements</TH><TH>Return type</TH></tr>
<tr>
<td>Dereference</td>
<td><tt>*x</tt></td>
<td>&nbsp;</td>
<td><tt>std::iterator_traits&lt;X&gt;::reference</tt></td>
</tr>
<tr>
<td>Member access</td>
<td><tt>x-&gt;m</tt></td>
<td><tt>T</tt> is a type with a member named <tt>m</tt>.</td>
<td>
&nbsp;
</td>
</tr>
</table>
-->
<p>
</p><hr>
<!--------------------------------------------------------------------------->
<h3><a name="concept_MutableLvalueIterator"></a>Mutable Lvalue Iterator </h3>A
Mutable Lvalue Iterator is an iterator that dereferences to produce a reference
to the pointed-to object. The associated <tt>reference</tt> type is
<tt>T&amp;</tt>. Changing the value of or destroying an iterator that models
Mutable Lvalue Iterator does not invalidate pointers and references previously
obtained from that iterator.
<h3>Refinement of</h3><a href="#concept_ReadableIterator">Readable
Iterator</a>, <a href="#concept_WritableIterator">Writable
Iterator</a>, and <a href="#concept_SwappableIterator">Swappable
Iterator</a>.
<h3>Associated Types</h3>
<table border="1">
<tbody>
<tr>
<td>Reference type</td>
<td><tt>std::iterator_traits&lt;X&gt;::reference</tt></td>
<td>The return type of dereferencing the iterator, which must be
<tt>T&amp;</tt>.</td></tr><!-- I don't think this is necessary
<tr>
<td>Pointer type</td>
<td><tt>std::iterator_traits&lt;X&gt;::pointer</tt></td>
<td>
The pointer to the value type, which is <tt>T*</tt>.
</td>
</tr>
-->
<tr>
<td>Return Category</td>
<td><tt>std::return_category&lt;X&gt;::type</tt></td>
<td>A type convertible to <tt>std::mutable_lvalue_iterator_tag</tt>
</td></tr></tbody></table><!-- no longer needed since the return type is specified as reference in the readable iterator
<h3>Valid expressions</h3>
<Table border>
<tr><TH>Name</TH><TH>Expression</TH><TH>Type requirements</TH><TH>Return type</TH></tr>
<tr>
<td>Dereference</td>
<td><tt>*x</tt></td>
<td>&nbsp;</td>
<td><tt>std::iterator_traits&lt;X&gt;::reference</tt></td>
</tr>
<tr>
<td>Member access</td>
<td><tt>x-&gt;m</tt></td>
<td><tt>T</tt> is a type with a member named <tt>m</tt>.</td>
<td>
&nbsp;
</td>
</tr>
</table>
-->
<p>
</p><hr>
<!--------------------------------------------------------------------------->
<h3><a name="concept_ForwardTraversalIterator"></a>Forward Traversal Iterator
</h3>The Forward Iterator is an iterator that can be incremented. Also, it is
permissible to make multiple passes through the iterator's range.
<h3>Refinement of</h3><a href="http://www.boost.org/libs/utility/CopyConstructible.html">Copy
Constructible</a>, <a href="http://www.boost.org/libs/utility/Assignable.html">Assignable</a>, <a href="http://www.sgi.com/tech/stl/DefaultConstructible.html">Default
Constructible</a>, and <a href="http://www.sgi.com/tech/stl/EqualityComparable.html">Equality
Comparable</a>
<h3>Associated types</h3>
<table border="1">
<tbody>
<tr>
<td>Difference Type</td>
<td><tt>std::iterator_traits&lt;X&gt;::difference_type</tt></td>
<td>A signed integral type used for representing distances between
iterators that point into the same range. </td></tr>
<tr>
<td>Traversal Category</td>
<td><tt>std::traversal_category&lt;X&gt;::type</tt></td>
<td>A type convertible to <tt>std::forward_traversal_tag</tt>
</td></tr></tbody></table>
<h3>Valid expressions</h3>
<table border="1">
<tbody>
<tr>
<th>Name</th>
<th>Expression</th>
<th>Type requirements</th>
<th>Return type</th></tr>
<tr>
<td>Preincrement</td>
<td><tt>++i</tt></td>
<td> </td>
<td><tt>X&amp;</tt></td></tr>
<tr>
<td>Postincrement</td>
<td><tt>i++</tt></td>
<td> </td>
<td>convertible to <tt>const X&amp;</tt></td></tr></tbody></table>
<p>
</p><hr>
<!--------------------------------------------------------------------------->
<h3><a name="concept_BidirectionalTraversalIterator"></a>Bidirectional Traversal
Iterator </h3>An iterator that can be incremented and decremented.
<h3>Refinement of</h3><a href="#concept_ForwardTraversalIterator">Forward
Traversal Iterator</a>
<h3>Associated types</h3>
<table border="1">
<tbody>
<tr>
<td>Traversal Category</td>
<td><tt>std::traversal_category&lt;X&gt;::type</tt></td>
<td>A type convertible to <tt>std::bidirectional_traversal_tag</tt>
</td></tr></tbody></table>
<h3>Valid expressions</h3>
<table border="1">
<tbody>
<tr>
<th>Name</th>
<th>Expression</th>
<th>Type requirements</th>
<th>Return type</th></tr>
<tr>
<td>Predecrement</td>
<td><tt>--i</tt></td>
<td> </td>
<td><tt>X&amp;</tt></td></tr>
<tr>
<td>Postdecrement</td>
<td><tt>i--</tt></td>
<td> </td>
<td>convertible to <tt>const X&amp;</tt></td></tr></tbody></table>
<p>
</p><hr>
<!--------------------------------------------------------------------------->
<h3><a name="concept_RandomAccessTraversalIterator"></a>Random Access Traversal
Iterator </h3>An iterator that provides constant-time methods for moving forward
and backward in arbitrary-sized steps.
<h3>Refinement of</h3><a href="#concept_BidirectionalTraversalIterator">Bidirectional
Traversal Iterator</a> and <a href="http://www.sgi.com/tech/stl/LessThanComparable.html">Less Than
Comparable</a> where <tt>&lt;</tt> is a total ordering
<h3>Associated types</h3>
<table border="1">
<tbody>
<tr>
<td>Traversal Category</td>
<td><tt>std::traversal_category&lt;X&gt;::type</tt></td>
<td>A type convertible to <tt>std::random_access_traversal_tag</tt>
</td></tr></tbody></table>
<h3>Valid expressions</h3>
<table border="1">
<tbody>
<tr>
<th>Name</th>
<th>Expression</th>
<th>Type requirements</th>
<th>Return type</th></tr>
<tr>
<td>Iterator addition</td>
<td><tt>i += n</tt></td>
<td> </td>
<td><tt>X&amp;</tt></td></tr>
<tr>
<td>Iterator addition</td>
<td><tt>i + n</tt> or <tt>n + i</tt></td>
<td> </td>
<td><tt>X</tt></td></tr>
<tr>
<td>Iterator subtraction</td>
<td><tt>i -= n</tt></td>
<td> </td>
<td><tt>X&amp;</tt></td></tr>
<tr>
<td>Iterator subtraction</td>
<td><tt>i - n</tt></td>
<td> </td>
<td><tt>X</tt></td></tr>
<tr>
<td>Difference</td>
<td><tt>i - j</tt></td>
<td> </td>
<td><tt>std::iterator_traits&lt;X&gt;::difference_type</tt></td></tr>
<tr>
<td>Element operator</td>
<td><tt>i[n]</tt></td>
<td><tt>X</tt> must also be a model of <a href="#concept_ReadableIterator">Readable
Iterator</a>. </td>
<td><tt>std::iterator_traits&lt;X&gt;::reference</tt></td></tr>
<tr>
<td>Element assignment</td>
<td><tt>i[n] = t</tt></td>
<td><tt>X</tt> must also be a model of <a href="#concept_WritableIterator">Writable
Iterator</a>.</td>
<td>unspecified</td></tr></tbody></table>
<p>
</p><hr>
<!-- LocalWords: HTML BGCOLOR FFFFFF TR TD Siek HREF mailto jsiek
--><!-- LocalWords: lsc edu tt const href http anubis dkuug dk JTC SC WG docs lt
--><!-- LocalWords: lwg html bool gt Sutter's htm Lvalue namespace std struct
--><!-- LocalWords: lvalue typename OldTraits reusability min iter prev inplace
--><!-- LocalWords: rvalue templated Preincrement Postincrement Predecrement
--><!-- LocalWords: Postdecrement
--></body></html>

View File

@@ -2,17 +2,18 @@
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<!--
== Copyright (c) Ronald Garcia, Jeremy Siek 2001
==
== Permission to use, copy, modify, distribute and sell this software
== and its documentation for any purpose is hereby granted without fee,
== provided that the above copyright notice appears in all copies and
== that both that copyright notice and this permission notice appear
== in supporting documentation. Jeremy Siek makes no
== representations about the suitability of this software for any
== purpose. It is provided "as is" without express or implied warranty.
-->
== Copyright 2002 The Trustees of Indiana University.
== Use, modification and distribution is subject to the Boost Software
== License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
== http://www.boost.org/LICENSE_1_0.txt)
== Boost.MultiArray Library
== Authors: Ronald Garcia
== Jeremy Siek
== Andrew Lumsdaine
== See http://www.boost.org/libs/multi_array for documentation.
-->
<head>
<title>Boost.MultiArray: Extra Notes</title>
</head>
@@ -58,6 +59,7 @@ The following is a list of work that is intended for the near future
<li> Pursue and document performance issues related to compilers and
implementation.
<li> More comprehensive examples of using the library components.
<li> Extensive rewrite of the user documentation to make it more accessible.
</ol>
<hr>
@@ -67,7 +69,7 @@ The following is a list of work that is intended for the near future
</address>
<!-- Created: Fri Jun 29 10:53:07 EST 2001 -->
<!-- hhmts start -->
Last modified: Mon May 6 16:28:15 EST 2002
Last modified: Wed Jan 8 18:09:46 EST 2003
<!-- hhmts end -->
</body>

View File

@@ -1,4 +1,4 @@
<html><head><meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type"><title>Boost.MultiArray Reference Manual</title><meta name="generator" content="DocBook XSL Stylesheets V1.49"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="article"><div class="titlepage"><div><h1 class="title"><a name="id170680"></a>Boost.MultiArray Reference Manual</h1></div><div><h3 class="author">Ronald Garcia</h3><div class="affiliation"><span class="orgname">Indiana University<br></span><span class="orgdiv">Open Systems Lab<br></span></div></div><div><p class="copyright">Copyright © 2002 Ronald Garcia</p></div><hr></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><a href="#synopsis">Library Synopsis</a></dt><dt><a href="#MultiArray">MultiArray Concept</a></dt><dd><dl><dt><a href="#id178376">Notation</a></dt><dt><a href="#id174783">Associated Types</a></dt><dt><a href="#id175406">Valid expressions</a></dt><dt><a href="#id248758">Complexity guarantees</a></dt><dt><a href="#id248780">Invariants</a></dt><dt><a href="#view_types">Associated Types for Views</a></dt><dd><dl><dt><a href="#index_range">index_range</a></dt><dt><a href="#index_gen">index_gen</a></dt></dl></dd><dt><a href="#id250491">Models</a></dt></dl></dd><dt><a href="#array_types">Array Components</a></dt><dd><dl><dt><a href="#multi_array">multi_array</a></dt><dt><a href="#multi_array_ref">multi_array_ref</a></dt><dt><a href="#const_multi_array_ref">const_multi_array_ref</a></dt></dl></dd><dt><a href="#auxiliary">Auxiliary Components</a></dt><dd><dl><dt><a href="#multi_array_types">multi_array_types</a></dt><dt><a href="#extent_range">extent_range</a></dt><dt><a href="#extent_gen">extent_gen</a></dt><dt><a href="#id250788">Global Objects</a></dt><dd><dl><dt><a href="#extents">extents</a></dt><dt><a href="#indices">indices</a></dt></dl></dd><dt><a href="#generators">View and SubArray Generators</a></dt><dt><a href="#memory_layout">Memory Layout Specifiers</a></dt><dd><dl><dt><a href="#c_storage_order">c_storage_order</a></dt><dt><a href="#fortran_storage_order">fortran_storage_order</a></dt><dt><a href="#general_storage_order">general_storage_order</a></dt></dl></dd></dl></dd></dl></div><fake><p>Boost.MultiArray is composed of several components.
<html><head><meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type"><title>Boost.MultiArray Reference Manual</title><meta name="generator" content="DocBook XSL Stylesheets V1.49"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="article"><div class="titlepage"><div><h1 class="title"><a name="id170468"></a>Boost.MultiArray Reference Manual</h1></div><div><h3 class="author">Ronald Garcia</h3><div class="affiliation"><span class="orgname">Indiana University<br></span><span class="orgdiv">Open Systems Lab<br></span></div></div><div><p class="copyright">Copyright © 2002 Ronald Garcia</p></div><hr></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><a href="#synopsis">Library Synopsis</a></dt><dt><a href="#MultiArray">MultiArray Concept</a></dt><dd><dl><dt><a href="#id179006">Notation</a></dt><dt><a href="#id175494">Associated Types</a></dt><dt><a href="#id250868">Valid expressions</a></dt><dt><a href="#id251805">Complexity guarantees</a></dt><dt><a href="#id251847">Invariants</a></dt><dt><a href="#view_types">Associated Types for Views</a></dt><dd><dl><dt><a href="#index_range">index_range</a></dt><dt><a href="#index_gen">index_gen</a></dt></dl></dd><dt><a href="#id253521">Models</a></dt></dl></dd><dt><a href="#array_types">Array Components</a></dt><dd><dl><dt><a href="#multi_array">multi_array</a></dt><dt><a href="#multi_array_ref">multi_array_ref</a></dt><dt><a href="#const_multi_array_ref">const_multi_array_ref</a></dt></dl></dd><dt><a href="#auxiliary">Auxiliary Components</a></dt><dd><dl><dt><a href="#multi_array_types">multi_array_types</a></dt><dt><a href="#extent_range">extent_range</a></dt><dt><a href="#extent_gen">extent_gen</a></dt><dt><a href="#id253863">Global Objects</a></dt><dd><dl><dt><a href="#extents">extents</a></dt><dt><a href="#indices">indices</a></dt></dl></dd><dt><a href="#generators">View and SubArray Generators</a></dt><dt><a href="#memory_layout">Memory Layout Specifiers</a></dt><dd><dl><dt><a href="#c_storage_order">c_storage_order</a></dt><dt><a href="#fortran_storage_order">fortran_storage_order</a></dt><dt><a href="#general_storage_order">general_storage_order</a></dt></dl></dd></dl></dd></dl></div><fake><p>Boost.MultiArray is composed of several components.
The MultiArray concept defines a generic interface to multidimensional
containers.
<tt>multi_array</tt> is a general purpose container class
@@ -150,7 +150,7 @@ number of possible element layouts. For example, the elements of a 2
dimensional array can be stored by row (i.e., the elements of each row
are stored contiguously) or by column (i.e., the elements of each
column are stored contiguously).
</p></fake><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="id178376"></a>Notation</h3></div></div><fake><p>What follows are the descriptions of symbols that will be used
</p></fake><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="id179006"></a>Notation</h3></div></div><fake><p>What follows are the descriptions of symbols that will be used
to describe the MultiArray interface.</p></fake><div class="table"><p><b>Table 1. Notation</b></p><table summary="Notation" border="1"><colgroup><col><col></colgroup><tbody><tr><td><tt>A</tt></td><td>A type that is a model of MultiArray
</td></tr><tr><td><tt>a</tt></td><td>An object of type <tt>A</tt></td></tr><tr><td><tt>NumDims</tt></td><td>The numeric dimension parameter associated with
<tt>A</tt>.</td></tr><tr><td><tt>Dims</tt></td><td>Some numeric dimension parameter such that
@@ -158,7 +158,7 @@ to describe the MultiArray interface.</p></fake><div class="table"><p><b>Table 1
</td></tr><tr><td><tt>indices</tt></td><td>An object created by some number of chained calls
to <tt>index_gen::operator[](index_range)</tt>.</td></tr><tr><td><tt>index_list</tt></td><td>An object whose type models
<a href="../../utility/Collection.html" target="_top">Collection</a></td></tr><tr><td><tt>idx</tt></td><td>A signed integral value.</td></tr><tr><td><tt>tmp</tt></td><td>An object of type
<tt>boost::array&lt;index,NumDims&gt;</tt></td></tr></tbody></table></div></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="id174783"></a>Associated Types</h3></div></div><fake><p>
<tt>boost::array&lt;index,NumDims&gt;</tt></td></tr></tbody></table></div></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="id175494"></a>Associated Types</h3></div></div><fake><p>
</p></fake><div class="table"><p><b>Table 2. Associated Types</b></p><table summary="Associated Types" border="1"><colgroup><col><col></colgroup><thead><tr><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><tt>value_type</tt></td><td>This is the value type of the container.
If <tt>NumDims == 1</tt>, then this is
<tt>element</tt>. Otherwise, this is the value type of the
@@ -228,7 +228,7 @@ It models MultiArray.
</td></tr><tr><td><tt>template
const_array_view&lt;Dims&gt;::type</tt></td><td>
This is the const view type with <tt>Dims</tt> dimensions.
</td></tr></tbody></table></div></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="id175406"></a>Valid expressions</h3></div></div><div class="table"><p><b>Table 3. Valid Expressions</b></p><table summary="Valid Expressions" border="1"><colgroup><col><col><col></colgroup><thead><tr><th>Expression</th><th>Return type</th><th>Semantics</th></tr></thead><tbody><tr><td><tt>a.shape()</tt></td><td><tt>const size_type*</tt></td><td>
</td></tr></tbody></table></div></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="id250868"></a>Valid expressions</h3></div></div><div class="table"><p><b>Table 3. Valid Expressions</b></p><table summary="Valid Expressions" border="1"><colgroup><col><col><col></colgroup><thead><tr><th>Expression</th><th>Return type</th><th>Semantics</th></tr></thead><tbody><tr><td><tt>a.shape()</tt></td><td><tt>const size_type*</tt></td><td>
This returns a list of <tt>NumDims</tt> elements specifying the
extent of each array dimension.
</td></tr><tr><td><tt>a.strides()</tt></td><td><tt>const index*</tt></td><td>
@@ -315,11 +315,11 @@ type must model <a href="http://www.sgi.com/tech/stl/EqualityComparable.html" ta
expression to be valid.</td></tr><tr><td><tt>a &gt;= b</tt></td><td>bool</td><td>This performs a lexicographical comparison of the
values of <tt>a</tt> and <tt>b</tt>. The element
type must model <a href="http://www.sgi.com/tech/stl/LessThanComparable.html" target="_top">LessThanComparable</a> for this
expression to be valid.</td></tr></tbody></table></div></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="id248758"></a>Complexity guarantees</h3></div></div><tt>begin()</tt> and <tt>end()</tt> execute in amortized
expression to be valid.</td></tr></tbody></table></div></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="id251805"></a>Complexity guarantees</h3></div></div><tt>begin()</tt> and <tt>end()</tt> execute in amortized
constant time.
<tt>size()</tt> executes in at most linear time in the
MultiArray's size.
</div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="id248780"></a>Invariants</h3></div></div><div class="table"><p><b>Table 4. Invariants</b></p><table summary="Invariants" border="1"><colgroup><col><col></colgroup><tbody><tr><td>Valid range</td><td><tt>[a.begin(),a.end())</tt> is a valid range.
</div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="id251847"></a>Invariants</h3></div></div><div class="table"><p><b>Table 4. Invariants</b></p><table summary="Invariants" border="1"><colgroup><col><col></colgroup><tbody><tr><td>Valid range</td><td><tt>[a.begin(),a.end())</tt> is a valid range.
</td></tr><tr><td>Range size</td><td><tt>a.size() == std::distance(a.begin(),a.end());</tt>.
</td></tr><tr><td>Completeness</td><td>
Iteration through the range
@@ -421,7 +421,7 @@ range, <tt>index_range(idx,idx).</tt> Note that this is NOT
equivalent to <tt>x[index_range(idx,idx)].</tt>, which will
return an object of type
<tt>gen_type&lt;Dims+1,Ranges+1&gt;::type</tt>.
</td></tr></tbody></table></div></div></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="id250491"></a>Models</h3></div></div><div class="itemizedlist"><ul type="disc"><li><tt>multi_array</tt></li><li><tt>multi_array_ref</tt></li><li><tt>const_multi_array_ref</tt></li><li><tt>template array_view&lt;Dims&gt;::type</tt></li><li><tt>template const_array_view&lt;Dims&gt;::type</tt></li><li><tt>template subarray&lt;Dims&gt;::type</tt></li><li><tt>template const_subarray&lt;Dims&gt;::type</tt></li></ul></div></div></div><div class="sect1"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="array_types"></a>Array Components</h2></div></div><fake><p>
</td></tr></tbody></table></div></div></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="id253521"></a>Models</h3></div></div><div class="itemizedlist"><ul type="disc"><li><tt>multi_array</tt></li><li><tt>multi_array_ref</tt></li><li><tt>const_multi_array_ref</tt></li><li><tt>template array_view&lt;Dims&gt;::type</tt></li><li><tt>template const_array_view&lt;Dims&gt;::type</tt></li><li><tt>template subarray&lt;Dims&gt;::type</tt></li><li><tt>template const_subarray&lt;Dims&gt;::type</tt></li></ul></div></div></div><div class="sect1"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="array_types"></a>Array Components</h2></div></div><fake><p>
Boost.MultiArray defines an array class,
<tt>multi_array</tt>, and two adapter classes,
<tt>multi_array_ref</tt> and
@@ -552,13 +552,15 @@ public:
typedef *implementation-defined* const_iterator;
typedef *implementation-defined* reverse_iterator;
typedef *implementation-defined* const_reverse_iterator;
typedef multi_array_types::size_type size_type;
typedef multi_array_types::index index;
typedef multi_array_types::index_gen index_gen;
typedef multi_array_types::index_range index_range;
typedef multi_array_types::extent_gen extent_gen;
typedef multi_array_types::extent_range extent_range;
typedef multi_array_types::size_type size_type;
typedef multi_array_types::index index;
typedef multi_array_types::index_gen index_gen;
typedef multi_array_types::index_range index_range;
typedef multi_array_types::extent_gen extent_gen;
typedef multi_array_types::extent_range extent_range;
typedef *implementation-defined* storage_order_type;
// template typedefs
template &lt;std::size_t Dims&gt; struct subarray;
template &lt;std::size_t Dims&gt; struct const_subarray;
@@ -568,12 +570,14 @@ public:
// constructors and destructors
multi_array();
template &lt;typename ExtentList&gt;
explicit multi_array(const ExtentList&amp; sizes,
const storage_order&amp; store = c_storage_order(),
const storage_order_type&amp; store = c_storage_order(),
const Allocator&amp; alloc = Allocator());
explicit multi_array(const extents_tuple&amp; ranges,
const storage_order&amp; store = c_storage_order(),
const storage_order_type&amp; store = c_storage_order(),
const Allocator&amp; alloc = Allocator());
multi_array(const multi_array&amp; x);
~multi_array();
@@ -616,6 +620,7 @@ public:
const size_type* shape() const;
const index* strides() const;
const index* index_bases() const;
const storage_order_type&amp; storage_order() const;
// comparators
bool operator==(const multi_array&amp; rhs);
@@ -632,11 +637,12 @@ public:
void reshape(const SizeList&amp; sizes)
template &lt;typename BaseList&gt; void reindex(const BaseList&amp; values);
void reindex(index value);
multi_array&amp; resize(extents_tuple&amp; extents);
};
</pre></p><p><b>Constructors. </b><div class="variablelist"><dl><dt><span class="term"><pre class="programlisting">template &lt;typename ExtentList&gt;
explicit multi_array(const ExtentList&amp; sizes,
const storage_order&amp; store = c_storage_order(),
const storage_order_type&amp; store = c_storage_order(),
const Allocator&amp; alloc = Allocator());
</pre></span></dt><dd><fake><p>
This constructs a <tt>multi_array</tt> using the specified
@@ -649,7 +655,7 @@ allocate the contained elements.
<tt>ExtentList</tt> must model <a href="../../utility/Collection.html" target="_top">Collection</a>.
</p><p><b>Preconditions. </b><tt>sizes.size() == NumDims;</tt></p></dd><dt><span class="term">
<pre class="programlisting">explicit multi_array(extent_gen::gen_type&lt;NumDims&gt;::type ranges,
const storage_order&amp; store = c_storage_order(),
const storage_order_type&amp; store = c_storage_order(),
const Allocator&amp; alloc = Allocator());
</pre></span></dt><dd><fake><p>
This constructs a <tt>multi_array</tt> using the specified
@@ -668,7 +674,10 @@ copy of <tt>x</tt>.
</p></fake><p><b>Complexity. </b> This performs O(<tt>x.num_elements()</tt>) calls to
<tt>element</tt>'s copy
constructor.
</p></dd></dl></div><p><b>Note on Constructors. </b>
</p></dd><dt><span class="term"><pre class="programlisting">
multi_array();
</pre></span></dt><dd><fake><p>This constructs a <tt>multi_array</tt> whose shape is (0,...,0) and contains no elements.
</p></fake></dd></dl></div><p><b>Note on Constructors. </b>
The <tt>multi_array</tt> construction expressions,
<pre class="programlisting">
multi_array&lt;int,3&gt; A(boost::extents[5][4][3]);
@@ -705,7 +714,19 @@ void assign(InputIterator begin, InputIterator end);
The <tt>assign</tt> member function performs
O(<tt>this-&gt;num_elements()</tt>) calls to
<tt>ValueType</tt>'s copy constructor.
</p></dd></dl></div></p></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="multi_array_ref"></a><tt>multi_array_ref</tt></h3></div></div><fake><p>
</p></dd><dt><span class="term">
<pre class="programlisting">multi_array&amp; resize(extent_gen::gen_type&lt;NumDims&gt;::type ranges);
</pre></span></dt><dd><fake><p>
This function resizes an array to the shape specified by
<tt>ranges</tt>. The contents of the array are preserved
whenever possible; if the new array size is smaller, then some data will
be lost. Any new elements created by resizing the array are initialized with
the <tt>element</tt> default constructor.
</p></fake></dd></dl></div></p><p><b>Queries. </b><div class="variablelist"><dl><dt><span class="term"><pre class="programlisting">
storage_order_type&amp; storage_order() const;
</pre>
</span></dt><dd><fake><p>This query returns the storage order object associated with the
<tt>multi_array</tt> in question. It can be used to construct a new array with the same storage order.</p></fake></dd></dl></div></p></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="multi_array_ref"></a><tt>multi_array_ref</tt></h3></div></div><fake><p>
<tt>multi_array_ref</tt> is a multi-dimensional container
adaptor. It provides the MultiArray interface over any contiguous
block of elements. <tt>multi_array_ref</tt> exports the
@@ -738,12 +759,13 @@ public:
typedef *implementation-defined* const_iterator;
typedef *implementation-defined* reverse_iterator;
typedef *implementation-defined* const_reverse_iterator;
typedef multi_array_types::size_type size_type;
typedef multi_array_types::index index;
typedef multi_array_types::index_gen index_gen;
typedef multi_array_types::index_range index_range;
typedef multi_array_types::extent_gen extent_gen;
typedef multi_array_types::extent_range extent_range;
typedef multi_array_types::size_type size_type;
typedef multi_array_types::index index;
typedef multi_array_types::index_gen index_gen;
typedef multi_array_types::index_range index_range;
typedef multi_array_types::extent_gen extent_gen;
typedef multi_array_types::extent_range extent_range;
typedef *implementation-defined* storage_order_type;
// template typedefs
template &lt;std::size_t Dims&gt; struct subarray;
@@ -756,9 +778,9 @@ public:
template &lt;typename ExtentList&gt;
explicit multi_array_ref(element* data, const ExtentList&amp; sizes,
const storage_order&amp; store = c_storage_order());
const storage_order_type&amp; store = c_storage_order());
explicit multi_array_ref(element* data, const extents_tuple&amp; ranges,
const storage_order&amp; store = c_storage_order());
const storage_order_type&amp; store = c_storage_order());
multi_array_ref(const multi_array_ref&amp; x);
~multi_array_ref();
@@ -800,6 +822,7 @@ public:
const size_type* shape() const;
const index* strides() const;
const index* index_bases() const;
const storage_order_type&amp; storage_order() const;
// comparators
bool operator==(const multi_array_ref&amp; rhs);
@@ -895,12 +918,13 @@ public:
typedef *implementation-defined* const_iterator;
typedef *implementation-defined* reverse_iterator;
typedef *implementation-defined* const_reverse_iterator;
typedef multi_array_types::size_type size_type;
typedef multi_array_types::index index;
typedef multi_array_types::index_gen index_gen;
typedef multi_array_types::index_range index_range;
typedef multi_array_types::extent_gen extent_gen;
typedef multi_array_types::extent_range extent_range;
typedef multi_array_types::size_type size_type;
typedef multi_array_types::index index;
typedef multi_array_types::index_gen index_gen;
typedef multi_array_types::index_range index_range;
typedef multi_array_types::extent_gen extent_gen;
typedef multi_array_types::extent_range extent_range;
typedef *implementation-defined* storage_order_type;
// template typedefs
template &lt;std::size_t Dims&gt; struct subarray;
@@ -913,9 +937,9 @@ public:
template &lt;typename ExtentList&gt;
explicit const_multi_array_ref(const element* data, const ExtentList&amp; sizes,
const storage_order&amp; store = c_storage_order());
const storage_order_type&amp; store = c_storage_order());
explicit const_multi_array_ref(const element* data, const extents_tuple&amp; ranges,
const storage_order&amp; store = c_storage_order());
const storage_order_type&amp; store = c_storage_order());
const_multi_array_ref(const const_multi_array_ref&amp; x);
~const_multi_array_ref();
@@ -944,6 +968,7 @@ public:
const size_type* shape() const;
const index* strides() const;
const index* index_bases() const;
const storage_order_type&amp; storage_order() const;
// comparators
bool operator==(const const_multi_array_ref&amp; rhs);
@@ -1078,7 +1103,7 @@ operator[](index idx) const;</tt></span></dt><dd><fake><p>This function returns
<tt>extent_range</tt> objects in addition to
<tt>extent_range(0,idx).</tt> This function gives the array
constructors a similar syntax to traditional C multidimensional array
declaration.</p></fake></dd></dl></div></p></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="id250788"></a>Global Objects</h3></div></div><fake><p>For syntactic convenience, Boost.MultiArray defines two
declaration.</p></fake></dd></dl></div></p></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="id253863"></a>Global Objects</h3></div></div><fake><p>For syntactic convenience, Boost.MultiArray defines two
global objects as part of its
interface. These objects play the role of object generators;
expressions involving them create other objects of interest.

View File

@@ -2,15 +2,17 @@
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<!--
== Copyright (c) Ronald Garcia, Jeremy Siek 2001
==
== Permission to use, copy, modify, distribute and sell this software
== and its documentation for any purpose is hereby granted without fee,
== provided that the above copyright notice appears in all copies and
== that both that copyright notice and this permission notice appear
== in supporting documentation. Jeremy Siek makes no
== representations about the suitability of this software for any
== purpose. It is provided "as is" without express or implied warranty.
== Copyright 2002 The Trustees of Indiana University.
== Use, modification and distribution is subject to the Boost Software
== License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
== http://www.boost.org/LICENSE_1_0.txt)
== Boost.MultiArray Library
== Authors: Ronald Garcia
== Jeremy Siek
== Andrew Lumsdaine
== See http://www.boost.org/libs/multi_array for documentation.
-->
<head>
<title>

View File

@@ -2,17 +2,18 @@
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<!--
== Copyright (c) Ronald Garcia, Jeremy Siek 2001
==
== Permission to use, copy, modify, distribute and sell this software
== and its documentation for any purpose is hereby granted without fee,
== provided that the above copyright notice appears in all copies and
== that both that copyright notice and this permission notice appear
== in supporting documentation. Jeremy Siek makes no
== representations about the suitability of this software for any
== purpose. It is provided "as is" without express or implied warranty.
-->
== Copyright 2002 The Trustees of Indiana University.
== Use, modification and distribution is subject to the Boost Software
== License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
== http://www.boost.org/LICENSE_1_0.txt)
== Boost.MultiArray Library
== Authors: Ronald Garcia
== Jeremy Siek
== Andrew Lumsdaine
== See http://www.boost.org/libs/multi_array for documentation.
-->
<head>
<title>The Boost Multidimensional Array Library (Boost.MultiArray)</title>
</head>
@@ -29,22 +30,25 @@
<h2>Synopsis</h2>
<p>
The Boost Multidimensional Array Library provides
a multidimensional container of elements and semantically equivalent
The Boost Multidimensional Array Library provides a class template for
multidimensional arrays, as well as semantically equivalent
adaptors for arrays of contiguous data. The classes in this library
behave as closely as possible to STL Containers, providing a more
convenient and efficient implementation than the equivalent "vectors
of vectors" formulation of N-dimensional arrays. Arrays are not
re-sizable once constructed, but may be sliced and shaped, providing
alternate views of the contained data.
implement a common interface, formalized as a generic programming
concept. The interface design is in line with the precedent set by the
C++ Standard Library containers. Boost MultiArray is a more efficient
and convenient way to express N-dimensional arrays than existing
alternatives (especially the
<tt>std::vector&lt;std::vector&lt;...&gt;&gt;</tt> formulation
of N-dimensional arrays). The arrays provided by the library may be
accessed using the familiar syntax of native C++ arrays. Additional
features, such as resizing, reshaping, and creating views are
available (and described below).
<h2>Table of Contents</h2>
<ol>
<li><a href="#sec_rationale">Rationale</a>
<li><a href="#sec_related">Related Work</a>
<li><a href="#sec_introduction">Introduction</a>
<li><a href="#sec_example">Short Example</a>
@@ -69,58 +73,48 @@ alternate views of the contained data.
<li><a href="#sec_concepts">MultiArray Concept</a>
<li><a href="#sec_testcases">Test Cases</a>
<li><a href="#sec_related">Related Work</a>
<li><a href="#sec_credits">Credits</a>
</ol>
<a name="sec_rationale"></a>
<h2>Rationale</h2>
<a name="sec_introduction"></a>
<h2>Introduction</h2>
The C++ standard library provides several generic containers, but
it does not provide any multidimensional array types.
Using <tt>std::vector</tt>, you can simulate N-dimensional arrays as
"nested vectors", but the
interface is unwieldy and the memory overhead can be quite high. You can also
use a native C++ arrays (i.e. <tt>int arr[2][2][2];</tt>),
or a dynamically allocated array of contigous data which you treat as
a multidimensional array. Using
<a href="../../array_traits/index.html">array_traits</a>,
you can extract from a statically defined C++ array
iterators over its dimensions.
In either case, however, dimensional data may be lost if it is
passed to a function that is not properly specialized to accept
it. Beyond the above, neither the <tt>std::vector</tt> nor C++ array-based
solution provides a convenient method of honing in upon a specific
subset or "view" of a multi-dimensional array.
<p>
The C++ standard library provides several generic containers, but it
does not provide any multidimensional array types. The
<tt>std::vector</tt> class template can be used to implement
N-dimensional arrays, for example expressing a 2-dimensional array of
<tt>double</tt> elements using the type
<tt>std::vector&lt;std::vector&lt;double&gt;&gt;</tt>, but the
resulting interface is unwieldy and the memory overhead can be quite
high. Native C++ arrays (i.e. <tt>int arr[2][2][2];</tt>) do not
immediately interoperate well with the C++ Standard Library, and they
also lose information at function call boundaries (specifically the
extent of the last dimension). Finally, a dynamically allocated
contiguous block of elements can be treated as an array, though this
method requires manual bookkeeping that is error prone and obfuscates
the intent of the programmer.
</p>
<p>Boost.MultiArray defines the MultiArray concept, a generic
interface for N-dimensional containers. The primary components of
this library model MultiArray and support adapting user data
to model MultiArray as well.
<a name="sec_related"></a>
<h2>Related Work</h2>
<a href="../../array/index.htm">boost::array</a>
and <a href="http://www.sgi.com/tech/stl/Vector.html">std::vector</a> are
one-dimensional containers of user data. Both manage their own
memory. <tt>std::valarray</tt> is a low-level
C++ Standard Library component
meant to provide portable high performance for numerical applications.
<a href="http://www.oonumerics.org/blitz/">Blitz++</a> is
an array library developed by Todd
Veldhuizen. It uses
advanced C++ techniques to provide near-Fortran performance for
array-based numerical applications.
<a href="../../array_traits/index.html">array_traits</a> is a beta
library distributed with Boost that provides a means to create
iterators over native C++ arrays.
This library is analogous to
<a href="">boost::array</a> in that it augments C style N-dimensional
arrays, as <tt>boost::array</tt> does for C one-dimensional arrays.
<p>
The Boost MultiArray library enhances the C++ standard containers with
versatile multi-dimensional array abstractions. It includes a general
array class template and native array adaptors that support idiomatic
array operations and interoperate with C++ Standard Library containers
and algorithms. The arrays share a common interface, expressed as a
generic programming in terms of which generic array algorithms can be
implemented.
</p>
<p>
This document is meant to provide an introductory tutorial and user's
guide for the most basic and common usage patterns of MultiArray
components. The <a href="./reference.html">reference manual</a>
provides more complete and formal documentation of library features.
</p>
<a name="sec_example"></a>
<h2>Short Example</h2>
@@ -569,6 +563,30 @@ Boost.MultiArray comes with a suite of test cases meant to exercise
the features and semantics of the library. A description of the test
cases can be found <a href="./test_cases.html">here</a>.
<a name="sec_related"></a>
<h2>Related Work</h2>
<a href="../../array/index.html">boost::array</a>
and <a href="http://www.sgi.com/tech/stl/Vector.html">std::vector</a> are
one-dimensional containers of user data. Both manage their own
memory. <tt>std::valarray</tt> is a low-level
C++ Standard Library component
meant to provide portable high performance for numerical applications.
<a href="http://www.oonumerics.org/blitz/">Blitz++</a> is
an array library developed by Todd
Veldhuizen. It uses
advanced C++ techniques to provide near-Fortran performance for
array-based numerical applications.
<b>array_traits</b> is a beta library, formerly distributed with
Boost, that provides a means to create iterators over native C++
arrays.
This library is analogous to
<a href="">boost::array</a> in that it augments C style N-dimensional
arrays, as <tt>boost::array</tt> does for C one-dimensional arrays.
<a name="sec_credits"></a>
<h2>Credits</h2>
<ul>

View File

@@ -46,12 +46,13 @@ public:
typedef *implementation-defined* const_iterator;
typedef *implementation-defined* reverse_iterator;
typedef *implementation-defined* const_reverse_iterator;
typedef multi_array_types::size_type size_type;
typedef multi_array_types::index index;
typedef multi_array_types::index_gen index_gen;
typedef multi_array_types::index_range index_range;
typedef multi_array_types::extent_gen extent_gen;
typedef multi_array_types::extent_range extent_range;
typedef multi_array_types::size_type size_type;
typedef multi_array_types::index index;
typedef multi_array_types::index_gen index_gen;
typedef multi_array_types::index_range index_range;
typedef multi_array_types::extent_gen extent_gen;
typedef multi_array_types::extent_range extent_range;
typedef *implementation-defined* storage_order_type;
// template typedefs
template <std::size_t Dims> struct subarray;
@@ -64,9 +65,9 @@ public:
template <typename ExtentList>
explicit const_multi_array_ref(const element* data, const ExtentList& sizes,
const storage_order& store = c_storage_order());
const storage_order_type& store = c_storage_order());
explicit const_multi_array_ref(const element* data, const extents_tuple& ranges,
const storage_order& store = c_storage_order());
const storage_order_type& store = c_storage_order());
const_multi_array_ref(const const_multi_array_ref& x);
~const_multi_array_ref();
@@ -95,6 +96,7 @@ public:
const size_type* shape() const;
const index* strides() const;
const index* index_bases() const;
const storage_order_type& storage_order() const;
// comparators
bool operator==(const const_multi_array_ref& rhs);

View File

@@ -1,7 +1,7 @@
<?xml version='1.0' encoding="ISO-Latin-1" ?>
<!DOCTYPE article
PUBLIC "-//OASIS//DTD DocBook XML MathML V4.1.2//EN"
"/home/rgarcia/docbook-xml/docbookx.dtd"
"/u/garcia/docbook-xml/docbookx.dtd"
>
<article>

View File

@@ -44,13 +44,15 @@ public:
typedef *implementation-defined* const_iterator;
typedef *implementation-defined* reverse_iterator;
typedef *implementation-defined* const_reverse_iterator;
typedef multi_array_types::size_type size_type;
typedef multi_array_types::index index;
typedef multi_array_types::index_gen index_gen;
typedef multi_array_types::index_range index_range;
typedef multi_array_types::extent_gen extent_gen;
typedef multi_array_types::extent_range extent_range;
typedef multi_array_types::size_type size_type;
typedef multi_array_types::index index;
typedef multi_array_types::index_gen index_gen;
typedef multi_array_types::index_range index_range;
typedef multi_array_types::extent_gen extent_gen;
typedef multi_array_types::extent_range extent_range;
typedef *implementation-defined* storage_order_type;
// template typedefs
template <std::size_t Dims> struct subarray;
template <std::size_t Dims> struct const_subarray;
@@ -60,12 +62,14 @@ public:
// constructors and destructors
multi_array();
template <typename ExtentList>
explicit multi_array(const ExtentList& sizes,
const storage_order& store = c_storage_order(),
const storage_order_type& store = c_storage_order(),
const Allocator& alloc = Allocator());
explicit multi_array(const extents_tuple& ranges,
const storage_order& store = c_storage_order(),
const storage_order_type& store = c_storage_order(),
const Allocator& alloc = Allocator());
multi_array(const multi_array& x);
~multi_array();
@@ -108,6 +112,7 @@ public:
const size_type* shape() const;
const index* strides() const;
const index* index_bases() const;
const storage_order_type& storage_order() const;
// comparators
bool operator==(const multi_array& rhs);
@@ -124,6 +129,7 @@ public:
void reshape(const SizeList& sizes)
template <typename BaseList> void reindex(const BaseList& values);
void reindex(index value);
multi_array& resize(extents_tuple& extents);
};
]]>
</programlisting>
@@ -136,7 +142,7 @@ public:
<varlistentry>
<term><programlisting>template &lt;typename ExtentList&gt;
explicit multi_array(const ExtentList&amp; sizes,
const storage_order&amp; store = c_storage_order(),
const storage_order_type&amp; store = c_storage_order(),
const Allocator&amp; alloc = Allocator());
</programlisting></term>
<listitem>
@@ -166,7 +172,7 @@ allocate the contained elements.
<varlistentry>
<term>
<programlisting><![CDATA[explicit multi_array(extent_gen::gen_type<NumDims>::type ranges,
const storage_order& store = c_storage_order(),
const storage_order_type& store = c_storage_order(),
const Allocator& alloc = Allocator());]]>
</programlisting></term>
<listitem>
@@ -203,6 +209,16 @@ constructor.
</listitem>
</varlistentry>
<varlistentry>
<term><programlisting>
<![CDATA[multi_array();]]>
</programlisting></term>
<listitem>
<para>This constructs a <literal>multi_array</literal> whose shape is (0,...,0) and contains no elements.
</para>
</listitem>
</varlistentry>
</variablelist>
<formalpara><title>Note on Constructors</title>
@@ -294,6 +310,42 @@ O(<literal>this->num_elements()</literal>) calls to
</formalpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<programlisting><![CDATA[multi_array& resize(extent_gen::gen_type<NumDims>::type ranges);]]>
</programlisting></term>
<listitem>
<para>
This function resizes an array to the shape specified by
<literal>ranges</literal>. The contents of the array are preserved
whenever possible; if the new array size is smaller, then some data will
be lost. Any new elements created by resizing the array are initialized with
the <literal>element</literal> default constructor.
</para>
</listitem>
</varlistentry>
</variablelist>
</formalpara>
<formalpara>
<title>Queries</title>
<variablelist>
<varlistentry>
<term><programlisting>
<![CDATA[storage_order_type& storage_order() const;]]>
</programlisting>
</term>
<listitem>
<para>This query returns the storage order object associated with the
<literal>multi_array</literal> in question. It can be used to construct a new array with the same storage order.</para>
</listitem>
</varlistentry>
</variablelist>
</formalpara>
</sect2>

View File

@@ -45,12 +45,13 @@ public:
typedef *implementation-defined* const_iterator;
typedef *implementation-defined* reverse_iterator;
typedef *implementation-defined* const_reverse_iterator;
typedef multi_array_types::size_type size_type;
typedef multi_array_types::index index;
typedef multi_array_types::index_gen index_gen;
typedef multi_array_types::index_range index_range;
typedef multi_array_types::extent_gen extent_gen;
typedef multi_array_types::extent_range extent_range;
typedef multi_array_types::size_type size_type;
typedef multi_array_types::index index;
typedef multi_array_types::index_gen index_gen;
typedef multi_array_types::index_range index_range;
typedef multi_array_types::extent_gen extent_gen;
typedef multi_array_types::extent_range extent_range;
typedef *implementation-defined* storage_order_type;
// template typedefs
template <std::size_t Dims> struct subarray;
@@ -63,9 +64,9 @@ public:
template <typename ExtentList>
explicit multi_array_ref(element* data, const ExtentList& sizes,
const storage_order& store = c_storage_order());
const storage_order_type& store = c_storage_order());
explicit multi_array_ref(element* data, const extents_tuple& ranges,
const storage_order& store = c_storage_order());
const storage_order_type& store = c_storage_order());
multi_array_ref(const multi_array_ref& x);
~multi_array_ref();
@@ -107,6 +108,7 @@ public:
const size_type* shape() const;
const index* strides() const;
const index* index_bases() const;
const storage_order_type& storage_order() const;
// comparators
bool operator==(const multi_array_ref& rhs);

View File

@@ -21,7 +21,7 @@
<orgname>BOOST</orgname>
<copyright>
<year>2002</year>
<holder>Ronald Garcia</holder>
<holder>The Trustees of Indiana University</holder>
</copyright>
</articleinfo>

View File

@@ -1,3 +1,15 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
#include <cassert>
#include "boost/multi_array.hpp"
#include "boost/cstdlib.hpp"

View File

@@ -1,3 +1,15 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
#include <cassert>
#include "boost/multi_array.hpp"

View File

@@ -1,3 +1,15 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
#ifndef FOR_EACH_HPP
#define FOR_EACH_HPP

View File

@@ -1,3 +1,15 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
// foreach_test.cpp
// Let's see if this stuff works

View File

@@ -1,3 +1,15 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
#include "boost/multi_array.hpp"
#include "for_each.hpp"
#include <algorithm>

View File

@@ -1,3 +1,15 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
#include <cassert>
#include "boost/multi_array.hpp"

View File

@@ -1,3 +1,15 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
#include <iostream>
#include "boost/multi_array.hpp"

View File

@@ -1,3 +1,15 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
#include "boost/multi_array.hpp"
#include "boost/cstdlib.hpp"

View File

@@ -1,3 +1,15 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
#include "boost/multi_array.hpp"
#include "boost/cstdlib.hpp"

View File

@@ -1,14 +1,14 @@
// Copyright (C) 2002 Ronald Garcia
//
// Permission to copy, use, sell and distribute this software is granted
// provided this copyright notice appears in all copies.
// Permission to modify the code and to distribute modified code is granted
// provided this copyright notice appears in all copies, and a notice
// that the code was modified is included with the copyright notice.
//
// This software is provided "as is" without express or implied warranty,
// and with no claim as to its suitability for any purpose.
//
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
#ifndef BOOST_MULTI_ARRAY_RG071801_HPP
#define BOOST_MULTI_ARRAY_RG071801_HPP
@@ -33,22 +33,33 @@
#include <numeric>
#include <vector>
namespace boost {
namespace detail {
namespace multi_array {
struct populate_index_ranges {
multi_array_types::index_range
operator()(multi_array_types::index base,
multi_array_types::size_type extent) {
return multi_array_types::index_range(base,base+extent);
}
};
} //namespace multi_array
} // namespace detail
template<typename T, std::size_t NumDims,
typename Allocator>
class multi_array :
class multi_array :
public multi_array_ref<T,NumDims>
{
typedef multi_array_ref<T,NumDims> super_type;
public:
public:
typedef typename super_type::value_type value_type;
typedef typename super_type::reference reference;
typedef typename super_type::const_reference const_reference;
typedef typename super_type::iterator iterator;
typedef typename super_type::const_iterator const_iterator;
typedef typename super_type::iter_base iter_base;
typedef typename super_type::const_iter_base const_iter_base;
typedef typename super_type::reverse_iterator reverse_iterator;
typedef typename super_type::const_reverse_iterator const_reverse_iterator;
typedef typename super_type::element element;
@@ -68,17 +79,27 @@ public:
typedef boost::detail::multi_array::multi_array_view<T,NDims> type;
};
explicit multi_array() :
super_type((T*)initial_base_) {
allocate_space();
}
template <class ExtentList>
explicit multi_array(ExtentList const& extents) :
explicit multi_array(
ExtentList const& extents
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
, typename detail::multi_array::disable_non_sub_array<ExtentList>::type* = 0
#endif
) :
super_type((T*)initial_base_,extents) {
boost::function_requires<
detail::multi_array::CollectionConcept<ExtentList> >();
allocate_space();
}
template <class ExtentList>
explicit multi_array(ExtentList const& extents,
const general_storage_order<NumDims>& so) :
const general_storage_order<NumDims>& so) :
super_type((T*)initial_base_,extents,so) {
boost::function_requires<
detail::multi_array::CollectionConcept<ExtentList> >();
@@ -133,7 +154,7 @@ public:
const_sub_array<T,NumDims,OPtr>& rhs) :
super_type(rhs) {
allocate_space();
std::copy(rhs.begin(),rhs.end(),begin());
std::copy(rhs.begin(),rhs.end(),this->begin());
}
// For some reason, gcc 2.95.2 doesn't pick the above template
@@ -143,10 +164,10 @@ public:
sub_array<T,NumDims>& rhs) :
super_type(rhs) {
allocate_space();
std::copy(rhs.begin(),rhs.end(),begin());
std::copy(rhs.begin(),rhs.end(),this->begin());
}
// Since assignment is a deep copy, multi_array_ref
// Since assignment is a deep copy, multi_array_ref
// contains all the necessary code.
template <typename ConstMultiArray>
multi_array& operator=(const ConstMultiArray& other) {
@@ -162,6 +183,72 @@ public:
}
multi_array& resize(const detail::multi_array
::extent_gen<NumDims>& ranges) {
// build a multi_array with the specs given
multi_array new_array(ranges);
// build a view of tmp with the minimum extents
// Get the minimum extents of the arrays.
boost::array<size_type,NumDims> min_extents;
const size_type& (*min)(const size_type&, const size_type&) =
std::min;
std::transform(new_array.extent_list_.begin(),new_array.extent_list_.end(),
this->extent_list_.begin(),
min_extents.begin(),
min);
// typedef boost::array<index,NumDims> index_list;
// Build index_gen objects to create views with the same shape
// these need to be separate to handle non-zero index bases
typedef detail::multi_array::index_gen<NumDims,NumDims> index_gen;
index_gen old_idxes;
index_gen new_idxes;
std::transform(new_array.index_base_list_.begin(),
new_array.index_base_list_.end(),
min_extents.begin(),old_idxes.ranges_.begin(),
detail::multi_array::populate_index_ranges());
std::transform(this->index_base_list_.begin(),
this->index_base_list_.end(),
min_extents.begin(),new_idxes.ranges_.begin(),
detail::multi_array::populate_index_ranges());
// Build same-shape views of the two arrays
typename
multi_array::BOOST_NESTED_TEMPLATE array_view<NumDims>::type view_old = (*this)[old_idxes];
typename
multi_array::BOOST_NESTED_TEMPLATE array_view<NumDims>::type view_new = new_array[new_idxes];
// Set the right portion of the new array
view_new = view_old;
using std::swap;
// Swap the internals of these arrays.
swap(this->super_type::base_,new_array.super_type::base_);
swap(this->storage_,new_array.storage_);
swap(this->extent_list_,new_array.extent_list_);
swap(this->stride_list_,new_array.stride_list_);
swap(this->index_base_list_,new_array.index_base_list_);
swap(this->origin_offset_,new_array.origin_offset_);
swap(this->directional_offset_,new_array.directional_offset_);
swap(this->num_elements_,new_array.num_elements_);
swap(this->allocator_,new_array.allocator_);
swap(this->base_,new_array.base_);
swap(this->allocated_elements_,new_array.allocated_elements_);
return *this;
}
~multi_array() {
deallocate_space();
}
@@ -169,9 +256,9 @@ public:
private:
void allocate_space() {
typename Allocator::const_pointer no_hint=0;
base_ = allocator_.allocate(super_type::num_elements(),no_hint);
super_type::set_base_ptr(base_);
allocated_elements_ = super_type::num_elements();
base_ = allocator_.allocate(this->num_elements(),no_hint);
this->set_base_ptr(base_);
allocated_elements_ = this->num_elements();
std::uninitialized_fill_n(base_,allocated_elements_,T());
}
@@ -181,8 +268,8 @@ private:
allocator_.destroy(i);
allocator_.deallocate(base_,allocated_elements_);
}
}
}
typedef boost::array<size_type,NumDims> size_list;
typedef boost::array<index,NumDims> index_list;

View File

@@ -26,17 +26,18 @@
// representations about the suitability of this software for any
// purpose. It is provided "as is" without express or implied warranty.
//
// Copyright (C) 2002 Ronald Garcia
//
// Permission to copy, use, sell and distribute this software is granted
// provided this copyright notice appears in all copies.
// Permission to modify the code and to distribute modified code is granted
// provided this copyright notice appears in all copies, and a notice
// that the code was modified is included with the copyright notice.
//
// This software is provided "as is" without express or implied warranty,
// and with no claim as to its suitability for any purpose.
//
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
#include "boost/iterator.hpp"

View File

@@ -1,14 +1,14 @@
// Copyright (C) 2002 Ronald Garcia
//
// Permission to copy, use, sell and distribute this software is granted
// provided this copyright notice appears in all copies.
// Permission to modify the code and to distribute modified code is granted
// provided this copyright notice appears in all copies, and a notice
// that the code was modified is included with the copyright notice.
//
// This software is provided "as is" without express or implied warranty,
// and with no claim as to its suitability for any purpose.
//
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
#ifndef BASE_RG071801_HPP
#define BASE_RG071801_HPP
@@ -25,7 +25,11 @@
#include "boost/multi_array/storage_order.hpp"
#include "boost/multi_array/types.hpp"
#include "boost/config.hpp"
#include "boost/multi_array/iterator_adaptors.hpp"
#include "boost/mpl/apply_if.hpp"
#include "boost/mpl/if.hpp"
#include "boost/mpl/size_t.hpp"
#include "boost/mpl/aux_/msvc_eti_base.hpp"
#include "boost/iterator/reverse_iterator.hpp"
#include "boost/static_assert.hpp"
#include "boost/type.hpp"
#include <cassert>
@@ -76,27 +80,8 @@ class sub_array;
template <typename T, std::size_t NumDims, typename TPtr = const T*>
class const_sub_array;
template <typename T, std::size_t NumDims, typename value_type,
typename reference_type, typename tag, typename difference_type>
struct iterator_generator;
template <typename T, std::size_t NumDims, typename value_type,
typename reference_type, typename tag, typename difference_type>
struct const_iterator_generator;
template <typename T, std::size_t NumDims, typename value_type,
typename reference_type, typename tag, typename difference_type>
struct reverse_iterator_generator;
template <typename T, std::size_t NumDims, typename value_type,
typename reference_type, typename tag, typename difference_type>
struct const_reverse_iterator_generator;
template <typename T,typename TPtr>
struct iterator_base;
template <typename T, std::size_t NumDims>
struct iterator_policies;
template <typename T, typename TPtr, typename NumDims, typename Reference>
class array_iterator;
template <typename T, std::size_t NumDims, typename TPtr = const T*>
class const_multi_array_view;
@@ -195,73 +180,94 @@ protected:
// choose value accessor begins
//
template <typename T, std::size_t NumDims>
struct choose_value_accessor_n {
template <typename T, std::size_t NumDims>
struct bind {
typedef value_accessor_n<T,NumDims> type;
};
typedef value_accessor_n<T,NumDims> type;
};
template <typename T>
struct choose_value_accessor_one {
template <typename T, std::size_t NumDims>
struct bind {
typedef value_accessor_one<T> type;
};
typedef value_accessor_one<T> type;
};
template <std::size_t NumDims>
struct value_accessor_gen_helper {
typedef choose_value_accessor_n choice;
template <typename T, typename NumDims>
struct value_accessor_generator {
BOOST_STATIC_CONSTANT(std::size_t, dimensionality = NumDims::value);
typedef typename
mpl::apply_if_c<(dimensionality == 1),
choose_value_accessor_one<T>,
choose_value_accessor_n<T,dimensionality>
>::type type;
};
#if BOOST_WORKAROUND(BOOST_MSVC, == 1200)
struct eti_value_accessor
{
typedef int index;
typedef int size_type;
typedef int element;
typedef int index_range;
typedef int value_type;
typedef int reference;
typedef int const_reference;
};
template <>
struct value_accessor_generator<int,int>
{
typedef eti_value_accessor type;
};
template <class T, class NumDims>
struct associated_types
: mpl::aux::msvc_eti_base<
typename value_accessor_generator<T,NumDims>::type
>::type
{};
template <>
struct value_accessor_gen_helper<1> {
typedef choose_value_accessor_one choice;
};
struct associated_types<int,int> : eti_value_accessor {};
template <typename T, std::size_t NumDims>
struct value_accessor_generator {
private:
typedef typename value_accessor_gen_helper<NumDims>::choice Choice;
public:
typedef typename Choice::template bind<T,NumDims>::type type;
};
#else
template <class T, class NumDims>
struct associated_types
: value_accessor_generator<T,NumDims>::type
{};
#endif
//
// choose value accessor ends
/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
// multi_array/sub_array base stuffs
/////////////////////////////////////////////////////////////////////////
template <std::size_t NumDims>
struct iterator_tag_selector {
typedef std::input_iterator_tag type;
};
template <>
struct iterator_tag_selector<1> {
typedef std::random_access_iterator_tag type;
};
////////////////////////////////////////////////////////////////////////
// multi_array_base
////////////////////////////////////////////////////////////////////////
template <typename T, std::size_t NumDims>
class multi_array_impl_base :
public value_accessor_generator<T,NumDims>::type {
typedef typename value_accessor_generator<T,NumDims>::type super_type;
class multi_array_impl_base
:
#if BOOST_WORKAROUND(BOOST_MSVC, == 1200)
public mpl::aux::msvc_eti_base<
typename value_accessor_generator<T,mpl::size_t<NumDims> >::type
>::type
#else
public value_accessor_generator<T,mpl::size_t<NumDims> >::type
#endif
{
typedef associated_types<T,mpl::size_t<NumDims> > types;
public:
typedef typename super_type::index index;
typedef typename super_type::size_type size_type;
typedef typename super_type::element element;
typedef typename super_type::index_range index_range;
typedef typename super_type::value_type value_type;
typedef typename super_type::reference reference;
typedef typename super_type::const_reference const_reference;
typedef typename types::index index;
typedef typename types::size_type size_type;
typedef typename types::element element;
typedef typename types::index_range index_range;
typedef typename types::value_type value_type;
typedef typename types::reference reference;
typedef typename types::const_reference const_reference;
template <std::size_t NDims>
struct subarray {
@@ -287,28 +293,14 @@ public:
//
// iterator support
//
typedef array_iterator<T,T*,mpl::size_t<NumDims>,reference> iterator;
typedef array_iterator<T,T const*,mpl::size_t<NumDims>,const_reference> const_iterator;
typedef typename iterator_tag_selector<NumDims>::type iterator_tag;
typedef typename
iterator_generator<T,NumDims,value_type,
reference,iterator_tag,index>::type iterator;
typedef typename
const_iterator_generator<T,NumDims,value_type,
const_reference,iterator_tag,index>::type const_iterator;
typedef typename
reverse_iterator_generator<T,NumDims,value_type,
reference,iterator_tag,index>::type reverse_iterator;
typedef typename
const_reverse_iterator_generator<T,NumDims,value_type,
const_reference,iterator_tag,index>::type const_reverse_iterator;
typedef ::boost::reverse_iterator<iterator> reverse_iterator;
typedef ::boost::reverse_iterator<const_iterator> const_reverse_iterator;
BOOST_STATIC_CONSTANT(std::size_t, dimensionality = NumDims);
protected:
typedef iterator_base<T,T*> iter_base;
typedef iterator_base<T,const T*> const_iter_base;
multi_array_impl_base() { }
~multi_array_impl_base() { }
@@ -424,7 +416,7 @@ protected:
index start = current_range.get_start(default_start);
index finish = current_range.get_finish(default_finish);
index index_factor = current_range.stride();
index len = (finish - start) / index_factor;
index len = (finish - start + (index_factor - 1)) / index_factor;
// the array data pointer is modified to account for non-zero
// bases during slicing (see [Garcia] for the math involved)

View File

@@ -1,14 +1,14 @@
// Copyright (C) 2002 Ronald Garcia
//
// Permission to copy, use, sell and distribute this software is granted
// provided this copyright notice appears in all copies.
// Permission to modify the code and to distribute modified code is granted
// provided this copyright notice appears in all copies, and a notice
// that the code was modified is included with the copyright notice.
//
// This software is provided "as is" without express or implied warranty,
// and with no claim as to its suitability for any purpose.
//
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
#ifndef COLLECTION_CONCEPT_RG103101_HPP
#define COLLECTION_CONCEPT_RG103101_HPP

View File

@@ -1,14 +1,14 @@
// Copyright (C) 2002 Ronald Garcia
//
// Permission to copy, use, sell and distribute this software is granted
// provided this copyright notice appears in all copies.
// Permission to modify the code and to distribute modified code is granted
// provided this copyright notice appears in all copies, and a notice
// that the code was modified is included with the copyright notice.
//
// This software is provided "as is" without express or implied warranty,
// and with no claim as to its suitability for any purpose.
//
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
#ifndef BOOST_MULTI_ARRAY_CONCEPT_CHECKS_RG110101_HPP
#define BOOST_MULTI_ARRAY_CONCEPT_CHECKS_RG110101_HPP
@@ -19,6 +19,7 @@
//
#include "boost/concept_check.hpp"
#include "boost/iterator/iterator_concepts.hpp"
namespace boost {
namespace detail {
@@ -60,7 +61,11 @@ namespace multi_array {
struct ConstMultiArrayConcept
{
void constraints() {
// function_requires< CopyConstructibleConcept<Array> >();
// function_requires< CopyConstructibleConcept<Array> >();
function_requires< boost_concepts::ForwardTraversalConcept<iterator> >();
function_requires< boost_concepts::ReadableIteratorConcept<iterator> >();
function_requires< boost_concepts::ForwardTraversalConcept<const_iterator> >();
function_requires< boost_concepts::ReadableIteratorConcept<const_iterator> >();
// RG - a( CollectionArchetype) when available...
a[ id ];
@@ -118,6 +123,12 @@ namespace multi_array {
void constraints() {
// function_requires< CopyConstructibleConcept<Array> >();
function_requires< boost_concepts::ForwardTraversalConcept<iterator> >();
function_requires< boost_concepts::ReadableIteratorConcept<iterator> >();
function_requires< boost_concepts::WritableIteratorConcept<iterator> >();
function_requires< boost_concepts::ForwardTraversalConcept<const_iterator> >();
function_requires< boost_concepts::ReadableIteratorConcept<const_iterator> >();
// RG - a( CollectionArchetype) when available...
value_type vt = a[ id ];

View File

@@ -1,14 +1,14 @@
// Copyright (C) 2002 Ronald Garcia
//
// Permission to copy, use, sell and distribute this software is granted
// provided this copyright notice appears in all copies.
// Permission to modify the code and to distribute modified code is granted
// provided this copyright notice appears in all copies, and a notice
// that the code was modified is included with the copyright notice.
//
// This software is provided "as is" without express or implied warranty,
// and with no claim as to its suitability for any purpose.
//
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
#ifndef COPY_ARRAY_RG092101_HPP
#define COPY_ARRAY_RG092101_HPP

View File

@@ -1,14 +1,14 @@
// Copyright (C) 2002 Ronald Garcia
//
// Permission to copy, use, sell and distribute this software is granted
// provided this copyright notice appears in all copies.
// Permission to modify the code and to distribute modified code is granted
// provided this copyright notice appears in all copies, and a notice
// that the code was modified is included with the copyright notice.
//
// This software is provided "as is" without express or implied warranty,
// and with no claim as to its suitability for any purpose.
//
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
#ifndef BOOST_EXTENT_GEN_RG071801_HPP
#define BOOST_EXTENT_GEN_RG071801_HPP

View File

@@ -1,14 +1,14 @@
// Copyright (C) 2002 Ronald Garcia
//
// Permission to copy, use, sell and distribute this software is granted
// provided this copyright notice appears in all copies.
// Permission to modify the code and to distribute modified code is granted
// provided this copyright notice appears in all copies, and a notice
// that the code was modified is included with the copyright notice.
//
// This software is provided "as is" without express or implied warranty,
// and with no claim as to its suitability for any purpose.
//
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
#ifndef BOOST_EXTENT_RANGE_RG071801_HPP
#define BOOST_EXTENT_RANGE_RG071801_HPP

View File

@@ -1,14 +1,14 @@
// Copyright (C) 2002 Ronald Garcia
//
// Permission to copy, use, sell and distribute this software is granted
// provided this copyright notice appears in all copies.
// Permission to modify the code and to distribute modified code is granted
// provided this copyright notice appears in all copies, and a notice
// that the code was modified is included with the copyright notice.
//
// This software is provided "as is" without express or implied warranty,
// and with no claim as to its suitability for any purpose.
//
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
#ifndef BOOST_INDEX_GEN_RG071801_HPP
#define BOOST_INDEX_GEN_RG071801_HPP
@@ -28,7 +28,7 @@ namespace multi_array {
template <int NumRanges, int NumDims>
struct index_gen {
private:
typedef index Index;
typedef ::boost::detail::multi_array::index Index;
typedef std::size_t SizeType;
typedef index_range<Index,SizeType> range;
public:

View File

@@ -1,14 +1,14 @@
// Copyright (C) 2002 Ronald Garcia
//
// Permission to copy, use, sell and distribute this software is granted
// provided this copyright notice appears in all copies.
// Permission to modify the code and to distribute modified code is granted
// provided this copyright notice appears in all copies, and a notice
// that the code was modified is included with the copyright notice.
//
// This software is provided "as is" without express or implied warranty,
// and with no claim as to its suitability for any purpose.
//
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
#ifndef BOOST_INDEX_RANGE_RG071801_HPP
#define BOOST_INDEX_RANGE_RG071801_HPP
@@ -53,7 +53,7 @@ namespace multi_array {
explicit index_range(index start, index finish, index stride=1)
: start_(start), finish_(finish), stride_(stride),
degenerate_(start_ == finish_)
degenerate_(false)
{ }

View File

@@ -1,14 +1,14 @@
// Copyright (C) 2002 Ronald Garcia
//
// Permission to copy, use, sell and distribute this software is granted
// provided this copyright notice appears in all copies.
// Permission to modify the code and to distribute modified code is granted
// provided this copyright notice appears in all copies, and a notice
// that the code was modified is included with the copyright notice.
//
// This software is provided "as is" without express or implied warranty,
// and with no claim as to its suitability for any purpose.
//
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
#ifndef ITERATOR_RG071801_HPP
#define ITERATOR_RG071801_HPP
@@ -19,8 +19,8 @@
//
#include "boost/multi_array/base.hpp"
#include "boost/multi_array/iterator_adaptors.hpp"
#include "boost/iterator_adaptors.hpp"
#include "boost/iterator/iterator_facade.hpp"
#include "boost/mpl/aux_/msvc_eti_base.hpp"
#include <cstddef>
#include <iterator>
@@ -32,136 +32,130 @@ namespace multi_array {
// iterator components
/////////////////////////////////////////////////////////////////////////
template <typename T, typename TPtr>
struct iterator_base : private multi_array_base {
typedef multi_array_base super_type;
typedef super_type::index index;
typedef super_type::size_type size_type;
template <class T>
struct operator_arrow_proxy
{
operator_arrow_proxy(T const& px) : value_(px) {}
T* operator->() const { return &value_; }
// This function is needed for MWCW and BCC, which won't call operator->
// again automatically per 13.3.1.2 para 8
operator T*() const { return &value_; }
mutable T value_;
};
template <typename T, typename TPtr, typename NumDims, typename Reference>
class array_iterator;
template <typename T, typename TPtr, typename NumDims, typename Reference>
class array_iterator
: public
iterator_facade<
array_iterator<T,TPtr,NumDims,Reference>
, typename associated_types<T,NumDims>::value_type
, boost::random_access_traversal_tag
, Reference
>
, private
#if BOOST_WORKAROUND(BOOST_MSVC,==1200)
mpl::aux::msvc_eti_base<typename
#endif
value_accessor_generator<T,NumDims>::type
#if BOOST_WORKAROUND(BOOST_MSVC,==1200)
>::type
#endif
{
friend class iterator_core_access;
typedef detail::multi_array::associated_types<T,NumDims> access_t;
typedef iterator_facade<
array_iterator<T,TPtr,NumDims,Reference>
, typename detail::multi_array::associated_types<T,NumDims>::value_type
, boost::random_access_traversal_tag
, Reference
> facade_type;
typedef typename access_t::index index;
typedef typename access_t::size_type size_type;
#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
template <typename, typename, typename, typename>
friend class array_iterator;
#else
public:
#endif
index idx_;
TPtr base_;
const size_type* extents_;
const index* strides_;
const index* index_base_;
public:
// Typedefs to circumvent ambiguities between parent classes
typedef typename facade_type::reference reference;
typedef typename facade_type::value_type value_type;
typedef typename facade_type::difference_type difference_type;
iterator_base(int idx, TPtr base, const size_type* extents,
array_iterator() {}
array_iterator(int idx, TPtr base, const size_type* extents,
const index* strides,
const index* index_base) :
idx_(idx), base_(base), extents_(extents),
strides_(strides), index_base_(index_base) {
}
strides_(strides), index_base_(index_base) { }
template <typename OPtr>
iterator_base(const iterator_base<T,OPtr>& rhs) :
idx_(rhs.idx_), base_(rhs.base_), extents_(rhs.extents_),
strides_(rhs.strides_), index_base_(rhs.index_base_) {
}
template <typename OPtr, typename ORef>
array_iterator(
const array_iterator<T,OPtr,NumDims,ORef>& rhs
, typename boost::enable_if_convertible<OPtr,TPtr>::type* = 0
)
: idx_(rhs.idx_), base_(rhs.base_), extents_(rhs.extents_),
strides_(rhs.strides_), index_base_(rhs.index_base_) { }
// default constructor required
iterator_base() {}
};
template<typename T, std::size_t NumDims>
struct iterator_policies :
public boost::detail::multi_array::default_iterator_policies,
private value_accessor_generator<T,NumDims>::type {
private:
typedef typename value_accessor_generator<T,NumDims>::type super_type;
public:
template <class IteratorAdaptor>
typename IteratorAdaptor::reference
dereference(const IteratorAdaptor& iter) const {
typedef typename IteratorAdaptor::reference reference;
return super_type::access(boost::type<reference>(),
iter.base().idx_,
iter.base().base_,
iter.base().extents_,
iter.base().strides_,
iter.base().index_base_);
// RG - we make our own operator->
operator_arrow_proxy<reference>
operator->() const
{
return operator_arrow_proxy<reference>(this->dereference());
}
template <class IteratorAdaptor>
static void increment(IteratorAdaptor& x) { ++x.base().idx_; }
reference dereference() const
{
typedef typename value_accessor_generator<T,NumDims>::type accessor;
return accessor::access(boost::type<reference>(),
idx_,
base_,
extents_,
strides_,
index_base_);
}
void increment() { ++idx_; }
void decrement() { --idx_; }
template <class IteratorAdaptor>
static void decrement(IteratorAdaptor& x) { --x.base().idx_; }
template <class IteratorAdaptor1, class IteratorAdaptor2>
bool equal(IteratorAdaptor1& lhs, IteratorAdaptor2& rhs) const {
return (lhs.base().idx_ == rhs.base().idx_) &&
(lhs.base().base_ == rhs.base().base_) &&
(lhs.base().extents_ == rhs.base().extents_) &&
(lhs.base().strides_ == rhs.base().strides_) &&
(lhs.base().index_base_ == rhs.base().index_base_);
bool equal(IteratorAdaptor& rhs) const {
return (idx_ == rhs.idx_) &&
(base_ == rhs.base_) &&
(extents_ == rhs.extents_) &&
(strides_ == rhs.strides_) &&
(index_base_ == rhs.index_base_);
}
template <class IteratorAdaptor, class DifferenceType>
static void advance(IteratorAdaptor& x, DifferenceType n) {
x.idx_ += n;
template <class DifferenceType>
void advance(DifferenceType n) {
idx_ += n;
}
template <class IteratorAdaptor1, class IteratorAdaptor2>
typename IteratorAdaptor1::difference_type
distance(IteratorAdaptor1& lhs, IteratorAdaptor2& rhs) const {
return rhs.base().idx_ - lhs.base().idx_;
template <class IteratorAdaptor>
typename facade_type::difference_type
distance_to(IteratorAdaptor& rhs) const {
return rhs.idx_ - idx_;
}
};
template <typename T, typename base_type,
std::size_t NumDims, typename value_type,
typename reference_type, typename tag, typename difference_type>
struct iterator_gen_helper {
private:
typedef iterator_policies<T,NumDims> policies;
typedef value_type* pointer_type;
typedef tag category;
public:
typedef boost::detail::multi_array::iterator_adaptor<base_type,policies,value_type,
reference_type,pointer_type,category,difference_type> type;
};
template <typename T, std::size_t NumDims, typename value_type,
typename reference_type, typename tag, typename difference_type>
struct iterator_generator {
private:
typedef iterator_base<T,T*> base_type;
public:
typedef typename iterator_gen_helper<T,base_type,NumDims,value_type,
reference_type,tag,difference_type>::type type;
};
template <typename T, std::size_t NumDims, typename value_type,
typename reference_type, typename tag, typename difference_type>
struct const_iterator_generator {
private:
typedef iterator_base<T,const T*> base_type;
public:
typedef typename iterator_gen_helper<T,base_type,NumDims,value_type,
reference_type,tag,difference_type>::type type;
};
template <typename T, std::size_t NumDims, typename value_type,
typename reference_type, typename tag, typename difference_type>
struct reverse_iterator_generator {
private:
typedef iterator_base<T,T*> base_type;
typedef typename iterator_gen_helper<T,base_type,NumDims,value_type,
reference_type,tag,difference_type>::type it_type;
public:
typedef typename boost::reverse_iterator_generator<it_type>::type type;
};
template <typename T, std::size_t NumDims, typename value_type,
typename reference_type, typename tag, typename difference_type>
struct const_reverse_iterator_generator {
private:
typedef iterator_base<T,const T*> base_type;
typedef typename iterator_gen_helper<T,base_type,NumDims,value_type,
reference_type,tag,difference_type>::type it_type;
public:
typedef typename boost::reverse_iterator_generator<it_type>::type type;
};
} // namespace multi_array

View File

@@ -1,970 +0,0 @@
// (C) Copyright David Abrahams 2000. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
//
// (C) Copyright Jeremy Siek 2000. Permission to copy, use, modify,
// sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
//
// Thes code is modified from its original form to meet the needs of
// Boost.MultiArray.
// Revision History:
// 27 Mar 2002 Ronald Garcia
// Forked from the main tree iterator adaptors. Necessary to
// allow iterator::operator->*() to work with multi_array iterators.
// 01 Feb 2002 Jeremy Siek
// Added more comments in default_iterator_policies.
// 08 Jan 2001 David Abrahams
// Moved concept checks into a separate class, which makes MSVC
// better at dealing with them.
// 07 Jan 2001 David Abrahams
// Choose proxy for operator->() only if the reference type is not a reference.
// Updated workarounds for __MWERKS__ == 0x2406
// 20 Dec 2001 David Abrahams
// Adjusted is_convertible workarounds for __MWERKS__ == 0x2406
// 03 Nov 2001 Jeremy Siek
// Changed the named template parameter interface and internal.
// 04 Oct 2001 Jeremy Siek
// Changed projection_iterator to not rely on the default reference,
// working around a limitation of detail::iterator_traits.
// 04 Oct 2001 David Abrahams
// Applied indirect_iterator patch from George A. Heintzelman <georgeh@aya.yale.edu>
// Changed name of "bind" to "select" to avoid problems with MSVC.
// 26 Sep 2001 David Abrahams
// Added borland bug fix
// 08 Mar 2001 Jeremy Siek
// Added support for optional named template parameters.
// 19 Feb 2001 David Abrahams
// Rolled back reverse_iterator_pair_generator again, as it doesn't
// save typing on a conforming compiler.
// 18 Feb 2001 David Abrahams
// Reinstated reverse_iterator_pair_generator
// 16 Feb 2001 David Abrahams
// Add an implicit conversion operator to operator_arrow_proxy
// as CW and BCC workarounds.
// 11 Feb 2001 David Abrahams
// Switch to use of BOOST_STATIC_CONSTANT where possible
// 11 Feb 2001 Jeremy Siek
// Removed workaround for older MIPSpro compiler. The workaround
// was preventing the proper functionality of the underlying
// iterator being carried forward into the iterator adaptor.
// Also added is_bidirectional enum to avoid EDG compiler error.
// 11 Feb 2001 David Abrahams
// Borland fixes up the wazoo. It finally works!
// 10 Feb 2001 David Abrahams
// Removed traits argument from iterator_adaptor<> and switched to
// explicit trait specification for maximum ease-of-use.
// Added comments to detail::iterator_defaults<>
// Began using detail::iterator_defaults<> unconditionally for code clarity
// Changed uses of `Iterator' to `Base' where non-iterators can be used.
//
// 10 Feb 2001 David Abrahams
// Rolled in supposed Borland fixes from John Maddock, but not seeing any
// improvement yet
// Changed argument order to indirect_ generator, for convenience in the
// case of input iterators (where Reference must be a value type).
// Removed derivation of filter_iterator_policies from
// default_iterator_policies, since the iterator category is likely to be
// reduced (we don't want to allow illegal operations like decrement).
// Support for a simpler filter iterator interface.
//
// 09 Feb 2001 David Abrahams
// Improved interface to indirect_ and reverse_ iterators
// Rolled back Jeremy's new constructor for now; it was causing
// problems with counting_iterator_test
// Attempted fix for Borland
//
// 09 Feb 2001 Jeremy Siek
// Added iterator constructor to allow const adaptor
// from non-const adaptee.
// Changed make_xxx to pass iterators by-value to
// get arrays converted to pointers.
// Removed InnerIterator template parameter from
// indirect_iterator_generator.
// Rearranged parameters for make_filter_iterator
//
// 07 Feb 2001 Jeremy Siek
// Removed some const iterator adaptor generators.
// Added make_xxx_iterator() helper functions for remaining
// iterator adaptors.
// Removed some traits template parameters where they
// where no longer needed thanks to detail::iterator_traits.
// Moved some of the compile-time logic into enums for
// EDG compatibility.
//
// 07 Feb 2001 David Abrahams
// Removed iterator_adaptor_pair_generator and
// reverse_iterator_pair_generator (more such culling to come)
// Improved comments
// Changed all uses of std::iterator_traits as default arguments
// to boost::detail::iterator_traits for improved utility in
// non-generic contexts
// Fixed naming convention of non-template parameter names
//
// 06 Feb 2001 David Abrahams
// Produce operator-> proxy objects for InputIterators
// Added static assertions to do some basic concept checks
// Renamed single-type generators -> xxx_generator
// Renamed const/nonconst iterator generators -> xxx_pair_generator
// Added make_transform_iterator(iter, function)
// The existence of boost::detail::iterator_traits allowed many
// template arguments to be defaulted. Some arguments had to be
// moved to accomplish it.
//
// 04 Feb 2001 MWERKS bug workaround, concept checking for proper
// reference types (David Abrahams)
#ifndef BOOST_ITERATOR_ADAPTOR_RG032702_HPP_
# define BOOST_ITERATOR_ADAPTOR_RG032702_HPP_
# include <boost/iterator.hpp>
# include <boost/utility.hpp>
# include <boost/compressed_pair.hpp>
# include <boost/concept_check.hpp>
# include <boost/type.hpp>
# include <boost/static_assert.hpp>
# include <boost/type_traits.hpp>
# include <boost/detail/iterator.hpp>
# include <boost/detail/select_type.hpp>
// I was having some problems with VC6. I couldn't tell whether our hack for
// stock GCC was causing problems so I needed an easy way to turn it on and
// off. Now we can test the hack with various compilers and still have an
// "out" if it doesn't work. -dwa 7/31/00
# if __GNUC__ == 2 && __GNUC_MINOR__ <= 96 && !defined(__STL_USE_NAMESPACES)
# define BOOST_RELOPS_AMBIGUITY_BUG 1
# endif
namespace boost {
namespace detail {
namespace multi_array {
//============================================================================
// Default policies for iterator adaptors. You can use this as a base
// class if you want to customize particular policies.
struct default_iterator_policies
{
// Some of the member functions were defined static, but Borland
// got confused and thought they were non-const. Also, Sun C++
// does not like static function templates.
//
// The reason some members were defined static is because there is
// not state (data members) needed by those members of the
// default_iterator_policies class. If your policies class member
// functions need to access state stored in the policies object,
// then the member functions should not be static (they can't be).
template <class Base>
void initialize(Base&)
{ }
template <class IteratorAdaptor>
typename IteratorAdaptor::reference dereference(const IteratorAdaptor& x) const
{ return *x.base(); }
template <class IteratorAdaptor>
void increment(IteratorAdaptor& x)
{ ++x.base(); }
template <class IteratorAdaptor>
void decrement(IteratorAdaptor& x)
{ --x.base(); }
template <class IteratorAdaptor, class DifferenceType>
void advance(IteratorAdaptor& x, DifferenceType n)
{ x.base() += n; }
template <class IteratorAdaptor1, class IteratorAdaptor2>
typename IteratorAdaptor1::difference_type
distance(const IteratorAdaptor1& x, const IteratorAdaptor2& y) const
{ return y.base() - x.base(); }
template <class IteratorAdaptor1, class IteratorAdaptor2>
bool equal(const IteratorAdaptor1& x, const IteratorAdaptor2& y) const
{ return x.base() == y.base(); }
};
// putting the comparisons in a base class avoids the g++
// ambiguous overload bug due to the relops operators
#ifdef BOOST_RELOPS_AMBIGUITY_BUG
template <class Derived, class Base>
struct iterator_comparisons : Base { };
template <class D1, class D2, class Base1, class Base2>
inline bool operator==(const iterator_comparisons<D1,Base1>& xb,
const iterator_comparisons<D2,Base2>& yb)
{
const D1& x = static_cast<const D1&>(xb);
const D2& y = static_cast<const D2&>(yb);
return x.policies().equal(x, y);
}
template <class D1, class D2, class Base1, class Base2>
inline bool operator!=(const iterator_comparisons<D1,Base1>& xb,
const iterator_comparisons<D2,Base2>& yb)
{
const D1& x = static_cast<const D1&>(xb);
const D2& y = static_cast<const D2&>(yb);
return !x.policies().equal(x, y);
}
template <class D1, class D2, class Base1, class Base2>
inline bool operator<(const iterator_comparisons<D1,Base1>& xb,
const iterator_comparisons<D2,Base2>& yb)
{
const D1& x = static_cast<const D1&>(xb);
const D2& y = static_cast<const D2&>(yb);
return x.policies().distance(y, x) < 0;
}
template <class D1, class D2, class Base1, class Base2>
inline bool operator>(const iterator_comparisons<D1,Base1>& xb,
const iterator_comparisons<D2,Base2>& yb)
{
const D1& x = static_cast<const D1&>(xb);
const D2& y = static_cast<const D2&>(yb);
return x.policies().distance(y, x) > 0;
}
template <class D1, class D2, class Base1, class Base2>
inline bool operator>=(const iterator_comparisons<D1,Base1>& xb,
const iterator_comparisons<D2,Base2>& yb)
{
const D1& x = static_cast<const D1&>(xb);
const D2& y = static_cast<const D2&>(yb);
return x.policies().distance(y, x) >= 0;
}
template <class D1, class D2, class Base1, class Base2>
inline bool operator<=(const iterator_comparisons<D1,Base1>& xb,
const iterator_comparisons<D2,Base2>& yb)
{
const D1& x = static_cast<const D1&>(xb);
const D2& y = static_cast<const D2&>(yb);
return x.policies().distance(y, x) <= 0;
}
#endif
namespace detail {
// operator->() needs special support for input iterators to strictly meet the
// standard's requirements. If *i is not a reference type, we must still
// produce a (constant) lvalue to which a pointer can be formed. We do that by
// returning an instantiation of this special proxy class template.
template <class T>
struct operator_arrow_proxy
{
operator_arrow_proxy(const T& x) : m_value(x) {}
// RG removed const below
T* operator->() const { return &m_value; }
// This function is needed for MWCW and BCC, which won't call operator->
// again automatically per 13.3.1.2 para 8
// RG - removed const below
operator T*() const { return &m_value; }
mutable T m_value;
};
template <class Iter>
inline operator_arrow_proxy<typename Iter::reference>
operator_arrow(const Iter& i, std::input_iterator_tag) {
// RG - THIS is the change I needed to make!
// My input iterators need to return proxy references rather than values
typedef typename Iter::reference value_t; // VC++ needs this typedef
return operator_arrow_proxy<value_t>(*i);
}
template <class Iter>
inline typename Iter::pointer
operator_arrow(const Iter& i, std::forward_iterator_tag) {
return &(*i);
}
template <class Value, class Reference, class Pointer>
struct operator_arrow_result_generator
{
//RG - another important change!
typedef operator_arrow_proxy<Reference> proxy;
// Borland chokes unless it's an actual enum (!)
enum { use_proxy = !boost::is_reference<Reference>::value };
typedef typename boost::detail::if_true<(use_proxy)>::template
then<
proxy,
// else
Pointer
>::type type;
};
# if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) || defined(BOOST_NO_STD_ITERATOR_TRAITS)
// Select default pointer and reference types for adapted non-pointer
// iterators based on the iterator and the value_type. Poor man's partial
// specialization is in use here.
template <bool is_pointer>
struct iterator_defaults_select
{
template <class Iterator,class Value>
struct traits
{
// The assumption is that iterator_traits can deduce these types
// properly as long as the iterator is not a pointer.
typedef typename boost::detail::iterator_traits<Iterator>::pointer pointer;
typedef typename boost::detail::iterator_traits<Iterator>::reference reference;
};
};
// Select default pointer and reference types for adapted pointer iterators
// given a (possibly-const) value_type.
template <>
struct iterator_defaults_select<true>
{
template <class Iterator,class Value>
struct traits
{
typedef Value* pointer;
typedef Value& reference;
};
};
// Consolidate selection of the default pointer and reference type
template <class Iterator,class Value>
struct iterator_defaults
{
BOOST_STATIC_CONSTANT(bool, is_ptr = boost::is_pointer<Iterator>::value);
typedef typename iterator_defaults_select<is_ptr>::template traits<Iterator,Value> traits;
typedef typename traits::pointer pointer;
typedef typename traits::reference reference;
};
# else
template <class Iterator,class Value>
struct iterator_defaults : iterator_traits<Iterator>
{
// Trying to factor the common is_same expression into an enum or a
// static bool constant confused Borland.
typedef typename if_true<(
::boost::is_same<Value,typename iterator_traits<Iterator>::value_type>::value
)>::template then<
typename iterator_traits<Iterator>::pointer,
Value*
>::type pointer;
typedef typename if_true<(
::boost::is_same<Value,typename iterator_traits<Iterator>::value_type>::value
)>::template then<
typename iterator_traits<Iterator>::reference,
Value&
>::type reference;
};
# endif
//===========================================================================
// Specify the defaults for iterator_adaptor's template parameters
struct default_argument { };
// This class template is a workaround for MSVC.
struct dummy_default_gen {
template <class Base, class Traits>
struct select { typedef default_argument type; };
};
// This class template is a workaround for MSVC.
template <class Gen> struct default_generator {
typedef dummy_default_gen type;
};
struct default_value_type {
template <class Base, class Traits>
struct select {
typedef typename boost::detail::iterator_traits<Base>::value_type type;
};
};
template <> struct default_generator<default_value_type>
{ typedef default_value_type type; }; // VC++ workaround
struct default_difference_type {
template <class Base, class Traits>
struct select {
typedef typename boost::detail::iterator_traits<Base>::difference_type type;
};
};
template <> struct default_generator<default_difference_type>
{ typedef default_difference_type type; }; // VC++ workaround
struct default_iterator_category {
template <class Base, class Traits>
struct select {
typedef typename boost::detail::iterator_traits<Base>::iterator_category type;
};
};
template <> struct default_generator<default_iterator_category>
{ typedef default_iterator_category type; }; // VC++ workaround
struct default_pointer {
template <class Base, class Traits>
struct select {
typedef typename Traits::value_type Value;
typedef typename boost::detail::multi_array::detail::iterator_defaults<Base,Value>::pointer
type;
};
};
template <> struct default_generator<default_pointer>
{ typedef default_pointer type; }; // VC++ workaround
struct default_reference {
template <class Base, class Traits>
struct select {
typedef typename Traits::value_type Value;
typedef typename boost::detail::multi_array::detail::iterator_defaults<Base,Value>::reference
type;
};
};
template <> struct default_generator<default_reference>
{ typedef default_reference type; }; // VC++ workaround
} // namespace detail
//===========================================================================
// Support for named template parameters
struct named_template_param_base { };
namespace detail {
struct value_type_tag { };
struct reference_tag { };
struct pointer_tag { };
struct difference_type_tag { };
struct iterator_category_tag { };
// avoid using std::pair because A or B might be a reference type, and g++
// complains about forming references to references inside std::pair
template <class A, class B>
struct cons_type {
typedef A first_type;
typedef B second_type;
};
} // namespace detail
template <class Value> struct value_type_is : public named_template_param_base
{
typedef detail::cons_type<detail::value_type_tag, Value> type;
};
template <class Reference> struct reference_is : public named_template_param_base
{
typedef detail::cons_type<detail::reference_tag, Reference> type;
};
template <class Pointer> struct pointer_is : public named_template_param_base
{
typedef detail::cons_type<detail::pointer_tag, Pointer> type;
};
template <class Difference> struct difference_type_is
: public named_template_param_base
{
typedef detail::cons_type<detail::difference_type_tag, Difference> type;
};
template <class IteratorCategory> struct iterator_category_is
: public named_template_param_base
{
typedef detail::cons_type<detail::iterator_category_tag, IteratorCategory> type;
};
namespace detail {
struct end_of_list { };
// Given an associative list, find the value with the matching key.
// An associative list is a list of key-value pairs. The list is
// built out of cons_type's and is terminated by end_of_list.
# if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) || defined(__BORLANDC__)
template <class AssocList, class Key>
struct find_param;
struct find_param_continue {
template <class AssocList, class Key2> struct select {
typedef typename AssocList::first_type Head;
typedef typename Head::first_type Key1;
typedef typename Head::second_type Value;
typedef typename if_true<(is_same<Key1, Key2>::value)>::template
then<Value,
typename find_param<typename AssocList::second_type, Key2>::type
>::type type;
};
};
struct find_param_end {
template <class AssocList, class Key>
struct select { typedef detail::default_argument type; };
};
template <class AssocList> struct find_param_helper1
{ typedef find_param_continue type; };
template <> struct find_param_helper1<end_of_list>
{ typedef find_param_end type; };
template <class AssocList, class Key>
struct find_param {
typedef typename find_param_helper1<AssocList>::type select1;
typedef typename select1::template select<AssocList, Key>::type type;
};
# else
template <class AssocList, class Key> struct find_param;
template <class Key>
struct find_param<end_of_list, Key> { typedef default_argument type; };
// Found a matching Key, return the associated Value
template <class Key, class Value, class Rest>
struct find_param<detail::cons_type< detail::cons_type<Key, Value>, Rest>, Key> {
typedef Value type;
};
// Non-matching keys, continue the search
template <class Key1, class Value, class Rest, class Key2>
struct find_param<detail::cons_type< detail::cons_type<Key1, Value>, Rest>, Key2> {
typedef typename find_param<Rest, Key2>::type type;
};
# endif
struct make_named_arg {
template <class Key, class Value>
struct select { typedef typename Value::type type; };
};
struct make_key_value {
template <class Key, class Value>
struct select { typedef detail::cons_type<Key, Value> type; };
};
template <class Value>
struct is_named_parameter
{
enum { value = is_convertible<Value, named_template_param_base>::value };
};
# if defined(__MWERKS__) && __MWERKS__ <= 0x2406 // workaround for broken is_convertible implementation
template <class T> struct is_named_parameter<value_type_is<T> > { enum { value = true }; };
template <class T> struct is_named_parameter<reference_is<T> > { enum { value = true }; };
template <class T> struct is_named_parameter<pointer_is<T> > { enum { value = true }; };
template <class T> struct is_named_parameter<difference_type_is<T> > { enum { value = true }; };
template <class T> struct is_named_parameter<iterator_category_is<T> > { enum { value = true }; };
# endif
template <class Key, class Value>
struct make_arg {
# ifdef __BORLANDC__
// Borland C++ doesn't like the extra indirection of is_named_parameter
typedef typename
if_true<(is_convertible<Value,named_template_param_base>::value)>::
template then<make_named_arg, make_key_value>::type Make;
# else
enum { is_named = is_named_parameter<Value>::value };
typedef typename if_true<(is_named)>::template
then<make_named_arg, make_key_value>::type Make;
# endif
typedef typename Make::template select<Key, Value>::type type;
};
// Mechanism for resolving the default argument for a template parameter.
template <class T> struct is_default { typedef type_traits::no_type type; };
template <> struct is_default<default_argument>
{ typedef type_traits::yes_type type; };
struct choose_default {
template <class Arg, class DefaultGen, class Base, class Traits>
struct select {
typedef typename default_generator<DefaultGen>::type Gen;
typedef typename Gen::template select<Base,Traits>::type type;
};
};
struct choose_arg {
template <class Arg, class DefaultGen, class Base, class Traits>
struct select {
typedef Arg type;
};
};
template <class UseDefault>
struct choose_arg_or_default { typedef choose_arg type; };
template <> struct choose_arg_or_default<type_traits::yes_type> {
typedef choose_default type;
};
template <class Arg, class DefaultGen, class Base, class Traits>
class resolve_default {
typedef typename choose_arg_or_default<typename is_default<Arg>::type>::type
Selector;
public:
typedef typename Selector
::template select<Arg, DefaultGen, Base, Traits>::type type;
};
template <class Base, class Value, class Reference, class Pointer,
class Category, class Distance>
class iterator_adaptor_traits_gen
{
// Form an associative list out of the template parameters
// If the argument is a normal parameter (not named) then make_arg
// creates a key-value pair. If the argument is a named parameter,
// then make_arg extracts the key-value pair defined inside the
// named parameter.
typedef detail::cons_type< typename make_arg<value_type_tag, Value>::type,
detail::cons_type<typename make_arg<reference_tag, Reference>::type,
detail::cons_type<typename make_arg<pointer_tag, Pointer>::type,
detail::cons_type<typename make_arg<iterator_category_tag, Category>::type,
detail::cons_type<typename make_arg<difference_type_tag, Distance>::type,
end_of_list> > > > > ArgList;
// Search the list for particular parameters
typedef typename find_param<ArgList, value_type_tag>::type Val;
typedef typename find_param<ArgList, difference_type_tag>::type Diff;
typedef typename find_param<ArgList, iterator_category_tag>::type Cat;
typedef typename find_param<ArgList, pointer_tag>::type Ptr;
typedef typename find_param<ArgList, reference_tag>::type Ref;
typedef boost::iterator<Category, Value, Distance, Pointer, Reference>
Traits0;
// Compute the defaults if necessary
typedef typename resolve_default<Val, default_value_type, Base, Traits0>::type
value_type;
// if getting default value type from iterator_traits, then it won't be const
typedef typename resolve_default<Diff, default_difference_type, Base,
Traits0>::type difference_type;
typedef typename resolve_default<Cat, default_iterator_category, Base,
Traits0>::type iterator_category;
typedef boost::iterator<iterator_category, value_type, difference_type,
Pointer, Reference> Traits1;
// Compute the defaults for pointer and reference. This is done as a
// separate step because the defaults for pointer and reference depend
// on value_type.
typedef typename resolve_default<Ptr, default_pointer, Base, Traits1>::type
pointer;
typedef typename resolve_default<Ref, default_reference, Base, Traits1>::type
reference;
public:
typedef boost::iterator<iterator_category,
typename remove_const<value_type>::type,
difference_type, pointer, reference> type;
};
// This is really a partial concept check for iterators. Should it
// be moved or done differently?
template <class Category, class Value, class Difference, class Pointer, class Reference>
struct validator
{
BOOST_STATIC_CONSTANT(
bool, is_input_or_output_iter
= (boost::is_convertible<Category*,std::input_iterator_tag*>::value
| boost::is_convertible<Category*,std::output_iterator_tag*>::value));
// Iterators should satisfy one of the known categories
BOOST_STATIC_ASSERT(is_input_or_output_iter);
// Iterators >= ForwardIterator must produce real references
// as required by the C++ standard requirements in Table 74.
BOOST_STATIC_CONSTANT(
bool, forward_iter_with_real_reference
= ((!boost::is_convertible<Category*,std::forward_iterator_tag*>::value)
| boost::is_same<Reference,Value&>::value
| boost::is_same<Reference,typename add_const<Value>::type&>::value));
BOOST_STATIC_ASSERT(forward_iter_with_real_reference);
};
} // namespace detail
// This macro definition is only temporary in this file
# if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
# define BOOST_ARG_DEPENDENT_TYPENAME typename
# else
# define BOOST_ARG_DEPENDENT_TYPENAME
# endif
//============================================================================
//iterator_adaptor - Adapts a generic piece of data as an iterator. Adaptation
// is especially easy if the data being adapted is itself an iterator
//
// Base - the base (usually iterator) type being wrapped.
//
// Policies - a set of policies determining how the resulting iterator
// works.
//
// Value - if supplied, the value_type of the resulting iterator, unless
// const. If const, a conforming compiler strips constness for the
// value_type. If not supplied, iterator_traits<Base>::value_type is used
//
// Reference - the reference type of the resulting iterator, and in
// particular, the result type of operator*(). If not supplied but
// Value is supplied, Value& is used. Otherwise
// iterator_traits<Base>::reference is used.
//
// Pointer - the pointer type of the resulting iterator, and in
// particular, the result type of operator->(). If not
// supplied but Value is supplied, Value* is used. Otherwise
// iterator_traits<Base>::pointer is used.
//
// Category - the iterator_category of the resulting iterator. If not
// supplied, iterator_traits<Base>::iterator_category is used.
//
// Distance - the difference_type of the resulting iterator. If not
// supplied, iterator_traits<Base>::difference_type is used.
template <class Base, class Policies,
class Value = ::boost::detail::multi_array::detail::default_argument,
class Reference = ::boost::detail::multi_array::detail::default_argument,
class Pointer = ::boost::detail::multi_array::detail::default_argument,
class Category = ::boost::detail::multi_array::detail::default_argument,
class Distance = ::boost::detail::multi_array::detail::default_argument
>
struct iterator_adaptor :
#ifdef BOOST_RELOPS_AMBIGUITY_BUG
iterator_comparisons<
iterator_adaptor<Base,Policies,Value,Reference,Pointer,Category,Distance>,
typename detail::iterator_adaptor_traits_gen<Base,Value,Reference,Pointer,Category, Distance>::type
>
#else
detail::iterator_adaptor_traits_gen<Base,Value,Reference,Pointer,Category,Distance>::type
#endif
{
typedef iterator_adaptor<Base,Policies,Value,Reference,Pointer,Category,Distance> self;
public:
typedef detail::iterator_adaptor_traits_gen<Base,Value,Reference,Pointer,Category,Distance> TraitsGen;
typedef typename TraitsGen::type Traits;
typedef typename Traits::difference_type difference_type;
typedef typename Traits::value_type value_type;
typedef typename Traits::pointer pointer;
typedef typename Traits::reference reference;
typedef typename Traits::iterator_category iterator_category;
typedef Base base_type;
typedef Policies policies_type;
private:
typedef detail::validator<
iterator_category,value_type,difference_type,pointer,reference
> concept_check;
public:
iterator_adaptor()
{
}
explicit
iterator_adaptor(const Base& it, const Policies& p = Policies())
: m_iter_p(it, p) {
policies().initialize(base());
}
template <class Iter2, class Value2, class Pointer2, class Reference2>
iterator_adaptor (
const iterator_adaptor<Iter2,Policies,Value2,Reference2,Pointer2,Category,Distance>& src)
: m_iter_p(src.base(), src.policies())
{
policies().initialize(base());
}
#if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 || defined(__BORLANDC__)
// This is required to prevent a bug in how VC++ generates
// the assignment operator for compressed_pair
iterator_adaptor& operator= (const iterator_adaptor& x) {
m_iter_p = x.m_iter_p;
return *this;
}
#endif
reference operator*() const {
return policies().dereference(*this);
}
#ifdef BOOST_MSVC
# pragma warning(push)
# pragma warning( disable : 4284 )
#endif
typename boost::detail::multi_array::detail::operator_arrow_result_generator<value_type,reference,pointer>::type
operator->() const
{ return detail::operator_arrow(*this, iterator_category()); }
#ifdef BOOST_MSVC
# pragma warning(pop)
#endif
value_type operator[](difference_type n) const
{ return *(*this + n); }
self& operator++() {
#if !defined(__MWERKS__) || __MWERKS__ >= 0x2405
policies().increment(*this);
#else
// Odd bug, MWERKS couldn't deduce the type for the member template
// Workaround by explicitly specifying the type.
policies().increment<self>(*this);
#endif
return *this;
}
self operator++(int) { self tmp(*this); ++*this; return tmp; }
self& operator--() {
#if !defined(__MWERKS__) || __MWERKS__ >= 0x2405
policies().decrement(*this);
#else
policies().decrement<self>(*this);
#endif
return *this;
}
self operator--(int) { self tmp(*this); --*this; return tmp; }
self& operator+=(difference_type n) {
policies().advance(*this, n);
return *this;
}
self& operator-=(difference_type n) {
policies().advance(*this, -n);
return *this;
}
base_type const& base() const { return m_iter_p.first(); }
// Moved from global scope to avoid ambiguity with the operator-() which
// subtracts iterators from one another.
self operator-(difference_type x) const
{ self result(*this); return result -= x; }
private:
compressed_pair<Base,Policies> m_iter_p;
public: // implementation details (too many compilers have trouble when these are private).
base_type& base() { return m_iter_p.first(); }
Policies& policies() { return m_iter_p.second(); }
const Policies& policies() const { return m_iter_p.second(); }
};
template <class Base, class Policies, class Value, class Reference, class Pointer,
class Category, class Distance1, class Distance2>
iterator_adaptor<Base,Policies,Value,Reference,Pointer,Category,Distance1>
operator+(
iterator_adaptor<Base,Policies,Value,Reference,Pointer,Category,Distance1> p,
Distance2 x)
{
return p += x;
}
template <class Base, class Policies, class Value, class Reference, class Pointer,
class Category, class Distance1, class Distance2>
iterator_adaptor<Base,Policies,Value,Reference,Pointer,Category,Distance1>
operator+(
Distance2 x,
iterator_adaptor<Base,Policies,Value,Reference,Pointer,Category,Distance1> p)
{
return p += x;
}
template <class Iterator1, class Iterator2, class Policies, class Value1, class Value2,
class Reference1, class Reference2, class Pointer1, class Pointer2, class Category,
class Distance>
typename iterator_adaptor<Iterator1,Policies,Value1,Reference1,Pointer1,Category,Distance>::difference_type
operator-(
const iterator_adaptor<Iterator1,Policies,Value1,Reference1,Pointer1,Category,Distance>& x,
const iterator_adaptor<Iterator2,Policies,Value2,Reference2,Pointer2,Category,Distance>& y)
{
typedef typename iterator_adaptor<Iterator1,Policies,Value1,Reference1,
Pointer1,Category,Distance>::difference_type difference_type;
return x.policies().distance(y, x);
}
#ifndef BOOST_RELOPS_AMBIGUITY_BUG
template <class Iterator1, class Iterator2, class Policies, class Value1, class Value2,
class Reference1, class Reference2, class Pointer1, class Pointer2,
class Category, class Distance>
inline bool
operator==(
const iterator_adaptor<Iterator1,Policies,Value1,Reference1,Pointer1,Category,Distance>& x,
const iterator_adaptor<Iterator2,Policies,Value2,Reference2,Pointer2,Category,Distance>& y)
{
return x.policies().equal(x, y);
}
template <class Iterator1, class Iterator2, class Policies, class Value1, class Value2,
class Reference1, class Reference2, class Pointer1, class Pointer2,
class Category, class Distance>
inline bool
operator<(
const iterator_adaptor<Iterator1,Policies,Value1,Reference1,Pointer1,Category,Distance>& x,
const iterator_adaptor<Iterator2,Policies,Value2,Reference2,Pointer2,Category,Distance>& y)
{
return x.policies().distance(y, x) < 0;
}
template <class Iterator1, class Iterator2, class Policies, class Value1, class Value2,
class Reference1, class Reference2, class Pointer1, class Pointer2,
class Category, class Distance>
inline bool
operator>(
const iterator_adaptor<Iterator1,Policies,Value1,Reference1,Pointer1,Category,Distance>& x,
const iterator_adaptor<Iterator2,Policies,Value2,Reference2,Pointer2,Category,Distance>& y)
{
return x.policies().distance(y, x) > 0;
}
template <class Iterator1, class Iterator2, class Policies, class Value1, class Value2,
class Reference1, class Reference2, class Pointer1, class Pointer2,
class Category, class Distance>
inline bool
operator>=(
const iterator_adaptor<Iterator1,Policies,Value1,Reference1,Pointer1,Category,Distance>& x,
const iterator_adaptor<Iterator2,Policies,Value2,Reference2,Pointer2,Category,Distance>& y)
{
return x.policies().distance(y, x) >= 0;
}
template <class Iterator1, class Iterator2, class Policies, class Value1, class Value2,
class Reference1, class Reference2, class Pointer1, class Pointer2,
class Category, class Distance>
inline bool
operator<=(
const iterator_adaptor<Iterator1,Policies,Value1,Reference1,Pointer1,Category,Distance>& x,
const iterator_adaptor<Iterator2,Policies,Value2,Reference2,Pointer2,Category,Distance>& y)
{
return x.policies().distance(y, x) <= 0;
}
template <class Iterator1, class Iterator2, class Policies, class Value1, class Value2,
class Reference1, class Reference2, class Pointer1, class Pointer2,
class Category, class Distance>
inline bool
operator!=(
const iterator_adaptor<Iterator1,Policies,Value1,Reference1,Pointer1,Category,Distance>& x,
const iterator_adaptor<Iterator2,Policies,Value2,Reference2,Pointer2,Category,Distance>& y)
{
return !x.policies().equal(x, y);
}
#endif
} // namespace multi_array
} // namespace detail
} // namespace boost
# undef BOOST_ARG_DEPENDENT_TYPENAME
#endif

View File

@@ -1,14 +1,14 @@
// Copyright (C) 2002 Ronald Garcia
//
// Permission to copy, use, sell and distribute this software is granted
// provided this copyright notice appears in all copies.
// Permission to modify the code and to distribute modified code is granted
// provided this copyright notice appears in all copies, and a notice
// that the code was modified is included with the copyright notice.
//
// This software is provided "as is" without express or implied warranty,
// and with no claim as to its suitability for any purpose.
//
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
#ifndef BOOST_MULTI_ARRAY_REF_RG071801_HPP
#define BOOST_MULTI_ARRAY_REF_RG071801_HPP
@@ -48,14 +48,13 @@ public:
typedef typename super_type::value_type value_type;
typedef typename super_type::const_reference const_reference;
typedef typename super_type::const_iterator const_iterator;
typedef typename super_type::const_iter_base const_iter_base;
typedef typename super_type::const_reverse_iterator const_reverse_iterator;
typedef typename super_type::element element;
typedef typename super_type::size_type size_type;
typedef typename super_type::difference_type difference_type;
typedef typename super_type::index index;
typedef typename super_type::extent_range extent_range;
typedef general_storage_order<NumDims> storage_order_type;
// template typedefs
template <std::size_t NDims>
@@ -72,6 +71,9 @@ public:
// make const_multi_array_ref a friend of itself
template <typename,std::size_t,typename>
friend class const_multi_array_ref;
// template <typename From, typename To> // needed for enable_if_convertible tests
// friend class boost::detail::is_convertible_basic_impl;
#endif
template <typename OPtr>
@@ -142,14 +144,14 @@ public:
detail::multi_array::CollectionConcept<BaseList> >();
boost::copy_n(values.begin(),num_dimensions(),index_base_list_.begin());
origin_offset_ =
calculate_origin_offset(stride_list_,extent_list_,
this->calculate_origin_offset(stride_list_,extent_list_,
storage_,index_base_list_);
}
void reindex(index value) {
index_base_list_.assign(value);
origin_offset_ =
calculate_origin_offset(stride_list_,extent_list_,
this->calculate_origin_offset(stride_list_,extent_list_,
storage_,index_base_list_);
}
@@ -162,10 +164,10 @@ public:
size_type(1),std::multiplies<size_type>()));
std::copy(extents.begin(),extents.end(),extent_list_.begin());
compute_strides(stride_list_,extent_list_,storage_);
this->compute_strides(stride_list_,extent_list_,storage_);
origin_offset_ =
calculate_origin_offset(stride_list_,extent_list_,
this->calculate_origin_offset(stride_list_,extent_list_,
storage_,index_base_list_);
}
@@ -195,6 +197,11 @@ public:
return index_base_list_.data();
}
const storage_order_type& storage_order() const {
return storage_;
}
template <typename IndexList>
const element& operator()(IndexList indices) const {
boost::function_requires<
@@ -232,13 +239,13 @@ public:
}
const_iterator begin() const {
return const_iterator(const_iter_base(*index_bases(),origin(),
shape(),strides(),index_bases()));
return const_iterator(*index_bases(),origin(),
shape(),strides(),index_bases());
}
const_iterator end() const {
return const_iterator(const_iter_base(*index_bases()+*shape(),origin(),
shape(),strides(),index_bases()));
return const_iterator(*index_bases()+*shape(),origin(),
shape(),strides(),index_bases());
}
const_reverse_iterator rbegin() const {
@@ -296,6 +303,17 @@ public:
return !(*this < rhs);
}
protected:
// This is only supplied to support multi_array's default constructor
explicit const_multi_array_ref(TPtr base) :
base_(base), storage_(c_storage_order()) {
index_base_list_.assign(0);
boost::array<size_type,NumDims> filler;
filler.assign(0);
init_multi_array_ref(filler.begin());
}
// This ensures that const_multi_array_ref types with different TPtr
// types can convert to each other
#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
@@ -307,9 +325,10 @@ public:
void set_base_ptr(TPtr new_base) { base_ = new_base; }
template <typename OPtr>
const_multi_array_ref(const detail::multi_array::
const_sub_array<T,NumDims,OPtr>& rhs)
: base_(rhs.origin()),
const_multi_array_ref(
const detail::multi_array::const_sub_array<T,NumDims,OPtr>& rhs
)
: base_(0), // playing it "safe"; so we learn of errors
storage_(c_storage_order()),
origin_offset_(0), directional_offset_(0),
num_elements_(rhs.num_elements())
@@ -324,7 +343,7 @@ public:
typedef boost::array<index,NumDims> index_list;
TPtr base_;
general_storage_order<NumDims> storage_;
storage_order_type storage_;
size_list extent_list_;
index_list stride_list_;
index_list index_base_list_;
@@ -366,20 +385,20 @@ private:
// Calculate the array size
num_elements_ = std::accumulate(extent_list_.begin(),extent_list_.end(),
1,std::multiplies<index>());
#if 0
assert(num_elements_ != 0);
compute_strides(stride_list_,extent_list_,storage_);
#endif
this->compute_strides(stride_list_,extent_list_,storage_);
origin_offset_ =
calculate_origin_offset(stride_list_,extent_list_,
this->calculate_origin_offset(stride_list_,extent_list_,
storage_,index_base_list_);
directional_offset_ =
calculate_descending_dimension_offset(stride_list_,extent_list_,
this->calculate_descending_dimension_offset(stride_list_,extent_list_,
storage_);
}
};
template <typename T, std::size_t NumDims>
class multi_array_ref :
public const_multi_array_ref<T,NumDims,T*>
@@ -389,11 +408,9 @@ public:
typedef typename super_type::value_type value_type;
typedef typename super_type::reference reference;
typedef typename super_type::iterator iterator;
typedef typename super_type::iter_base iter_base;
typedef typename super_type::reverse_iterator reverse_iterator;
typedef typename super_type::const_reference const_reference;
typedef typename super_type::const_iterator const_iterator;
typedef typename super_type::const_iter_base const_iter_base;
typedef typename super_type::const_reverse_iterator const_reverse_iterator;
typedef typename super_type::element element;
typedef typename super_type::size_type size_type;
@@ -455,11 +472,11 @@ public:
ConstMultiArrayConcept<ConstMultiArray,NumDims> >();
// make sure the dimensions agree
assert(other.num_dimensions() == num_dimensions());
assert(std::equal(other.shape(),other.shape()+num_dimensions(),
shape()));
assert(other.num_dimensions() == this->num_dimensions());
assert(std::equal(other.shape(),other.shape()+this->num_dimensions(),
this->shape()));
// iterator-based copy
std::copy(other.begin(),other.end(),begin());
std::copy(other.begin(),other.end(),this->begin());
return *this;
}
@@ -467,18 +484,18 @@ public:
if (&other != this) {
// make sure the dimensions agree
assert(other.num_dimensions() == num_dimensions());
assert(std::equal(other.shape(),other.shape()+num_dimensions(),
shape()));
assert(other.num_dimensions() == this->num_dimensions());
assert(std::equal(other.shape(),other.shape()+this->num_dimensions(),
this->shape()));
// iterator-based copy
std::copy(other.begin(),other.end(),begin());
std::copy(other.begin(),other.end(),this->begin());
}
return *this;
}
element* origin() { return base_+origin_offset_; }
element* origin() { return super_type::base_+super_type::origin_offset_; }
element* data() { return base_; }
element* data() { return super_type::base_; }
template <class IndexList>
element& operator()(const IndexList& indices) {
@@ -486,15 +503,15 @@ public:
detail::multi_array::CollectionConcept<IndexList> >();
return super_type::access_element(boost::type<element&>(),
origin(),
indices,strides());
indices,this->strides());
}
reference operator[](index idx) {
return super_type::access(boost::type<reference>(),
idx,origin(),
shape(),strides(),
index_bases());
this->shape(),this->strides(),
this->index_bases());
}
@@ -511,21 +528,22 @@ public:
return
super_type::generate_array_view(boost::type<return_type>(),
indices,
shape(),
strides(),
index_bases(),
this->shape(),
this->strides(),
this->index_bases(),
origin());
}
iterator begin() {
return iterator(iter_base(*index_bases(),origin(),shape(),
strides(),index_bases()));
return iterator(*this->index_bases(),origin(),this->shape(),
this->strides(),this->index_bases());
}
iterator end() {
return iterator(iter_base(*index_bases()+*shape(),origin(),
shape(),strides(),index_bases()));
return iterator(*this->index_bases()+*this->shape(),origin(),
this->shape(),this->strides(),
this->index_bases());
}
// RG - rbegin() and rend() written naively to thwart MSVC ICE.
@@ -555,7 +573,8 @@ public:
const_reference operator[](index idx) const {
return super_type::access(boost::type<const_reference>(),
idx,origin(),
shape(),strides(),index_bases());
this->shape(),this->strides(),
this->index_bases());
}
// See note attached to generate_array_view in base.hpp
@@ -586,6 +605,14 @@ public:
const_reverse_iterator rend() const {
return super_type::rend();
}
protected:
// This is only supplied to support multi_array's default constructor
explicit multi_array_ref(T* base) :
super_type(base) {
}
};
} // namespace boost

View File

@@ -1,14 +1,14 @@
// Copyright (C) 2002 Ronald Garcia
//
// Permission to copy, use, sell and distribute this software is granted
// provided this copyright notice appears in all copies.
// Permission to modify the code and to distribute modified code is granted
// provided this copyright notice appears in all copies, and a notice
// that the code was modified is included with the copyright notice.
//
// This software is provided "as is" without express or implied warranty,
// and with no claim as to its suitability for any purpose.
//
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
#ifndef RANGE_LIST_RG072501_HPP
#define RANGE_LIST_RG072501_HPP

View File

@@ -1,14 +1,14 @@
// Copyright (C) 2002 Ronald Garcia
//
// Permission to copy, use, sell and distribute this software is granted
// provided this copyright notice appears in all copies.
// Permission to modify the code and to distribute modified code is granted
// provided this copyright notice appears in all copies, and a notice
// that the code was modified is included with the copyright notice.
//
// This software is provided "as is" without express or implied warranty,
// and with no claim as to its suitability for any purpose.
//
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
#ifndef BOOST_STORAGE_ORDER_RG071801_HPP
#define BOOST_STORAGE_ORDER_RG071801_HPP

View File

@@ -1,14 +1,14 @@
// Copyright (C) 2002 Ronald Garcia
//
// Permission to copy, use, sell and distribute this software is granted
// provided this copyright notice appears in all copies.
// Permission to modify the code and to distribute modified code is granted
// provided this copyright notice appears in all copies, and a notice
// that the code was modified is included with the copyright notice.
//
// This software is provided "as is" without express or implied warranty,
// and with no claim as to its suitability for any purpose.
//
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
#ifndef SUBARRAY_RG071801_HPP
#define SUBARRAY_RG071801_HPP
@@ -44,7 +44,6 @@ public:
typedef typename super_type::value_type value_type;
typedef typename super_type::const_reference const_reference;
typedef typename super_type::const_iterator const_iterator;
typedef typename super_type::const_iter_base const_iter_base;
typedef typename super_type::const_reverse_iterator const_reverse_iterator;
typedef typename super_type::element element;
typedef typename super_type::size_type size_type;
@@ -138,13 +137,13 @@ public:
}
const_iterator begin() const {
return const_iterator(const_iter_base(*index_bases(),origin(),
shape(),strides(),index_bases()));
return const_iterator(*index_bases(),origin(),
shape(),strides(),index_bases());
}
const_iterator end() const {
return const_iterator(const_iter_base(*index_bases()+*shape(),origin(),
shape(),strides(),index_bases()));
return const_iterator(*index_bases()+*shape(),origin(),
shape(),strides(),index_bases());
}
const_reverse_iterator rbegin() const {
@@ -195,6 +194,45 @@ private:
const_sub_array& operator=(const const_sub_array&);
};
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
//
// Compilers that don't support partial ordering may need help to
// disambiguate multi_array's templated constructors. Even vc6/7 are
// capable of some limited SFINAE, so we take the most-general version
// out of the overload set with disable_non_sub_array.
//
template <typename T, std::size_t NumDims, typename TPtr>
char is_sub_array_help(const_sub_array<T,NumDims,TPtr>&);
char ( &is_sub_array_help(...) )[2];
template <class T>
struct is_sub_array
{
static T x;
BOOST_STATIC_CONSTANT(bool, value = sizeof((is_sub_array_help)(x)) == 1);
};
template <bool sub_array = false>
struct disable_non_sub_array_impl
{
// forming a pointer to a reference triggers SFINAE
typedef int& type;
};
template <>
struct disable_non_sub_array_impl<true>
{
typedef int type;
};
template <class T>
struct disable_non_sub_array
{
typedef typename disable_non_sub_array_impl<is_sub_array<T>::value>::type type;
};
#endif
//
// sub_array
// multi_array's proxy class to allow multiple overloads of
@@ -211,11 +249,9 @@ public:
typedef typename super_type::size_type size_type;
typedef typename super_type::iterator iterator;
typedef typename super_type::reverse_iterator reverse_iterator;
typedef typename super_type::iter_base iter_base;
typedef typename super_type::const_reference const_reference;
typedef typename super_type::const_iterator const_iterator;
typedef typename super_type::const_reverse_iterator const_reverse_iterator;
typedef typename super_type::const_iter_base const_iter_base;
// template typedefs
template <std::size_t NDims>
@@ -235,9 +271,9 @@ public:
ConstMultiArray, NumDims> >();
// make sure the dimensions agree
assert(other.num_dimensions() == num_dimensions());
assert(std::equal(other.shape(),other.shape()+num_dimensions(),
shape()));
assert(other.num_dimensions() == this->num_dimensions());
assert(std::equal(other.shape(),other.shape()+this->num_dimensions(),
this->shape()));
// iterator-based copy
std::copy(other.begin(),other.end(),begin());
return *this;
@@ -247,21 +283,22 @@ public:
sub_array& operator=(const sub_array& other) {
if (&other != this) {
// make sure the dimensions agree
assert(other.num_dimensions() == num_dimensions());
assert(std::equal(other.shape(),other.shape()+num_dimensions(),
shape()));
assert(other.num_dimensions() == this->num_dimensions());
assert(std::equal(other.shape(),other.shape()+this->num_dimensions(),
this->shape()));
// iterator-based copy
std::copy(other.begin(),other.end(),begin());
}
return *this;
}
T* origin() { return base_; }
const T* origin() const { return base_; }
T* origin() { return this->base_; }
const T* origin() const { return this->base_; }
reference operator[](index idx) {
return super_type::access(boost::type<reference>(),
idx,base_,shape(),strides(),index_bases());
idx,this->base_,this->shape(),this->strides(),
this->index_bases());
}
// see generate_array_view in base.hpp
@@ -277,9 +314,9 @@ public:
return
super_type::generate_array_view(boost::type<return_type>(),
indices,
shape(),
strides(),
index_bases(),
this->shape(),
this->strides(),
this->index_bases(),
origin());
}
@@ -287,17 +324,17 @@ public:
element& operator()(const IndexList& indices) {
return super_type::access_element(boost::type<element&>(),
origin(),
indices,strides());
indices,this->strides());
}
iterator begin() {
return iterator(iter_base(*index_bases(),origin(),
shape(),strides(),index_bases()));
return iterator(*this->index_bases(),origin(),
this->shape(),this->strides(),this->index_bases());
}
iterator end() {
return iterator(iter_base(*index_bases()+*shape(),origin(),
shape(),strides(),index_bases()));
return iterator(*this->index_bases()+*this->shape(),origin(),
this->shape(),this->strides(),this->index_bases());
}
// RG - rbegin() and rend() written naively to thwart MSVC ICE.

View File

@@ -1,14 +1,15 @@
// Copyright (C) 2002 Ronald Garcia
//
// Permission to copy, use, sell and distribute this software is granted
// provided this copyright notice appears in all copies.
// Permission to modify the code and to distribute modified code is granted
// provided this copyright notice appears in all copies, and a notice
// that the code was modified is included with the copyright notice.
//
// This software is provided "as is" without express or implied warranty,
// and with no claim as to its suitability for any purpose.
//
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
#ifndef BOOST_MULTI_ARRAY_TYPES_RG071801_HPP
#define BOOST_MULTI_ARRAY_TYPES_RG071801_HPP

View File

@@ -1,14 +1,14 @@
// Copyright (C) 2002 Ronald Garcia
//
// Permission to copy, use, sell and distribute this software is granted
// provided this copyright notice appears in all copies.
// Permission to modify the code and to distribute modified code is granted
// provided this copyright notice appears in all copies, and a notice
// that the code was modified is included with the copyright notice.
//
// This software is provided "as is" without express or implied warranty,
// and with no claim as to its suitability for any purpose.
//
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
#ifndef BOOST_MULTI_ARRAY_VIEW_RG071301_HPP
#define BOOST_MULTI_ARRAY_VIEW_RG071301_HPP
@@ -44,7 +44,6 @@ public:
typedef typename super_type::value_type value_type;
typedef typename super_type::const_reference const_reference;
typedef typename super_type::const_iterator const_iterator;
typedef typename super_type::const_iter_base const_iter_base;
typedef typename super_type::const_reverse_iterator const_reverse_iterator;
typedef typename super_type::element element;
typedef typename super_type::size_type size_type;
@@ -76,13 +75,13 @@ public:
void reindex(const BaseList& values) {
boost::copy_n(values.begin(),num_dimensions(),index_base_list_.begin());
origin_offset_ =
calculate_indexing_offset(stride_list_,index_base_list_);
this->calculate_indexing_offset(stride_list_,index_base_list_);
}
void reindex(index value) {
index_base_list_.assign(value);
origin_offset_ =
calculate_indexing_offset(stride_list_,index_base_list_);
this->calculate_indexing_offset(stride_list_,index_base_list_);
}
size_type num_dimensions() const { return NumDims; }
@@ -142,13 +141,13 @@ public:
origin());
}
const_iterator begin() const {
return const_iterator(const_iter_base(*index_bases(),origin(),
shape(),strides(),index_bases()));
return const_iterator(*index_bases(),origin(),
shape(),strides(),index_bases());
}
const_iterator end() const {
return const_iterator(const_iter_base(*index_bases()+*shape(),origin(),
shape(),strides(),index_bases()));
return const_iterator(*index_bases()+*shape(),origin(),
shape(),strides(),index_bases());
}
const_reverse_iterator rbegin() const {
@@ -232,7 +231,9 @@ public: // should be protected
// Calculate the array size
num_elements_ = std::accumulate(extent_list_.begin(),extent_list_.end(),
size_type(1),std::multiplies<size_type>());
#if 0
assert(num_elements_ != 0);
#endif
}
typedef boost::array<size_type,NumDims> size_list;
@@ -260,11 +261,9 @@ public:
typedef typename super_type::value_type value_type;
typedef typename super_type::reference reference;
typedef typename super_type::iterator iterator;
typedef typename super_type::iter_base iter_base;
typedef typename super_type::reverse_iterator reverse_iterator;
typedef typename super_type::const_reference const_reference;
typedef typename super_type::const_iterator const_iterator;
typedef typename super_type::const_iter_base const_iter_base;
typedef typename super_type::const_reverse_iterator const_reverse_iterator;
typedef typename super_type::element element;
typedef typename super_type::size_type size_type;
@@ -291,9 +290,9 @@ public:
ConstMultiArrayConcept<ConstMultiArray,NumDims> >();
// make sure the dimensions agree
assert(other.num_dimensions() == num_dimensions());
assert(std::equal(other.shape(),other.shape()+num_dimensions(),
shape()));
assert(other.num_dimensions() == this->num_dimensions());
assert(std::equal(other.shape(),other.shape()+this->num_dimensions(),
this->shape()));
// iterator-based copy
std::copy(other.begin(),other.end(),begin());
return *this;
@@ -303,30 +302,30 @@ public:
multi_array_view& operator=(const multi_array_view& other) {
if (&other != this) {
// make sure the dimensions agree
assert(other.num_dimensions() == num_dimensions());
assert(std::equal(other.shape(),other.shape()+num_dimensions(),
shape()));
assert(other.num_dimensions() == this->num_dimensions());
assert(std::equal(other.shape(),other.shape()+this->num_dimensions(),
this->shape()));
// iterator-based copy
std::copy(other.begin(),other.end(),begin());
}
return *this;
}
element* origin() { return base_+origin_offset_; }
element* origin() { return this->base_+this->origin_offset_; }
template <class IndexList>
element& operator()(const IndexList& indices) {
return super_type::access_element(boost::type<element&>(),
origin(),
indices,strides());
indices,this->strides());
}
reference operator[](index idx) {
return super_type::access(boost::type<reference>(),
idx,origin(),
shape(),strides(),
index_bases());
this->shape(),this->strides(),
this->index_bases());
}
@@ -343,21 +342,23 @@ public:
return
super_type::generate_array_view(boost::type<return_type>(),
indices,
shape(),
strides(),
index_bases(),
this->shape(),
this->strides(),
this->index_bases(),
origin());
}
iterator begin() {
return iterator(iter_base(*index_bases(),origin(),
shape(),strides(),index_bases()));
return iterator(*this->index_bases(),origin(),
this->shape(),this->strides(),
this->index_bases());
}
iterator end() {
return iterator(iter_base(*index_bases()+*shape(),origin(),
shape(),strides(),index_bases()));
return iterator(*this->index_bases()+*this->shape(),origin(),
this->shape(),this->strides(),
this->index_bases());
}
reverse_iterator rbegin() {

50
test/Jamfile Executable file
View File

@@ -0,0 +1,50 @@
# Copyright David Abrahams 2003. Permission to copy, use,
# modify, sell and distribute this software is granted provided this
# copyright notice appears in all copies. This software is provided
# "as is" without express or implied warranty, and with no claim as
# to its suitability for any purpose.
subproject libs/multi_array/test ;
import testing ;
test-suite multi_array
:
[ compile-fail fail_cbracket.cpp ]
[ compile-fail fail_cdata.cpp ]
[ compile-fail fail_citerator.cpp ]
[ compile-fail fail_cparen.cpp ]
[ compile-fail fail_criterator.cpp ]
[ compile-fail fail_csubarray.cpp ]
[ compile-fail fail_csubarray2.cpp ]
[ compile-fail fail_csubarray3.cpp ]
[ compile-fail fail_cview.cpp ]
[ compile-fail fail_cview2.cpp ]
[ compile-fail fail_cview3.cpp ]
[ compile-fail fail_ref_cbracket.cpp ]
[ compile-fail fail_ref_cdata.cpp ]
[ compile-fail fail_ref_citerator.cpp ]
[ compile-fail fail_ref_cparen.cpp ]
[ compile-fail fail_ref_criterator.cpp ]
[ compile-fail fail_ref_csubarray.cpp ]
[ compile-fail fail_ref_csubarray2.cpp ]
[ compile-fail fail_ref_csubarray3.cpp ]
[ compile-fail fail_ref_cview.cpp ]
[ compile-fail fail_ref_cview2.cpp ]
[ compile-fail fail_ref_cview3.cpp ]
[ run constructors.cpp <lib>../../test/build/boost_test_exec_monitor ]
[ run access.cpp <lib>../../test/build/boost_test_exec_monitor ]
[ run compare.cpp <lib>../../test/build/boost_test_exec_monitor ]
[ run iterators.cpp <lib>../../test/build/boost_test_exec_monitor ]
[ run slice.cpp <lib>../../test/build/boost_test_exec_monitor ]
[ run assign.cpp <lib>../../test/build/boost_test_exec_monitor ]
[ run index_bases.cpp <lib>../../test/build/boost_test_exec_monitor ]
[ run storage_order.cpp <lib>../../test/build/boost_test_exec_monitor ]
[ run reshape.cpp <lib>../../test/build/boost_test_exec_monitor ]
[ run range1.cpp <lib>../../test/build/boost_test_exec_monitor ]
[ run idxgen1.cpp <lib>../../test/build/boost_test_exec_monitor ]
[ run stl_interaction.cpp <lib>../../test/build/boost_test_exec_monitor ]
[ run resize.cpp <lib>../../test/build/boost_test_exec_monitor ]
[ compile concept_checks.cpp ]
;

View File

@@ -1,9 +1,22 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
//
// access.cpp - operator[] and operator() tests with various arrays
// The tests assume that they are working on an Array of shape 2x3x4
//
#include "generative_tests.hpp"
#include "boost/static_assert.hpp"
template <typename Array>
void access(Array& A, const mutable_array_tag&) {
@@ -16,8 +29,8 @@ void access(Array& A, const mutable_array_tag&) {
template <typename Array>
void access(Array& A, const const_array_tag&) {
const int ndims = 3;
const unsigned int ndims = 3;
BOOST_STATIC_ASSERT((Array::dimensionality == ndims));
typedef typename Array::index index;
const index idx0 = A.index_bases()[0];
const index idx1 = A.index_bases()[1];

View File

@@ -1,3 +1,15 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
//
// assign.cpp - Test out operator=() on the different types
//
@@ -9,6 +21,11 @@
#include <algorithm>
#include <iostream>
bool equal(const int& a, const int& b)
{
return a == b;
}
template <typename ArrayA, typename ArrayB>
bool equal(const ArrayA& A, const ArrayB& B)
{
@@ -20,11 +37,6 @@ bool equal(const ArrayA& A, const ArrayB& B)
return true;
}
bool equal(const int& a, const int& b)
{
return a == b;
}
template <typename Array>
void access(Array& A, const mutable_array_tag&) {

View File

@@ -1,3 +1,15 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
#include "boost/multi_array.hpp"

View File

@@ -1,3 +1,15 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
//
// concept_checks.cpp -
// make sure the types meet concept requirements

View File

@@ -1,3 +1,15 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
//
// constructors.cpp - Testing out the various constructor options
//
@@ -10,9 +22,12 @@
#include <algorithm>
#include <list>
void check_shape(const double&, std::size_t*, int*, unsigned int)
{}
template <class Array>
void check_shape(const Array& A,
unsigned int* sizes,
std::size_t* sizes,
int* strides,
unsigned int num_elements)
{
@@ -23,8 +38,11 @@ void check_shape(const Array& A,
check_shape(A[0], ++sizes, ++strides, num_elements / A.size());
}
void check_shape(const double&, unsigned int*, int*, unsigned int)
{}
bool equal(const double& a, const double& b)
{
return a == b;
}
template <typename ArrayA, typename ArrayB>
bool equal(const ArrayA& A, const ArrayB& B)
@@ -36,10 +54,6 @@ bool equal(const ArrayA& A, const ArrayB& B)
return false;
return true;
}
bool equal(const double& a, const double& b)
{
return a == b;
}
int
@@ -50,6 +64,11 @@ test_main(int, char*[])
int strides[] = { 9, 3, 1 };
size_type num_elements = 27;
// Default multi_array constructor
{
boost::multi_array<double, 3> A;
}
// Constructor 1, default storage order and allocator
{
boost::multi_array<double, 3> A(sizes);

View File

@@ -1,3 +1,15 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
//
// Trying to diagnose problems under visual

View File

@@ -1,3 +1,15 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
//
// fail_cbracket.cpp -
// checking constness of const operator[].

View File

@@ -1,3 +1,15 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
//
// fail_cdata.cpp
// Testing data() member function constness.
@@ -25,7 +37,6 @@ test_main(int,char*[])
const array& csma = sma;
// FAIL! data() returns a const int*
int* cdptr = csma.data();
(void)cdptr; // suppress compiler warnings;
*csma.data() = 0;
return boost::exit_success;
}

View File

@@ -1,3 +1,15 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
//
// fail_citerator.cpp -
// const_iterator/iterator conversion test

View File

@@ -1,3 +1,15 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
//
// fail_cparen.cpp -
// Testing const operator() constness.

View File

@@ -1,3 +1,15 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
//
// fail_criterator.cpp
// const_reverse_iterator/reverse_iterator conversion test

View File

@@ -1,3 +1,15 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
//
// fail_csubarray.cpp -
// Testing subarray and const_subarray assignment

View File

@@ -1,3 +1,15 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
//
// fail_csubarray2.cpp
// Testing constness of subarray operations.

View File

@@ -1,3 +1,15 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
//
// fail_csubarray3.cpp
// Testing constness of subarray operations.

View File

@@ -1,3 +1,15 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
//
// fail_cview.cpp -
// ensure const_array_view doesn't allow element assignment.

View File

@@ -1,3 +1,15 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
//
// fail_cview2.cpp
// ensure const_array_view cannot be converted to array_view

View File

@@ -1,3 +1,15 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
//
// fail_cview3.cpp
// ensure const_array_ref doesn't allow assignment.

View File

@@ -1,3 +1,15 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
//
// fail_ref_cbracket.cpp
// checking constness of const operator[].

View File

@@ -1,3 +1,15 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
//
// fail_ref_cdata.cpp -
// Testing data() member function constness.
@@ -24,7 +36,6 @@ test_main(int,char*[])
const array_ref& csma = sma;
// FAIL! data() returns const int*.
int* cdptr = csma.data();
(void)cdptr; // suppress compiler warnings
*csma.data() = 0;
return boost::exit_success;
}

View File

@@ -1,3 +1,15 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
//
// fail_ref_citerator.cpp
// const_iterator/iterator conversion test

View File

@@ -1,3 +1,15 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
//
// fail_ref_cparen.cpp
// Testing const operator() constness.

View File

@@ -1,3 +1,15 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
//
// fail_ref_criterator.cpp
// const_reverse_iterator/reverse_iterator conversion test

View File

@@ -1,3 +1,15 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
//
// fail_ref_csubarray.cpp -
// Testing subarray and const_subarray assignment

View File

@@ -1,3 +1,15 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
//
// fail_ref_csubarray2.cpp -
// Testing constness of subarray operations.

View File

@@ -1,3 +1,15 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
//
// fail_ref_csubarray3.cpp -
// Testing constness of subarray operations.

View File

@@ -1,3 +1,15 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
//
// fail_ref_cview.cpp
// ensure const_array_view doesn't allow element assignment.

View File

@@ -1,3 +1,15 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
//
// fail_ref_cview2.cpp
// ensure const_array_view cannot be converted to array_view

View File

@@ -1,3 +1,15 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
//
// fail_ref_cview3.cpp -
// ensure const_array_view doesn't allow assignment.

View File

@@ -1,3 +1,15 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
//
// idxset1.cpp - testing the code for index_gen
//

View File

@@ -1,3 +1,15 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
//
// index_bases - test of the index_base modifying facilities.
//

View File

@@ -1,3 +1,15 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
//
// iterators.cpp - checking out iterator stuffs.
// The tests assume that the array has shape 2x3x4

View File

@@ -1,3 +1,15 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
//
// range1.cpp - test of index_range
//

View File

@@ -1,3 +1,15 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
//
// reshape.cpp - testing reshaping functionality
//

73
test/resize.cpp Normal file
View File

@@ -0,0 +1,73 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
//
// resize.cpp - Test of resizing multi_arrays
//
#include "boost/test/test_tools.hpp"
#include "boost/multi_array.hpp"
#include <iostream>
using namespace std;
int test_main(int,char*[]) {
typedef boost::multi_array<int,3> marray;
int A_data[] = {
0,1,2,3,
4,5,6,7,
8,9,10,11,
12,13,14,15,
16,17,18,19,
20,21,22,23
};
marray A(boost::extents[2][3][4]);
A.assign(A_data,A_data+(2*3*4));
A.resize(boost::extents[4][3][2]);
int A_resize[] = {
0,1,
4,5,
8,9,
12,13,
16,17,
20,21,
0,0,
0,0,
0,0,
0,0,
0,0,
0,0
};
BOOST_TEST(std::equal(A_resize,A_resize+(4*3*2),A.data()));
{
marray defaultA;
defaultA.resize(boost::extents[2][3][4]);
BOOST_TEST(std::accumulate(defaultA.data(),
defaultA.data()+(2*3*4),0) == 0);
}
return boost::exit_success;
}

View File

@@ -1,3 +1,15 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
//
// slice.cpp - testing out slicing on a matrices
//

View File

@@ -1,3 +1,15 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
//
// stl_interaction.cpp - Make sure multi_arrays work with STL containers.
//

View File

@@ -1,3 +1,15 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
//
// storage_order.cpp - testing storage_order-isms.
//

View File

@@ -1,3 +1,15 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
//
// test out my new storage_order stuff
//

View File

@@ -1,3 +1,15 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
//
// index_bases - test of the index_base modifying facilities.
//