FastLED 3.10.8
Loading...
Searching...
No Matches

◆ resize_impl()

void fl::vector_basic::resize_impl ( fl::size n)

Resize to n elements. New elements are default-constructed (zeroed for trivial).

Definition at line 308 of file basic_vector.cpp.hpp.

308 {
309 if (n == mSize) return;
310
311 if (n < mSize) {
312 // Shrink: destroy excess elements
313 if (mOps) {
314 mOps->destroy_n(element_ptr(n), mSize - n);
315 }
316 mSize = n;
317 return;
318 }
319
320 // Grow: ensure capacity and default-construct new elements
322 if (mCapacity < n) return; // allocation failed
323
324 if (mOps) {
325 if (mOps->default_construct) {
326 for (fl::size i = mSize; i < n; ++i) {
327 mOps->default_construct(element_ptr(i));
328 }
329 } else {
330 // Type has no default constructor — zero-fill as fallback
332 }
333 } else {
335 }
336 mSize = n;
337}
const vector_element_ops * mOps
void ensure_capacity(fl::size n) FL_NO_EXCEPT
Ensure capacity for at least n elements. Grows if needed.
void * element_ptr(fl::size index) FL_NO_EXCEPT
Pointer to element at index (byte arithmetic).
void trivial_default_construct(void *ptr, fl::size count) const FL_NO_EXCEPT

References element_ptr(), ensure_capacity(), fl::FL_NO_EXCEPT, mCapacity, mOps, mSize, and trivial_default_construct().

Referenced by fl::vector< fl::i16 >::resize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: