diff --git a/esphome/core/helpers.h b/esphome/core/helpers.h index 192fd3838c..88fb600d95 100644 --- a/esphome/core/helpers.h +++ b/esphome/core/helpers.h @@ -204,9 +204,12 @@ template class FixedVector { /// This enables brace initialization: FixedVector v = {1, 2, 3}; FixedVector(std::initializer_list init_list) { init(init_list.size()); + size_t idx = 0; for (const auto &item : init_list) { - push_back(item); + new (data_ + idx) T(item); + ++idx; } + size_ = init_list.size(); } ~FixedVector() { cleanup_(); }