+// 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
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;
// constness.
const_reference operator[](index idx) const {
return super_type::access(boost::type<const_reference>(),
- idx,base_,shape(),strides(),index_bases());
+ idx,base_,shape(),strides(),index_bases());
}
template <typename IndexList>
const element& operator()(const IndexList& indices) const {
+ boost::function_requires<
+ detail::multi_array::CollectionConcept<IndexList> >();
return super_type::access_element(boost::type<const element&>(),
- origin(),
- indices,strides());
+ indices,origin(),
+ shape(),strides(),index_bases());
}
// see generate_array_view in base.hpp
-#ifndef BOOST_MSVC
+#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
template <int NDims>
#else
template <int NumDims, int NDims> // else ICE
#endif // BOOST_MSVC
typename const_array_view<NDims>::type
operator[](const boost::detail::multi_array::
- index_gen<NumDims,NDims>& indices)
+ index_gen<NumDims,NDims>& indices)
const {
- typedef const_array_view<NDims>::type return_type;
+ typedef typename const_array_view<NDims>::type return_type;
return
super_type::generate_array_view(boost::type<return_type>(),
- indices,
- shape(),
- strides(),
- index_bases(),
- base_);
+ indices,
+ shape(),
+ strides(),
+ index_bases(),
+ base_);
}
template <typename OPtr>
}
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()+(index)*shape(),origin(),
+ shape(),strides(),index_bases());
}
const_reverse_iterator rbegin() const {
size_type num_elements() const {
return std::accumulate(shape(),shape() + num_dimensions(),
- size_type(1), std::multiplies<size_type>());
+ size_type(1), std::multiplies<size_type>());
}
#endif
const_sub_array (TPtr base,
- const size_type* extents,
- const index* strides,
- const index* index_base) :
+ const size_type* extents,
+ const index* strides,
+ const index* index_base) :
base_(base), extents_(extents), strides_(strides),
index_base_(index_base) {
}
const_sub_array& operator=(const const_sub_array&);
};
+
//
// sub_array
// multi_array's proxy class to allow multiple overloads of
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>
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;
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
-#ifndef BOOST_MSVC
+#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
template <int NDims>
#else
template <int NumDims, int NDims> // else ICE
#endif // BOOST_MSVC
typename array_view<NDims>::type
operator[](const boost::detail::multi_array::
- index_gen<NumDims,NDims>& indices) {
- typedef array_view<NDims>::type return_type;
+ index_gen<NumDims,NDims>& indices) {
+ typedef typename array_view<NDims>::type return_type;
return
super_type::generate_array_view(boost::type<return_type>(),
- indices,
- shape(),
- strides(),
- index_bases(),
- origin());
+ indices,
+ this->shape(),
+ this->strides(),
+ this->index_bases(),
+ origin());
}
template <class IndexList>
element& operator()(const IndexList& indices) {
+ boost::function_requires<
+ detail::multi_array::CollectionConcept<IndexList> >();
return super_type::access_element(boost::type<element&>(),
- origin(),
- indices,strides());
+ indices,origin(),
+ this->shape(),this->strides(),
+ this->index_bases());
}
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()+(index)*this->shape(),origin(),
+ this->shape(),this->strides(),this->index_bases());
}
// RG - rbegin() and rend() written naively to thwart MSVC ICE.
template <class IndexList>
const element& operator()(const IndexList& indices) const {
+ boost::function_requires<
+ detail::multi_array::CollectionConcept<IndexList> >();
return super_type::operator()(indices);
}
}
// see generate_array_view in base.hpp
-#ifndef BOOST_MSVC
+#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
template <int NDims>
#else
template <int NumDims, int NDims> // else ICE
#endif // BOOST_MSVC
typename const_array_view<NDims>::type
operator[](const boost::detail::multi_array::
- index_gen<NumDims,NDims>& indices)
+ index_gen<NumDims,NDims>& indices)
const {
return super_type::operator[](indices);
}
#endif
sub_array (T* base,
- const size_type* extents,
- const index* strides,
- const index* index_base) :
+ const size_type* extents,
+ const index* strides,
+ const index* index_base) :
super_type(base,extents,strides,index_base) {
}