mirror of
https://github.com/ETLCPP/etl.git
synced 2026-06-16 00:46:03 +08:00
Fixed serious error where etl::vector would always allocate N^2 storage instead of N.
This commit is contained in:
parent
46fb16dd82
commit
a31cae151d
10
vector.h
10
vector.h
@ -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;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user