diff --git a/BAN/include/BAN/Vector.h b/BAN/include/BAN/Vector.h index 2674bd6942..039e264986 100644 --- a/BAN/include/BAN/Vector.h +++ b/BAN/include/BAN/Vector.h @@ -138,10 +138,13 @@ namespace BAN template Vector& Vector::operator=(const Vector& other) { - clear(); MUST(ensure_capacity(other.size())); - for (size_type i = 0; i < other.size(); i++) + for (size_type i = 0; i < BAN::Math::min(size(), other.size()); i++) + m_data[i] = other.m_data[i]; + for (size_type i = size(); i < other.size(); i++) new (m_data + i) T(other[i]); + for (size_type i = other.size(); i < size(); i++) + m_data[i].~T(); m_size = other.m_size; return *this; }