diff options
Diffstat (limited to 'src/openvic-simulation')
-rw-r--r-- | src/openvic-simulation/types/IdentifierRegistry.hpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/openvic-simulation/types/IdentifierRegistry.hpp b/src/openvic-simulation/types/IdentifierRegistry.hpp index f1edc95..3c81cfc 100644 --- a/src/openvic-simulation/types/IdentifierRegistry.hpp +++ b/src/openvic-simulation/types/IdentifierRegistry.hpp @@ -193,8 +193,13 @@ namespace OpenVic { return duplicate_callback(name, new_identifier); } + /* This string must be created before item is moved as that can invalidate new_identifier. */ + std::string new_identifier_str { new_identifier }; + items.emplace_back(std::move(item)); - identifier_index_map.emplace(std::move(new_identifier), StorageInfo::get_back_index(items)); + + identifier_index_map.emplace(std::move(new_identifier_str), StorageInfo::get_back_index(items)); + return true; } |