Fix optional::operator=

This commit is contained in:
yvt 2019-07-20 13:42:34 +09:00
parent 9e770cc040
commit 464b88a23b
No known key found for this signature in database
GPG Key ID: 48F2768FA8D07C92

View File

@ -85,15 +85,19 @@ namespace stmp {
void operator=(const optional &o) { void operator=(const optional &o) {
if (has_some && o.has_some) { if (has_some && o.has_some) {
**this = *o; **this = *o;
} else { } else if (o.has_some) {
reset(*o); reset(*o);
} else {
reset();
} }
} }
void operator=(optional &&o) { void operator=(optional &&o) {
if (has_some && o.has_some) { if (has_some && o.has_some) {
**this = *std::move(o); **this = *std::move(o);
} else { } else if (o.has_some) {
reset(*std::move(o)); reset(*std::move(o));
} else {
reset();
} }
} }