Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions include/EASTL/list.h
Original file line number Diff line number Diff line change
Expand Up @@ -471,10 +471,14 @@ namespace eastl
void DoInsert(ListNodeBase* pNode, InputIterator first, InputIterator last, false_type);

void DoInsertValues(ListNodeBase* pNode, size_type n, const value_type& value);

void DoInsertValues(ListNodeBase* pNode, size_type n);

template<typename... Args>
void DoInsertValue(ListNodeBase* pNode, Args&&... args);

void DoInsertValue(ListNodeBase* pNode);

void DoErase(ListNodeBase* pNode);

void DoSwap(this_type& x);
Expand Down Expand Up @@ -832,7 +836,7 @@ namespace eastl
inline list<T, Allocator>::list(size_type n, const allocator_type& allocator)
: base_type(allocator)
{
DoInsertValues((ListNodeBase*)&internalNode(), n, value_type());
DoInsertValues((ListNodeBase*)&internalNode(), n);
}


Expand Down Expand Up @@ -1902,7 +1906,7 @@ namespace eastl
throw;
}
#else
::new((void*)&pNode->mValue) value_type;
::new((void*)&pNode->mValue) value_type();
#endif

return pNode;
Expand Down Expand Up @@ -1978,6 +1982,13 @@ namespace eastl
DoInsertValue(pNode, value);
}

template <typename T, typename Allocator>
inline void list<T, Allocator>::DoInsertValues(ListNodeBase* pNode, size_type n)
{
for (; n > 0; --n)
DoInsertValue(pNode);
}


template <typename T, typename Allocator>
template<typename... Args>
Expand All @@ -1990,6 +2001,16 @@ namespace eastl
#endif
}

template <typename T, typename Allocator>
inline void list<T, Allocator>::DoInsertValue(ListNodeBase* pNode)
{
node_type* const pNodeNew = DoCreateNode();
((ListNodeBase*)pNodeNew)->insert(pNode);
#if EASTL_LIST_SIZE_CACHE
++mSize;
#endif
}


template <typename T, typename Allocator>
inline void list<T, Allocator>::DoErase(ListNodeBase* pNode)
Expand Down
6 changes: 6 additions & 0 deletions test/source/TestList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ int TestList()

VERIFY(eastl::all_of(l.begin(), l.end(), [](int e)
{ return e == 0; }));

TestObject::Reset();
eastl::list<TestObject> l2(test_size);
VERIFY(TestObject::sTOCtorCount == test_size);
VERIFY(TestObject::sTOCopyAssignCount == 0);
VERIFY(TestObject::sTOCopyCtorCount == 0);
}

// list(size_type n, const value_type& value, const allocator_type& allocator = EASTL_LIST_DEFAULT_ALLOCATOR);
Expand Down