From 8db59c200fe82d87e140d5fc8564a6a49a0d3cae Mon Sep 17 00:00:00 2001 From: Michael Stevens Date: Sat, 4 Sep 2004 14:47:39 +0000 Subject: [PATCH] fix unbounded_array copy cstrct with size_ explicit 0 value for range, stride values 0 svn path=/trunk/boost/boost/numeric/ublas/; revision=24902 --- include/boost/numeric/ublas/storage.hpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/include/boost/numeric/ublas/storage.hpp b/include/boost/numeric/ublas/storage.hpp index a8bdbdd6..bb079298 100644 --- a/include/boost/numeric/ublas/storage.hpp +++ b/include/boost/numeric/ublas/storage.hpp @@ -106,12 +106,16 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE unbounded_array (const unbounded_array &c): alloc (c.alloc), size_ (c.size_) { - data_ = alloc.allocate (c.size_); - const_iterator ci = c.begin(); - for (iterator i = begin(); i != end(); ++i) { - alloc.construct (&(*i), *ci); - ++ci; + if (size_) { + data_ = alloc.allocate (c.size_); + const_iterator ci = c.begin(); + for (iterator i = begin(); i != end(); ++i) { + alloc.construct (&(*i), *ci); + ++ci; + } } + else + data_ = 0; } BOOST_UBLAS_INLINE ~unbounded_array () { @@ -965,7 +969,7 @@ namespace boost { namespace numeric { namespace ublas { // Construction and destruction BOOST_UBLAS_INLINE range (): - start_ (), size_ () {} + start_ (0), size_ (0) {} BOOST_UBLAS_INLINE range (size_type start, size_type stop): start_ (start), size_ (stop - start) { @@ -1163,7 +1167,7 @@ namespace boost { namespace numeric { namespace ublas { // Construction and destruction BOOST_UBLAS_INLINE slice (): - start_ (), stride_ (), size_ () {} + start_ (0), stride_ (0), size_ (0) {} BOOST_UBLAS_INLINE slice (size_type start, difference_type stride, size_type size): start_ (start), stride_ (stride), size_ (size) {}