add default value option to JsonExpectedValue::get

This commit is contained in:
HJfod 2024-08-23 22:56:17 +03:00
parent 4ec449ed41
commit 908ac44a0b

View file

@ -385,11 +385,11 @@ namespace geode {
// -- Dealing with values -- // -- Dealing with values --
template <class T> template <class T>
T get() { T get(T const& defaultValue = T()) {
if (auto v = this->template tryGet<T>()) { if (auto v = this->template tryGet<T>()) {
return *std::move(v); return *std::move(v);
} }
return T(); return defaultValue;
} }
template <class T> template <class T>
JsonExpectedValue& into(T& value) { JsonExpectedValue& into(T& value) {