Skip to content

Commit a3ba714

Browse files
committed
Fix const& scope argument issue
1 parent 827e7ad commit a3ba714

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/openvic-simulation/scripts/Condition.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,17 +1153,27 @@ static constexpr auto _execute_condition_node_list_multi_scope_callback(
11531153
) -> bool {
11541154
return _execute_iterative<EXPECTED_VALUE, REQUIRE_ALL>(
11551155
change_scopes(condition, instance_manager, current_scope, this_scope, from_scope),
1156-
[&instance_manager, &this_scope, &from_scope, &argument](auto new_scope) -> bool {
1156+
[&instance_manager, &this_scope, &from_scope, &argument](auto const& new_scope) -> bool {
11571157
scope_t new_scope_final;
1158-
if constexpr (std::same_as<decltype(new_scope), CountryDefinition const*>) {
1158+
1159+
if constexpr (std::same_as<decltype(new_scope), CountryDefinition const* const&>) {
11591160
new_scope_final = &instance_manager.get_country_instance_manager()
11601161
.get_country_instance_from_definition(*new_scope);
1161-
} else if constexpr (std::same_as<decltype(new_scope), ProvinceDefinition const*>) {
1162+
} else if constexpr (std::same_as<decltype(new_scope), ProvinceDefinition const* const&>) {
11621163
new_scope_final =
11631164
&instance_manager.get_map_instance().get_province_instance_from_definition(*new_scope);
1165+
} else if constexpr (
1166+
// TODO - suppot CountryDefinition const& and ProvinceDefinition const&?
1167+
std::same_as<decltype(new_scope), CountryInstance const&> ||
1168+
std::same_as<decltype(new_scope), State const&> ||
1169+
std::same_as<decltype(new_scope), ProvinceInstance const&> ||
1170+
std::same_as<decltype(new_scope), Pop const&>
1171+
) {
1172+
new_scope_final = &new_scope;
11641173
} else {
11651174
new_scope_final = new_scope;
11661175
}
1176+
11671177
return _execute_condition_node_list<true, true>(
11681178
instance_manager, new_scope_final, this_scope, from_scope, argument
11691179
);

0 commit comments

Comments
 (0)