From 48b45ba4391ed377ce83c31ce8e314283e011c0c Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 26 Oct 2025 12:01:54 -0700 Subject: [PATCH] we have c++20 --- esphome/core/automation.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/esphome/core/automation.h b/esphome/core/automation.h index eb8c9316ba4..82dce303d28 100644 --- a/esphome/core/automation.h +++ b/esphome/core/automation.h @@ -27,20 +27,21 @@ template class TemplatableValue { public: TemplatableValue() : type_(NONE) {} - template::value, int> = 0> TemplatableValue(F value) : type_(VALUE) { + template + requires(!std::invocable) TemplatableValue(F value) : type_(VALUE) { new (&this->value_) T(std::move(value)); } // For stateless lambdas (convertible to function pointer): use function pointer - template::value && std::is_convertible::value, int> = 0> - TemplatableValue(F f) : type_(STATELESS_LAMBDA) { + template + requires std::invocable && std::convertible_to TemplatableValue(F f) + : type_(STATELESS_LAMBDA) { this->stateless_f_ = f; // Implicit conversion to function pointer } // For stateful lambdas (not convertible to function pointer): use std::function - template::value && !std::is_convertible::value, int> = 0> - TemplatableValue(F f) : type_(LAMBDA) { + template + requires std::invocable &&(!std::convertible_to) TemplatableValue(F f) : type_(LAMBDA) { this->f_ = new std::function(std::move(f)); }