diff -r 46b5323c8f25 boost/numeric/ublas/storage.hpp --- a/boost/numeric/ublas/storage.hpp Tue Apr 24 13:33:16 2007 -0400 +++ b/boost/numeric/ublas/storage.hpp Tue Apr 24 14:09:09 2007 -0400 @@ -116,7 +116,7 @@ namespace boost { namespace numeric { na // Resizing private: BOOST_UBLAS_INLINE - void resize_internal (const size_type size, const value_type init, const bool preserve) { + void resize_internal (const size_type size, value_type const& init, const bool preserve, const bool do_init) { if (size != size_) { pointer p_data = data_; if (size) { @@ -135,13 +135,15 @@ namespace boost { namespace numeric { na alloc_.construct (di, *si); ++di; } - for (; di != data_ + size; ++di) { + if (do_init) { + for (; di != data_ + size; ++di) { alloc_.construct (di, init); + } } } } else { - if (! detail::has_trivial_constructor::value) { + if (do_init) { for (pointer di = data_; di != data_ + size; ++di) alloc_.construct (di, value_type()); } @@ -162,13 +164,13 @@ namespace boost { namespace numeric { na } } public: - BOOST_UBLAS_INLINE - void resize (size_type size) { - resize_internal (size, value_type (), false); - } - BOOST_UBLAS_INLINE - void resize (size_type size, value_type init) { - resize_internal (size, init, true); +// BOOST_UBLAS_INLINE +// void resize (size_type size) { +// resize_internal (size, value_type (), false, !detail::has_trivial_destructor::value); +// } + BOOST_UBLAS_INLINE + void resize (size_type size, bool preserve=false, value_type const& init=value_type(), bool do_init=!detail::has_trivial_constructor::value) { + resize_internal (size, init, preserve, do_init); } // Random Access Container diff -r 46b5323c8f25 boost/numeric/ublas/vector.hpp --- a/boost/numeric/ublas/vector.hpp Tue Apr 24 13:33:16 2007 -0400 +++ b/boost/numeric/ublas/vector.hpp Tue Apr 24 14:09:09 2007 -0400 @@ -109,15 +109,12 @@ namespace boost { namespace numeric { na // Resizing BOOST_UBLAS_INLINE void resize (size_type size, bool preserve = true) { - if (preserve) - data ().resize (size, typename A::value_type ()); - else - data ().resize (size); - } - - BOOST_UBLAS_INLINE - void resize (size_type size, value_type const& init) { - data ().resize (size, init); + data ().resize (size, preserve); + } + + BOOST_UBLAS_INLINE + void resize (size_type size, value_type const& init, bool preserve=true) { + data ().resize (size, preserve, init, true); } // Element support