[core] Fix TemplatableValue move: destroy moved-from value for non-trivial T

This commit is contained in:
J. Nick Koston
2026-04-07 13:55:12 -10:00
parent 11934ab27f
commit d0754d1466
+2
View File
@@ -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_;
}