diff --git a/include/cereal/details/helpers.hpp b/include/cereal/details/helpers.hpp index 8dafb8ec..48e93f50 100644 --- a/include/cereal/details/helpers.hpp +++ b/include/cereal/details/helpers.hpp @@ -412,8 +412,13 @@ namespace cereal std::uint32_t find( std::size_t hash, std::uint32_t version ) { - const auto result = mapping.emplace( hash, version ); - return result.first->second; + auto it = mapping.find(hash); + if (it == mapping.end()) { + mapping.emplace(hash, version); + return version; + } + else + return it->second; } }; // struct Versions } // namespace detail