mirror of
https://github.com/boostorg/ublas.git
synced 2026-02-20 15:12:16 +00:00
generalize vector storage resize for all storage_array and sequences
[SVN r25213]
This commit is contained in:
@@ -39,6 +39,13 @@ namespace boost { namespace numeric { namespace ublas {
|
||||
// Thanks to Karl Meerbergen for the functor workaround which we use by default
|
||||
template <class A>
|
||||
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 <class A>
|
||||
struct resize_functor<storage_array<A> > {
|
||||
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 <class T>
|
||||
struct resize_functor<std::vector<T> > {
|
||||
void operator() (std::vector<T>& a, typename std::vector<T>::size_type size, bool ) const {
|
||||
a.resize (size);
|
||||
}
|
||||
};
|
||||
|
||||
template<class A>
|
||||
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!
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user