From 6eeaca2020d21fa17038801da561360c691214ff Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 19 Jan 2026 22:36:28 -1000 Subject: [PATCH] bot --- esphome/core/helpers.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/esphome/core/helpers.h b/esphome/core/helpers.h index 5759135392..a134c6d090 100644 --- a/esphome/core/helpers.h +++ b/esphome/core/helpers.h @@ -1345,17 +1345,24 @@ template class LazyCallbackManager; * - CallbackManager: 12 bytes (empty std::vector) * - LazyCallbackManager: 4 bytes (nullptr pointer) * - * Note: Uses plain pointer instead of unique_ptr since callbacks are never freed - * (entities live for device lifetime). This avoids destructor template overhead. + * Uses plain pointer instead of unique_ptr to avoid template instantiation overhead. + * The class is explicitly non-copyable/non-movable for Rule of Five compliance. * * @tparam Ts The arguments for the callbacks, wrapped in void(). */ template class LazyCallbackManager { public: + LazyCallbackManager() = default; /// Destructor - clean up allocated CallbackManager if any. /// In practice this never runs (entities live for device lifetime) but included for correctness. ~LazyCallbackManager() { delete this->callbacks_; } + // Non-copyable and non-movable (entities are never copied or moved) + LazyCallbackManager(const LazyCallbackManager &) = delete; + LazyCallbackManager &operator=(const LazyCallbackManager &) = delete; + LazyCallbackManager(LazyCallbackManager &&) = delete; + LazyCallbackManager &operator=(LazyCallbackManager &&) = delete; + /// Add a callback to the list. Allocates the underlying CallbackManager on first use. void add(std::function &&callback) { if (!this->callbacks_) {