mirror of
https://github.com/esphome/esphome.git
synced 2025-07-24 20:26:35 +00:00
address clang-tidy
This commit is contained in:
parent
ed61a2b77e
commit
2d15a3c0e8
@ -5,6 +5,7 @@
|
||||
#include "api_pb2.h"
|
||||
#include "esphome/core/automation.h"
|
||||
#include "esphome/core/helpers.h"
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace esphome {
|
||||
@ -36,10 +37,10 @@ template<typename... X> class TemplatableStringValue : public TemplatableValue<s
|
||||
|
||||
template<typename... Ts> class TemplatableKeyValuePair {
|
||||
public:
|
||||
// It's safe to use const std::string& for the key parameter because keys are always
|
||||
// string literals from YAML dictionary keys (e.g., "code", "event") and never
|
||||
// templatable values or lambdas. Only the value parameter can be a lambda/template.
|
||||
template<typename T> TemplatableKeyValuePair(const std::string &key, T value) : key(key), value(value) {}
|
||||
// Keys are always string literals from YAML dictionary keys (e.g., "code", "event")
|
||||
// and never templatable values or lambdas. Only the value parameter can be a lambda/template.
|
||||
// Using pass-by-value with std::move allows optimal performance for both lvalues and rvalues.
|
||||
template<typename T> TemplatableKeyValuePair(std::string key, T value) : key(std::move(key)), value(value) {}
|
||||
std::string key;
|
||||
TemplatableStringValue<Ts...> value;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user