Skip to content

Commit 12b3725

Browse files
committed
Add assign to fast_vector
1 parent dc0191a commit 12b3725

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

Common.FastVector.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,17 @@ class fast_vector<T, 0, ShouldInitializeElements>
237237
size_ = newSize;
238238
}
239239

240+
// Clear any existing elements and copy the new elements from the iterable range.
241+
template <typename IteratorType>
242+
void assign(size_t newSize, const T& value)
243+
{
244+
clear();
245+
246+
reserve(newSize);
247+
std::uninitialized_fill(begin(), end(), /*out*/ data_);
248+
size_ = newSize;
249+
}
250+
240251
// Tranfer all elements from the other vector to this one.
241252
// This only offers the weak exception guarantee, that no leaks will happen
242253
// if type T throws in the middle of a copy.
@@ -420,6 +431,11 @@ class fast_vector<T, 0, ShouldInitializeElements>
420431
insert(position - begin(), span.begin(), span.end());
421432
}
422433

434+
void insert(iterator position, const_iterator otherBegin, const_iterator otherEnd)
435+
{
436+
insert(position - begin(), otherBegin, otherEnd);
437+
}
438+
423439
void erase(const_iterator begin, const_iterator end)
424440
{
425441
assert(end >= begin);

0 commit comments

Comments
 (0)