Skip to content

Commit 1af5d90

Browse files
committed
vector_base: use new_storage to construct and destroy
Inside of append(), for the case that the underlying storage had to be reallocated to accomodate its new capacity, the code is currently using the old storage (ie., `m_storage`) to do the default construction, and possibly destruction when needing to clean up after an exception. It is more consistent to use the `new_storage` member functions to do so -- after all we are constructing (or destroying) elements in that `new_storage` here. This is essentially a cleanup only, it doesn't actually change behavior, since `new_storage` is created to use a copy of the allocator that's in `m_storage`, so the `default_construct_n` and `destroy` functions called are identical in practice -- it just makes this piece of code more consistent.
1 parent 0f2f85c commit 1af5d90

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

thrust/detail/vector_base.inl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -877,13 +877,13 @@ template<typename T, typename Alloc>
877877
new_end = m_storage.uninitialized_copy(begin(), end(), new_storage.begin());
878878

879879
// construct new elements to insert
880-
m_storage.default_construct_n(new_end, n);
880+
new_storage.default_construct_n(new_end, n);
881881
new_end += n;
882882
} // end try
883883
catch(...)
884884
{
885885
// something went wrong, so destroy & deallocate the new storage
886-
m_storage.destroy(new_storage.begin(), new_end);
886+
new_storage.destroy(new_storage.begin(), new_end);
887887
new_storage.deallocate();
888888

889889
// rethrow

0 commit comments

Comments
 (0)