Improve type safety in GetValueOrDefault

This commit is contained in:
2025-02-07 22:27:57 +01:00
parent 1fd3f05ebd
commit ceb392a198
3 changed files with 6 additions and 3 deletions

View File

@@ -272,7 +272,10 @@ namespace minipp
ValueDataType* value = nullptr; ValueDataType* value = nullptr;
if (GetValue(key, &value) != EResult::Success) if (GetValue(key, &value) != EResult::Success)
return defaultValue; return defaultValue;
return value->GetValue(); auto casted = dynamic_cast<ValueDataType*>(value);
if (casted == nullptr)
return defaultValue;
return casted->GetValue();
} }
public: public: