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

◆ swap()

template<typename T, fl::size N>
void fl::FixedVector< T, N >::swap ( FixedVector< T, N > & other)
inline

Definition at line 409 of file vector.h.

409 {
410 if (this == &other) return;
413 // Swap elements that exist in both vectors
414 for (fl::size i = 0; i < min_sz; ++i) {
415 fl::swap(memory()[i], other.memory()[i]);
416 }
417 // Move remaining elements from the larger to the smaller
419 for (fl::size i = min_sz; i < max_sz; ++i) {
420 T* src = memory() + i;
421 T* dst = other.memory() + i;
422 new (dst) T(fl::move(*src));
423 src->~T();
424 }
425 } else if (other.current_size > current_size) {
426 for (fl::size i = min_sz; i < max_sz; ++i) {
427 T* src = other.memory() + i;
428 T* dst = memory() + i;
429 new (dst) T(fl::move(*src));
430 src->~T();
431 }
432 }
436 }
T * memory() FL_NOEXCEPT
Definition vector.h:90
fl::size current_size
Definition vector.h:439
void swap(T &a, T &b) FL_NOEXCEPT
Definition s16x16x4.h:877
FL_DISABLE_WARNING_PUSH U constexpr common_type_t< T, U > min(T a, U b) FL_NOEXCEPT
Definition math.h:71
constexpr common_type_t< T, U > max(T a, U b) FL_NOEXCEPT
Definition math.h:75