From ac35c97a44a339dd6e69bcc503a5aa9edec5e156 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 13 Oct 2025 18:59:46 -1000 Subject: [PATCH] we need copy now --- esphome/core/helpers.h | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/esphome/core/helpers.h b/esphome/core/helpers.h index b94826629f..c0e73b70e0 100644 --- a/esphome/core/helpers.h +++ b/esphome/core/helpers.h @@ -208,9 +208,30 @@ template class FixedVector { ~FixedVector() { cleanup_(); } - // Disable copy operations (avoid accidental expensive copies) - FixedVector(const FixedVector &) = delete; - FixedVector &operator=(const FixedVector &) = delete; + // Copy constructor - performs deep copy + FixedVector(const FixedVector &other) { + if (other.size_ > 0) { + init(other.size_); + for (size_t i = 0; i < other.size_; i++) { + push_back(other.data_[i]); + } + } + } + + // Copy assignment operator - performs deep copy + FixedVector &operator=(const FixedVector &other) { + if (this != &other) { + cleanup_(); + reset_(); + if (other.size_ > 0) { + init(other.size_); + for (size_t i = 0; i < other.size_; i++) { + push_back(other.data_[i]); + } + } + } + return *this; + } // Enable move semantics (allows use in move-only containers like std::vector) FixedVector(FixedVector &&other) noexcept : data_(other.data_), size_(other.size_), capacity_(other.capacity_) {