diff --git a/esphome/core/automation.h b/esphome/core/automation.h index d357c6f58e..83f0941bac 100644 --- a/esphome/core/automation.h +++ b/esphome/core/automation.h @@ -27,21 +27,20 @@ template class TemplatableValue { public: TemplatableValue() : type_(NONE) {} - template - requires(!std::invocable) TemplatableValue(F value) : type_(VALUE) { + template TemplatableValue(F value) requires(!std::invocable) : type_(VALUE) { new (&this->value_) T(std::move(value)); } // For stateless lambdas (convertible to function pointer): use function pointer template - requires std::invocable && std::convertible_to TemplatableValue(F f) + TemplatableValue(F f) requires std::invocable && std::convertible_to : type_(STATELESS_LAMBDA) { this->stateless_f_ = f; // Implicit conversion to function pointer } // For stateful lambdas (not convertible to function pointer): use std::function template - requires std::invocable &&(!std::convertible_to) TemplatableValue(F f) : type_(LAMBDA) { + TemplatableValue(F f) requires std::invocable && !std::convertible_to : type_(LAMBDA) { this->f_ = new std::function(std::move(f)); }