From 8a00697a0e6a4168894594eadc373836a1689eea Mon Sep 17 00:00:00 2001 From: hop311 Date: Sun, 29 Oct 2023 22:16:14 +0000 Subject: Country: datatypes + TGC compat changes --- src/openvic-simulation/types/IdentifierRegistry.hpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src/openvic-simulation/types/IdentifierRegistry.hpp') diff --git a/src/openvic-simulation/types/IdentifierRegistry.hpp b/src/openvic-simulation/types/IdentifierRegistry.hpp index bcb8e33..ebdedce 100644 --- a/src/openvic-simulation/types/IdentifierRegistry.hpp +++ b/src/openvic-simulation/types/IdentifierRegistry.hpp @@ -49,10 +49,12 @@ namespace OpenVic { #define HASID_PROPERTY(NAME) \ const NAME; \ +\ public: \ - auto get_##NAME() const->decltype(get_property(NAME)) { \ + auto get_##NAME() const -> decltype(get_property(NAME)) { \ return get_property(NAME); \ } \ +\ private: }; @@ -180,9 +182,10 @@ private: return duplicate_callback(name, new_identifier); } } - identifier_index_map.emplace(new_identifier, items.size()); - items.push_back(std::move(item)); - return true; + const std::pair::iterator, bool> ret = + identifier_index_map.emplace(std::move(new_identifier), items.size()); + items.emplace_back(std::move(item)); + return ret.second && ret.first->second + 1 == items.size(); } void lock() { @@ -280,8 +283,9 @@ private: return identifiers; } - NodeTools::node_callback_t expect_item_decimal_map(NodeTools::callback_t&&> callback) - const { + NodeTools::node_callback_t expect_item_decimal_map( + NodeTools::callback_t&&> callback + ) const { return [this, callback](ast::NodeCPtr node) -> bool { decimal_map_t map; bool ret = expect_item_dictionary([&map](value_type const& key, ast::NodeCPtr value) -> bool { @@ -390,7 +394,9 @@ private: ) { \ return plural.expect_item_str(callback); \ } \ - NodeTools::node_callback_t expect_##singular##_identifier(NodeTools::callback_t callback) { \ + NodeTools::node_callback_t expect_##singular##_identifier( \ + NodeTools::callback_t callback \ + ) { \ return plural.expect_item_identifier(callback); \ } \ NodeTools::node_callback_t expect_##singular##_dictionary( \ -- cgit v1.2.3-56-ga3b1