Skip to content

Commit

Permalink
Use std::optional::emplace() when loading to construct and load the c…
Browse files Browse the repository at this point in the history
…ontained value directly in place
  • Loading branch information
kepler-5 authored and AzothAmmo committed Sep 17, 2021
1 parent 0bbbb14 commit f8338db
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions include/cereal/types/optional.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f8338db

Please sign in to comment.