mirror of https://github.com/esphome/esphome.git
esphome::optional: implement direct-initializing constructor
This allows code generator to pass e.g. string literals for functions with optional<std::string> arguments.
This commit is contained in:
parent
243469ad7c
commit
ef7cfacc33
|
@ -48,6 +48,8 @@ template<typename T> class optional { // NOLINT
|
|||
|
||||
template<class U> optional(optional<U> const &other) : has_value_(other.has_value()), value_(other.value()) {}
|
||||
|
||||
template<class U = T> constexpr optional(U &&value) : has_value_(true), value_(std::forward<U>(value)) {}
|
||||
|
||||
optional &operator=(nullopt_t) {
|
||||
reset();
|
||||
return *this;
|
||||
|
|
Loading…
Reference in New Issue