From 40bd3f3ef7d117a8e263603461fab16dc290d336 Mon Sep 17 00:00:00 2001 From: Michael Stevens Date: Thu, 19 Aug 2004 08:03:42 +0000 Subject: [PATCH] removed experimental type_traits:const_reference For consitency the would be needed for all container typedef It fails with VC6 Added resize that works without PTS [SVN r24589] --- include/boost/numeric/ublas/vector.hpp | 44 ++++++++++++++++---------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/include/boost/numeric/ublas/vector.hpp b/include/boost/numeric/ublas/vector.hpp index 037fe98d..93a0d45e 100644 --- a/include/boost/numeric/ublas/vector.hpp +++ b/include/boost/numeric/ublas/vector.hpp @@ -30,27 +30,44 @@ namespace boost { namespace numeric { namespace ublas { namespace detail { using namespace boost::numeric::ublas; - template - struct resize_functor { + // Resizing helper. Allow 'preserve' parameter to be used where possible. + +#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + // ISSUE Overloaded free function templates fail on some compilers! + // Thanks to Karl Meerbergen for the functor workaround which we use by default + template + struct resize_functor { void operator() (T& a, typename T::size_type size, bool preserve) const { a.resize (size, preserve); } - }; + }; // Specialise for std::vector - template - struct resize_functor< std::vector > { + template + struct resize_functor< std::vector > { void operator() (std::vector& a, typename std::vector::size_type size, bool ) const { a.resize (size); } - }; + }; - // Resizing helpers, allow preserve parameter to be used where possible template BOOST_UBLAS_INLINE void resize (T& a, typename T::size_type size, bool preserve) { resize_functor() (a, size, preserve); } +#else + template + BOOST_UBLAS_INLINE + void resize (T& a, typename T::size_type size, bool preserve) { + a.resize (size, preserve); + } + // Specialise for std::vector + template + BOOST_UBLAS_INLINE + void resize (std::vector &a, typename std::vector::size_type size, bool /* preserve */) { + a.resize (size); + } +#endif } // Array based vector class @@ -65,7 +82,6 @@ namespace boost { namespace numeric { namespace ublas { typedef std::size_t size_type; typedef std::ptrdiff_t difference_type; typedef T value_type; - // typedef const T &const_reference; typedef typename type_traits::const_reference const_reference; typedef T &reference; typedef const T *const_pointer; @@ -587,8 +603,7 @@ namespace boost { namespace numeric { namespace ublas { typedef std::size_t size_type; typedef std::ptrdiff_t difference_type; typedef T value_type; - // typedef const T &const_reference; - typedef typename type_traits::const_reference const_reference; + typedef const T &const_reference; typedef T &reference; typedef const T *const_pointer; typedef T *pointer; @@ -832,8 +847,7 @@ namespace boost { namespace numeric { namespace ublas { typedef std::size_t size_type; typedef std::ptrdiff_t difference_type; typedef T value_type; - // typedef const T &const_reference; - typedef typename type_traits::const_reference const_reference; + typedef const T &const_reference; typedef T &reference; typedef const T *const_pointer; typedef T *pointer; @@ -1037,8 +1051,7 @@ namespace boost { namespace numeric { namespace ublas { typedef std::size_t size_type; typedef std::ptrdiff_t difference_type; typedef T value_type; - // typedef const T &const_reference; - typedef typename type_traits::const_reference const_reference; + typedef const T &const_reference; typedef T &reference; typedef const T *const_pointer; typedef T *pointer; @@ -1267,8 +1280,7 @@ namespace boost { namespace numeric { namespace ublas { typedef std::size_t size_type; typedef std::ptrdiff_t difference_type; typedef T value_type; - // typedef const T &const_reference; - typedef typename type_traits::const_reference const_reference; + typedef const T &const_reference; typedef T &reference; typedef const T *const_pointer; typedef T *pointer;