From f67ead2a7336cc18821faca154916db5ee4fb044 Mon Sep 17 00:00:00 2001 From: Michael Stevens Date: Sun, 19 Sep 2004 06:25:52 +0000 Subject: [PATCH] generalize vector storage resize for all storage_array and sequences [SVN r25213] --- include/boost/numeric/ublas/vector.hpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/include/boost/numeric/ublas/vector.hpp b/include/boost/numeric/ublas/vector.hpp index 65ba99c1..6fad05b4 100644 --- a/include/boost/numeric/ublas/vector.hpp +++ b/include/boost/numeric/ublas/vector.hpp @@ -39,6 +39,13 @@ namespace boost { namespace numeric { namespace ublas { // Thanks to Karl Meerbergen for the functor workaround which we use by default template struct resize_functor { + void operator() (A& a, typename A::size_type size, bool ) const { + a.resize (size, typename A::value_type (0)); + } + }; + // Specialise for storage_array + template + struct resize_functor > { void operator() (A& a, typename A::size_type size, bool preserve) const { if (preserve) a.resize (size, typename A::value_type (0)); @@ -47,14 +54,6 @@ namespace boost { namespace numeric { namespace ublas { } }; - // Specialise for std::vector - template - struct resize_functor > { - void operator() (std::vector& a, typename std::vector::size_type size, bool ) const { - a.resize (size); - } - }; - template BOOST_UBLAS_INLINE void resize (A& a, typename A::size_type size, bool preserve) { @@ -69,7 +68,7 @@ namespace boost { namespace numeric { namespace ublas { else a.resize_new (size); } - /* ISSUE Specialise for std::vector + /* ISSUE Specialise for std::vector ONLY * however some (MSVC-6/7) compilers without template partial specialization * also think this is ambiguous when std::vector is used! */