mirror of
https://github.com/esphome/esphome.git
synced 2026-09-22 12:38:40 +00:00
[core] Fix TemplatableValue move: destroy moved-from value for non-trivial T
This commit is contained in:
@@ -101,6 +101,7 @@ template<typename T, typename... X> class TemplatableValue {
|
||||
TemplatableValue(TemplatableValue &&other) noexcept : tag_(other.tag_) {
|
||||
if (this->tag_ == VALUE) {
|
||||
new (&this->value_) T(std::move(other.value_));
|
||||
other.destroy_();
|
||||
} else if (this->tag_ == FN) {
|
||||
this->f_ = other.f_;
|
||||
}
|
||||
@@ -126,6 +127,7 @@ template<typename T, typename... X> class TemplatableValue {
|
||||
this->tag_ = other.tag_;
|
||||
if (this->tag_ == VALUE) {
|
||||
new (&this->value_) T(std::move(other.value_));
|
||||
other.destroy_();
|
||||
} else if (this->tag_ == FN) {
|
||||
this->f_ = other.f_;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user