Imported Upstream version 1.57.0
[platform/upstream/boost.git] / boost / numeric / ublas / storage.hpp
index b7f9009..9dfaaee 100644 (file)
@@ -128,7 +128,7 @@ namespace boost { namespace numeric { namespace ublas {
                             }
                         }
                         else {
-                            for (pointer si = p_data; si != p_data + size_; ++si) {
+                            for (; si != p_data + size_; ++si) {
                                 alloc_.construct (di, *si);
                                 ++di;
                             }
@@ -229,9 +229,17 @@ namespace boost { namespace numeric { namespace ublas {
             return data_;
         }
         BOOST_UBLAS_INLINE
+        const_iterator cbegin () const {
+            return begin ();
+        }
+        BOOST_UBLAS_INLINE
         const_iterator end () const {
             return data_ + size_;
         }
+        BOOST_UBLAS_INLINE
+        const_iterator cend () const {
+            return end ();
+        }
 
         BOOST_UBLAS_INLINE
         iterator begin () {
@@ -251,10 +259,18 @@ namespace boost { namespace numeric { namespace ublas {
             return const_reverse_iterator (end ());
         }
         BOOST_UBLAS_INLINE
+        const_reverse_iterator crbegin () const {
+            return rbegin ();
+        }
+        BOOST_UBLAS_INLINE
         const_reverse_iterator rend () const {
             return const_reverse_iterator (begin ());
         }
         BOOST_UBLAS_INLINE
+        const_reverse_iterator crend () const {
+            return rend ();
+        }
+        BOOST_UBLAS_INLINE
         reverse_iterator rbegin () {
             return reverse_iterator (end ());
         }
@@ -273,7 +289,7 @@ namespace boost { namespace numeric { namespace ublas {
 
         // Serialization
         template<class Archive>
-        void serialize(Archive & ar, const unsigned int version)
+        void serialize(Archive & ar, const unsigned int /*version*/)
         { 
             serialization::collection_size_type s(size_);
             ar & serialization::make_nvp("size",s);
@@ -412,9 +428,17 @@ namespace boost { namespace numeric { namespace ublas {
             return data_;
         }
         BOOST_UBLAS_INLINE
+        const_iterator cbegin () const {
+            return begin ();
+        }
+        BOOST_UBLAS_INLINE
         const_iterator end () const {
             return data_ + size_;
         }
+        BOOST_UBLAS_INLINE
+        const_iterator cend () const {
+            return end ();
+        }
 
         BOOST_UBLAS_INLINE
         iterator begin () {
@@ -434,10 +458,18 @@ namespace boost { namespace numeric { namespace ublas {
             return const_reverse_iterator (end ());
         }
         BOOST_UBLAS_INLINE
+        const_reverse_iterator crbegin () const {
+            return rbegin ();
+        }
+        BOOST_UBLAS_INLINE
         const_reverse_iterator rend () const {
             return const_reverse_iterator (begin ());
         }
         BOOST_UBLAS_INLINE
+        const_reverse_iterator crend () const {
+            return rend ();
+        }
+        BOOST_UBLAS_INLINE
         reverse_iterator rbegin () {
             return reverse_iterator (end ());
         }
@@ -451,7 +483,7 @@ namespace boost { namespace numeric { namespace ublas {
         friend class boost::serialization::access;
 
         template<class Archive>
-        void serialize(Archive & ar, const unsigned int version)
+        void serialize(Archive & ar, const unsigned int /*version*/)
         {
             serialization::collection_size_type s(size_);
             ar & serialization::make_nvp("size", s);
@@ -464,7 +496,12 @@ namespace boost { namespace numeric { namespace ublas {
 
     private:
         size_type size_;
+// MSVC does not like arrays of size 0 in base classes.  Hence, this conditionally changes the size to 1
+#ifdef _MSC_VER
+        BOOST_UBLAS_BOUNDED_ARRAY_ALIGN value_type data_ [(N>0)?N:1];
+#else
         BOOST_UBLAS_BOUNDED_ARRAY_ALIGN value_type data_ [N];
+#endif
     };
 
 
@@ -623,9 +660,17 @@ namespace boost { namespace numeric { namespace ublas {
             return data_;
         }
         BOOST_UBLAS_INLINE
+        const_iterator cbegin () const {
+            return begin ();
+        }
+        BOOST_UBLAS_INLINE
         const_iterator end () const {
             return data_ + size_;
         }
+        BOOST_UBLAS_INLINE
+        const_iterator cend () const {
+            return end ();
+        }
 
         typedef pointer iterator;
 
@@ -647,10 +692,18 @@ namespace boost { namespace numeric { namespace ublas {
             return const_reverse_iterator (end ());
         }
         BOOST_UBLAS_INLINE
+        const_reverse_iterator crbegin () const {
+            return rbegin ();
+        }
+        BOOST_UBLAS_INLINE
         const_reverse_iterator rend () const {
             return const_reverse_iterator (begin ());
         }
         BOOST_UBLAS_INLINE
+        const_reverse_iterator crend () const {
+            return rend ();
+        }
+        BOOST_UBLAS_INLINE
         reverse_iterator rbegin () {
             return reverse_iterator (end ());
         }
@@ -819,9 +872,17 @@ namespace boost { namespace numeric { namespace ublas {
             return data_.get ();
         }
         BOOST_UBLAS_INLINE
+        const_iterator cbegin () const {
+            return begin ();
+        }
+        BOOST_UBLAS_INLINE
         const_iterator end () const {
             return data_.get () + size_;
         }
+        BOOST_UBLAS_INLINE
+        const_iterator cend () const {
+            return end ();
+        }
 
         typedef pointer iterator;
 
@@ -843,10 +904,18 @@ namespace boost { namespace numeric { namespace ublas {
             return const_reverse_iterator (end ());
         }
         BOOST_UBLAS_INLINE
+        const_reverse_iterator crbegin () const {
+            return rbegin ();
+        }
+        BOOST_UBLAS_INLINE
         const_reverse_iterator rend () const {
             return const_reverse_iterator (begin ());
         }
         BOOST_UBLAS_INLINE
+        const_reverse_iterator crend () const {
+            return rend ();
+        }
+        BOOST_UBLAS_INLINE
         reverse_iterator rbegin () {
             return reverse_iterator (end ());
         }
@@ -1038,9 +1107,17 @@ namespace boost { namespace numeric { namespace ublas {
             return const_iterator (*this, start_);
         }
         BOOST_UBLAS_INLINE
+        const_iterator cbegin () const {
+            return begin ();
+        }
+        BOOST_UBLAS_INLINE
         const_iterator end () const {
             return const_iterator (*this, start_ + size_);
         }
+        BOOST_UBLAS_INLINE
+        const_iterator cend () const {
+            return end ();
+        }
 
         // Reverse iterator
         typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
@@ -1050,9 +1127,17 @@ namespace boost { namespace numeric { namespace ublas {
             return const_reverse_iterator (end ());
         }
         BOOST_UBLAS_INLINE
+        const_reverse_iterator crbegin () const {
+            return rbegin ();
+        }
+        BOOST_UBLAS_INLINE
         const_reverse_iterator rend () const {
             return const_reverse_iterator (begin ());
         }
+        BOOST_UBLAS_INLINE
+        const_reverse_iterator crend () const {
+            return rend ();
+        }
 
         BOOST_UBLAS_INLINE
         basic_range preprocess (size_type size) const {
@@ -1257,9 +1342,17 @@ namespace boost { namespace numeric { namespace ublas {
             return const_iterator (*this, 0);
         }
         BOOST_UBLAS_INLINE
+        const_iterator cbegin () const {
+            return begin ();
+        }
+        BOOST_UBLAS_INLINE
         const_iterator end () const {
             return const_iterator (*this, size_);
         }
+        BOOST_UBLAS_INLINE
+        const_iterator cend () const {
+            return end ();
+        }
 
         // Reverse iterator
         typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
@@ -1269,9 +1362,17 @@ namespace boost { namespace numeric { namespace ublas {
             return const_reverse_iterator (end ());
         }
         BOOST_UBLAS_INLINE
+        const_reverse_iterator crbegin () const {
+            return rbegin ();
+        }
+        BOOST_UBLAS_INLINE
         const_reverse_iterator rend () const {
             return const_reverse_iterator (begin ());
         }
+        BOOST_UBLAS_INLINE
+        const_reverse_iterator crend () const {
+            return rend ();
+        }
 
         BOOST_UBLAS_INLINE
         basic_slice preprocess (size_type size) const {
@@ -1517,9 +1618,17 @@ namespace boost { namespace numeric { namespace ublas {
             return const_iterator (*this, 0);
         }
         BOOST_UBLAS_INLINE
+        const_iterator cbegin () const {
+            return begin ();
+        }
+        BOOST_UBLAS_INLINE
         const_iterator end () const {
             return const_iterator (*this, size_);
         }
+        BOOST_UBLAS_INLINE
+        const_iterator cend () const {
+            return end ();
+        }
 
         // Reverse iterator
         typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
@@ -1529,9 +1638,17 @@ namespace boost { namespace numeric { namespace ublas {
             return const_reverse_iterator (end ());
         }
         BOOST_UBLAS_INLINE
+        const_reverse_iterator crbegin () const {
+            return rbegin ();
+        }
+        BOOST_UBLAS_INLINE
         const_reverse_iterator rend () const {
             return const_reverse_iterator (begin ());
         }
+        BOOST_UBLAS_INLINE
+        const_reverse_iterator crend () const {
+            return rend ();
+        }
 
         BOOST_UBLAS_INLINE
         indirect_array preprocess (size_type size) const {
@@ -1564,7 +1681,6 @@ namespace boost { namespace numeric { namespace ublas {
 
     template <class V>
     class index_pair :
-        private boost::noncopyable,
         public container_reference<V> {
 
         typedef index_pair<V> self_type;
@@ -1603,11 +1719,17 @@ namespace boost { namespace numeric { namespace ublas {
             rhs = *this;
             *this = tmp;
         }
+
         BOOST_UBLAS_INLINE
         friend void swap(self_type& lhs, self_type& rhs) {
             lhs.swap(rhs);
         }
 
+        friend void swap(self_type lhs, self_type rhs) { // For gcc 4.8 and c++11
+            lhs.swap(rhs);
+        }
+
+
         BOOST_UBLAS_INLINE
         bool equal(const self_type& rhs) const {
             return (v1_ == rhs.v1_);
@@ -1700,9 +1822,17 @@ namespace boost { namespace numeric { namespace ublas {
             return const_iterator( (*this), 0);
         }
         BOOST_UBLAS_INLINE
+        const_iterator cbegin () const {
+            return begin ();
+        }
+        BOOST_UBLAS_INLINE
         const_iterator end() const {
             return const_iterator( (*this), size());
         }
+        BOOST_UBLAS_INLINE
+        const_iterator cend () const {
+            return end ();
+        }
 
         // unnecessary function:
         BOOST_UBLAS_INLINE
@@ -1734,7 +1864,6 @@ namespace boost { namespace numeric { namespace ublas {
 
     template <class M>
     class index_triple :
-        private boost::noncopyable,
         public container_reference<M> {
 
         typedef index_triple<M> self_type;
@@ -1775,11 +1904,16 @@ namespace boost { namespace numeric { namespace ublas {
             rhs = *this;
             *this = tmp;
         }
+
         BOOST_UBLAS_INLINE
         friend void swap(self_type& lhs, self_type& rhs) {
             lhs.swap(rhs);
         }
 
+        friend void swap(self_type lhs, self_type rhs) { // For gcc 4.8 and c++11
+            lhs.swap(rhs);
+        }
+
         BOOST_UBLAS_INLINE
         bool equal(const self_type& rhs) const {
             return ((v1_ == rhs.v1_) && (v2_ == rhs.v2_));
@@ -1875,9 +2009,17 @@ namespace boost { namespace numeric { namespace ublas {
             return const_iterator( (*this), 0);
         }
         BOOST_UBLAS_INLINE
+        const_iterator cbegin () const {
+            return begin ();
+        }
+        BOOST_UBLAS_INLINE
         const_iterator end() const {
             return const_iterator( (*this), size());
         }
+        BOOST_UBLAS_INLINE
+        const_iterator cend () const {
+            return end ();
+        }
 
         // unnecessary function:
         BOOST_UBLAS_INLINE