Skip to content

Commit a3ce5c5

Browse files
committed
Fix fast_vector assign
1 parent 12b3725 commit a3ce5c5

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

Common.FastVector.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ class fast_vector<T, 0, ShouldInitializeElements>
227227

228228
// Clear any existing elements and copy the new elements from the iterable range.
229229
template <typename IteratorType>
230+
requires(!std::is_convertible_v<IteratorType, size_t>)
230231
void assign(IteratorType begin, IteratorType end)
231232
{
232233
clear();
@@ -238,13 +239,12 @@ class fast_vector<T, 0, ShouldInitializeElements>
238239
}
239240

240241
// Clear any existing elements and copy the new elements from the iterable range.
241-
template <typename IteratorType>
242242
void assign(size_t newSize, const T& value)
243243
{
244244
clear();
245245

246246
reserve(newSize);
247-
std::uninitialized_fill(begin(), end(), /*out*/ data_);
247+
std::uninitialized_fill(begin(), end(), /*out*/ value);
248248
size_ = newSize;
249249
}
250250

Common.FastVector.ixx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,12 @@ void fast_vector_test()
186186
assert(ints[0] == 1);
187187
assert(ints[2] == 3);
188188

189+
auto intAssignmentInitializerList = { 1,2,3 };
190+
std::vector<int> intAssignmentVector({1,2,3});
191+
ints.assign(intAssignmentInitializerList.begin(), intAssignmentInitializerList.end());
192+
ints.assign(intAssignmentVector.begin(), intAssignmentVector.end());
193+
ints.assign(3, 0);
194+
189195
// Create another vector from the old one.
190196
ints2[0] = 1;
191197
ints2[2] = 3;

0 commit comments

Comments
 (0)