diff --git a/include/EASTL/list.h b/include/EASTL/list.h index 5e794379..b01f527a 100644 --- a/include/EASTL/list.h +++ b/include/EASTL/list.h @@ -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 void DoInsertValue(ListNodeBase* pNode, Args&&... args); + void DoInsertValue(ListNodeBase* pNode); + void DoErase(ListNodeBase* pNode); void DoSwap(this_type& x); @@ -832,7 +836,7 @@ namespace eastl inline list::list(size_type n, const allocator_type& allocator) : base_type(allocator) { - DoInsertValues((ListNodeBase*)&internalNode(), n, value_type()); + DoInsertValues((ListNodeBase*)&internalNode(), n); } @@ -1902,7 +1906,7 @@ namespace eastl throw; } #else - ::new((void*)&pNode->mValue) value_type; + ::new((void*)&pNode->mValue) value_type(); #endif return pNode; @@ -1978,6 +1982,13 @@ namespace eastl DoInsertValue(pNode, value); } + template + inline void list::DoInsertValues(ListNodeBase* pNode, size_type n) + { + for (; n > 0; --n) + DoInsertValue(pNode); + } + template template @@ -1990,6 +2001,16 @@ namespace eastl #endif } + template + inline void list::DoInsertValue(ListNodeBase* pNode) + { + node_type* const pNodeNew = DoCreateNode(); + ((ListNodeBase*)pNodeNew)->insert(pNode); + #if EASTL_LIST_SIZE_CACHE + ++mSize; + #endif + } + template inline void list::DoErase(ListNodeBase* pNode) diff --git a/test/source/TestList.cpp b/test/source/TestList.cpp index 8a5e0573..b56cb2b7 100644 --- a/test/source/TestList.cpp +++ b/test/source/TestList.cpp @@ -54,6 +54,12 @@ int TestList() VERIFY(eastl::all_of(l.begin(), l.end(), [](int e) { return e == 0; })); + + TestObject::Reset(); + eastl::list 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);