]> git.lyx.org Git - lyx.git/blobdiff - boost/boost/multi_array/subarray.hpp
* src/MenuBackend.[Ch]: the specialMenu is now a real menu, not a
[lyx.git] / boost / boost / multi_array / subarray.hpp
index 5b1ab067c94e383d4af67e8a3d15f452892ca877..359d00e951a3eb528e6af563c06347011be6d7c2 100644 (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 SUBARRAY_RG071801_HPP
 #define SUBARRAY_RG071801_HPP
 
@@ -32,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;
@@ -63,34 +74,36 @@ public:
   // 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>
@@ -126,13 +139,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()+(index)*shape(),origin(),
+                          shape(),strides(),index_bases());
   }
 
   const_reverse_iterator rbegin() const {
@@ -154,7 +167,7 @@ public:
 
   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>());
   }
 
 
@@ -167,9 +180,9 @@ public:  // Should be protected
 #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) {
   }
@@ -183,6 +196,7 @@ private:
   const_sub_array& operator=(const const_sub_array&);
 };
 
+
 //
 // sub_array
 //    multi_array's proxy class to allow multiple overloads of
@@ -199,11 +213,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>
@@ -223,9 +235,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;
@@ -235,57 +247,61 @@ 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
-#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.
@@ -305,6 +321,8 @@ public:
 
   template <class IndexList>
   const element& operator()(const IndexList& indices) const {
+    boost::function_requires<
+      detail::multi_array::CollectionConcept<IndexList> >();
     return super_type::operator()(indices);
   }
 
@@ -313,14 +331,14 @@ public:
   }
 
   // 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);
   }
@@ -349,9 +367,9 @@ public: // should be private
 #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) {
   }