mirror of
https://github.com/ETLCPP/etl.git
synced 2026-11-09 14:49:53 +08:00
Pointer specialisations of vector
This commit is contained in:
parent
07569d648d
commit
3b78b9c871
@ -424,9 +424,10 @@ namespace etl
|
||||
// The unused branch should be optimised away.
|
||||
if (is_simple_type<value_type>::value)
|
||||
{
|
||||
for (size_t current_size = 0; current_size < n; ++current_size)
|
||||
while (n > 0)
|
||||
{
|
||||
p_buffer[current_size] = value;
|
||||
p_buffer[current_size++] = value;
|
||||
--n;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -600,6 +601,7 @@ namespace etl
|
||||
size_t to = from + n_insert;
|
||||
size_t n_move = std::distance(position, end());
|
||||
size_t n_create_copy = std::min(n_insert, n_move);
|
||||
|
||||
for (size_t i = 0; i < n_create_copy; ++i)
|
||||
{
|
||||
p_buffer[to--] = p_buffer[from--];
|
||||
@ -899,7 +901,7 @@ namespace etl
|
||||
}
|
||||
}
|
||||
|
||||
//#include "ivectorpointer.h"
|
||||
#include "private/ivectorpointer.h"
|
||||
|
||||
#undef __ETL_IN_IVECTOR_H__
|
||||
#endif
|
||||
|
||||
12
src/vector.h
12
src/vector.h
@ -151,7 +151,7 @@ namespace etl
|
||||
/// Constructor.
|
||||
//*************************************************************************
|
||||
vector()
|
||||
: ivector<T*>(reinterpret_cast<void**>(&buffer), MAX_SIZE)
|
||||
: ivector<T*>(reinterpret_cast<T**>(&buffer), MAX_SIZE)
|
||||
{
|
||||
ivector<T*>::initialise();
|
||||
}
|
||||
@ -161,7 +161,7 @@ namespace etl
|
||||
///\param initial_size The initial size of the vector.
|
||||
//*************************************************************************
|
||||
explicit vector(size_t initial_size)
|
||||
: ivector<T*>(reinterpret_cast<void**>(&buffer), MAX_SIZE)
|
||||
: ivector<T*>(reinterpret_cast<T**>(&buffer), MAX_SIZE)
|
||||
{
|
||||
ivector<T*>::initialise();
|
||||
ivector<T*>::resize(initial_size);
|
||||
@ -173,7 +173,7 @@ namespace etl
|
||||
///\param value The value to fill the vector with.
|
||||
//*************************************************************************
|
||||
vector(size_t initial_size, typename ivector<T*>::parameter_t value)
|
||||
: ivector<T*>(reinterpret_cast<void**>(&buffer), MAX_SIZE)
|
||||
: ivector<T*>(reinterpret_cast<T**>(&buffer), MAX_SIZE)
|
||||
{
|
||||
ivector<T*>::initialise();
|
||||
ivector<T*>::resize(initial_size, value);
|
||||
@ -187,7 +187,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
template <typename TIterator>
|
||||
vector(TIterator first, TIterator last)
|
||||
: ivector<T*>(reinterpret_cast<void**>(&buffer), MAX_SIZE)
|
||||
: ivector<T*>(reinterpret_cast<T**>(&buffer), MAX_SIZE)
|
||||
{
|
||||
ivector<T*>::assign(first, last);
|
||||
}
|
||||
@ -196,7 +196,7 @@ namespace etl
|
||||
/// Copy constructor.
|
||||
//*************************************************************************
|
||||
vector(const vector& other)
|
||||
: ivector<T*>(reinterpret_cast<void**>(&buffer), MAX_SIZE)
|
||||
: ivector<T*>(reinterpret_cast<T**>(&buffer), MAX_SIZE)
|
||||
{
|
||||
ivector<T*>::assign(other.begin(), other.end());
|
||||
}
|
||||
@ -216,7 +216,7 @@ namespace etl
|
||||
|
||||
private:
|
||||
|
||||
typename etl::aligned_storage<sizeof(void*) * MAX_SIZE, etl::alignment_of<void*>::value>::type buffer;
|
||||
typename etl::aligned_storage<sizeof(T*) * MAX_SIZE, etl::alignment_of<T*>::value>::type buffer;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -221,6 +221,7 @@
|
||||
<ClInclude Include="..\..\src\iunordered_multimap.h" />
|
||||
<ClInclude Include="..\..\src\iunordered_set.h" />
|
||||
<ClInclude Include="..\..\src\ivector.h" />
|
||||
<ClInclude Include="..\..\src\ivectorpointer.h" />
|
||||
<ClInclude Include="..\..\src\jenkins.h" />
|
||||
<ClInclude Include="..\..\src\largest.h" />
|
||||
<ClInclude Include="..\..\src\list.h" />
|
||||
@ -256,6 +257,7 @@
|
||||
<ClInclude Include="..\..\src\private\multimap_base.h" />
|
||||
<ClInclude Include="..\..\src\private\multiset_base.h" />
|
||||
<ClInclude Include="..\..\src\private\pool_base.h" />
|
||||
<ClInclude Include="..\..\src\private\pvoidvector.h" />
|
||||
<ClInclude Include="..\..\src\private\queue_base.h" />
|
||||
<ClInclude Include="..\..\src\private\set_base.h" />
|
||||
<ClInclude Include="..\..\src\private\stack_base.h" />
|
||||
@ -271,6 +273,7 @@
|
||||
<ClInclude Include="..\..\src\string.h" />
|
||||
<ClInclude Include="..\..\src\test1.h" />
|
||||
<ClInclude Include="..\..\src\test2.h" />
|
||||
<ClInclude Include="..\..\src\type_def.h" />
|
||||
<ClInclude Include="..\..\src\type_traits.h" />
|
||||
<ClInclude Include="..\..\src\u16string.h" />
|
||||
<ClInclude Include="..\..\src\u32string.h" />
|
||||
|
||||
@ -510,6 +510,15 @@
|
||||
<ClInclude Include="..\..\src\wstring.h">
|
||||
<Filter>ETL\Containers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ivectorpointer.h">
|
||||
<Filter>ETL\Containers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\private\pvoidvector.h">
|
||||
<Filter>ETL\Private</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\type_def.h">
|
||||
<Filter>ETL\Utilities</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\unittest-cpp\UnitTest++\AssertException.cpp">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user