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