mirror of
https://github.com/esphome/esphome.git
synced 2025-10-31 23:21:54 +00:00
Merge branch 'integration' into memory_api
This commit is contained in:
@@ -35,14 +35,14 @@ template<typename T, typename... Args> class TemplateLambda {
|
||||
bool has_value() const { return this->f_ != nullptr; }
|
||||
|
||||
/** Call the lambda, returning nullopt if no lambda is set */
|
||||
optional<T> operator()(Args... args) {
|
||||
optional<T> operator()(Args &&...args) {
|
||||
if (this->f_ == nullptr)
|
||||
return nullopt;
|
||||
return this->f_(args...);
|
||||
return this->f_(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
/** Alias for operator() for compatibility */
|
||||
optional<T> call(Args... args) { return (*this)(args...); }
|
||||
optional<T> call(Args &&...args) { return (*this)(std::forward<Args>(args)...); }
|
||||
|
||||
protected:
|
||||
optional<T> (*f_)(Args...); // Function pointer (4 bytes on ESP32)
|
||||
|
||||
Reference in New Issue
Block a user