add a generic version of std::vector::resize for other stl

implementations
This commit is contained in:
Gael Guennebaud 2009-04-21 21:40:33 +00:00
parent 2697877fac
commit 6f6b5ad016

View File

@ -120,8 +120,17 @@ class vector<T,Eigen::aligned_allocator<T> >
else else
vector_base::insert(vector_base::end(), new_size - vector_base::size(), x); vector_base::insert(vector_base::end(), new_size - vector_base::size(), x);
} }
#else #elif defined(_GLIBCXX_VECTOR)
using vector_base::resize; using vector_base::resize;
#else
// default implementation which should always work.
void resize(size_type new_size, const value_type& x)
{
if (new_size < vector_base::size())
vector_base::erase(vector_base::begin() + new_size, vector_base::end());
else if (new_size > vector_base::size())
vector_base::insert(vector_base::end(), new_size - vector_base::size(), x);
}
#endif #endif
}; };