Fixed serious error where etl::vector would always allocate N^2 storage instead of N.

This commit is contained in:
John Wellbelove 2015-09-13 21:13:53 +01:00
parent 46fb16dd82
commit a31cae151d

View File

@ -64,7 +64,7 @@ namespace etl
/// Constructor.
//*************************************************************************
vector()
: ivector<T>(reinterpret_cast<T*>(&buffer[0]), MAX_SIZE)
: ivector<T>(reinterpret_cast<T*>(&buffer), MAX_SIZE)
{
}
@ -73,7 +73,7 @@ namespace etl
///\param initialSize The initial size of the vector.
//*************************************************************************
explicit vector(size_t initialSize)
: ivector<T>(reinterpret_cast<T*>(&buffer[0]), MAX_SIZE)
: ivector<T>(reinterpret_cast<T*>(&buffer), MAX_SIZE)
{
ivector<T>::resize(initialSize);
}
@ -84,7 +84,7 @@ namespace etl
///\param value The value to fill the vector with.
//*************************************************************************
vector(size_t initialSize, typename ivector<T>::parameter_t value)
: ivector<T>(reinterpret_cast<T*>(&buffer[0]), MAX_SIZE)
: ivector<T>(reinterpret_cast<T*>(&buffer), MAX_SIZE)
{
ivector<T>::resize(initialSize, value);
}
@ -97,7 +97,7 @@ namespace etl
//*************************************************************************
template <typename TIterator>
vector(TIterator first, TIterator last)
: ivector<T>(reinterpret_cast<T*>(&buffer[0]), MAX_SIZE)
: ivector<T>(reinterpret_cast<T*>(&buffer), MAX_SIZE)
{
ivector<T>::assign(first, last);
}
@ -117,7 +117,7 @@ namespace etl
private:
typename etl::aligned_storage<sizeof(T) * MAX_SIZE, etl::alignment_of<T>::value>::type buffer[MAX_SIZE];
typename etl::aligned_storage<sizeof(T) * MAX_SIZE, etl::alignment_of<T>::value>::type buffer;
};
}