Use std::optional::emplace() when loading to construct and load the contained value directly in place

This commit is contained in:
logan
2021-06-10 09:42:24 -07:00
committed by Shane Grant
parent 0bbbb142f9
commit f8338dbb73

View File

@@ -56,9 +56,8 @@ namespace cereal {
if (nullopt) {
optional = std::nullopt;
} else {
T value;
ar(CEREAL_NVP_("data", value));
optional = std::move(value);
optional.emplace();
ar(CEREAL_NVP_("data", *optional));
}
}
} // namespace cereal