FastLED 3.9.15
Loading...
Searching...
No Matches

◆ insert() [2/2]

template<typename T, fl::size N>
bool fl::FixedVector< T, N >::insert ( iterator pos,
T && value )
inline

Definition at line 278 of file vector.h.

278 {
279 if (current_size < N) {
280 // shift all element from pos to end to the right
281 for (iterator p = end(); p != pos; --p) {
282 T temp = fl::move(*(p - 1));
283 (p)->~T(); // Destroy the current element
284 // Clear the memory
285 void *vp = static_cast<void *>(p);
286 fl::memfill(vp, 0, sizeof(T));
287 new (p) T(fl::move(temp)); // Use move constructor
288 }
289 ++current_size;
290 // now insert the new value
291 new (pos) T(fl::move(value));
292 return true;
293 }
294 return false;
295 }
fl::size current_size
Definition vector.h:341
iterator end()
Definition vector.h:324
constexpr remove_reference< T >::type && move(T &&t) noexcept
Definition move.h:27
void * memfill(void *ptr, int value, fl::size num)
Definition memfill.h:11